Skip to content
Latchkey

Bump package version on main workflow (notionnext-org/NotionNext)

The Bump package version on main workflow from notionnext-org/NotionNext, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: notionnext-org/NotionNext.github/workflows/bump-version-on-main.ymlLicense MITView source

What it does

This is the Bump package version on main workflow from the notionnext-org/NotionNext repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# 每次向 main 推送(含合并 PR)后,自动将 package.json 最后一位小版本 +1。
# 自动提交信息含 [skip-version],避免无限循环。发正式版或大版本时请人工改版本号后再合并。

name: Bump package version on main

on:
  push:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write

concurrency:
  group: bump-package-version-main
  cancel-in-progress: false

jobs:
  bump-patch:
    runs-on: ubuntu-latest
    # 跳过自动发版机器人自己的提交,防止循环触发
    if: >-
      github.event_name == 'workflow_dispatch' ||
      (github.event.head_commit != null &&
       !contains(github.event.head_commit.message, '[skip-version]'))

    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Bump package.json patch (last segment)
        id: bump
        run: |
          node scripts/bump-package-patch-version.js
          VERSION=$(node -p "require('./package.json').version")
          echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

      - name: Push version bump branch
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          if git diff --quiet package.json; then
            echo "No version change (unexpected)."
            exit 0
          fi
          BRANCH="chore/bump-package-version"
          git checkout -B "${BRANCH}"
          git add package.json
          git commit -m "chore(release): bump package.json to ${{ steps.bump.outputs.version }} [skip-version]"
          git push --force-with-lease origin "${BRANCH}"
          {
            echo "Version bump branch pushed: \`${BRANCH}\`"
            echo ""
            echo "Create a pull request from \`${BRANCH}\` to \`main\` to publish version ${{ steps.bump.outputs.version }}."
          } >> "$GITHUB_STEP_SUMMARY"

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

# 每次向 main 推送(含合并 PR)后,自动将 package.json 最后一位小版本 +1。
# 自动提交信息含 [skip-version],避免无限循环。发正式版或大版本时请人工改版本号后再合并。
 
name: Bump package version on main
 
on:
  push:
    branches:
      - main
  workflow_dispatch:
 
permissions:
  contents: write
 
concurrency:
  group: bump-package-version-main
  cancel-in-progress: false
 
jobs:
  bump-patch:
    timeout-minutes: 30
    runs-on: latchkey-small
    # 跳过自动发版机器人自己的提交,防止循环触发
    if: >-
      github.event_name == 'workflow_dispatch' ||
      (github.event.head_commit != null &&
       !contains(github.event.head_commit.message, '[skip-version]'))
 
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
 
      - name: Bump package.json patch (last segment)
        id: bump
        run: |
          node scripts/bump-package-patch-version.js
          VERSION=$(node -p "require('./package.json').version")
          echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
 
      - name: Push version bump branch
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          if git diff --quiet package.json; then
            echo "No version change (unexpected)."
            exit 0
          fi
          BRANCH="chore/bump-package-version"
          git checkout -B "${BRANCH}"
          git add package.json
          git commit -m "chore(release): bump package.json to ${{ steps.bump.outputs.version }} [skip-version]"
          git push --force-with-lease origin "${BRANCH}"
          {
            echo "Version bump branch pushed: \`${BRANCH}\`"
            echo ""
            echo "Create a pull request from \`${BRANCH}\` to \`main\` to publish version ${{ steps.bump.outputs.version }}."
          } >> "$GITHUB_STEP_SUMMARY"
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow