Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ‘· ci: publish releases as lobe-tsukumo GitHub App (#19758)

Innei96b73d41d712
diff --git a/.agents/skills/version-release/SKILL.md b/.agents/skills/version-release/SKILL.md
index 9a86c8a1a16..4f586a6c1e4 100644
--- a/.agents/skills/version-release/SKILL.md
+++ b/.agents/skills/version-release/SKILL.md
@@ -28,7 +28,7 @@ For every `/version-release` execution, you MUST load and apply:
## Overview
-The primary development branch is **canary**. All day-to-day development happens on canary. When releasing, canary is merged into main. After merge, `auto-tag-release.yml` automatically handles tagging, version bumping, creating a GitHub Release, and syncing back to the canary branch.
+The primary development branch is **canary**. All day-to-day development happens on canary. When releasing, canary is merged into main. Conventional release PRs (`πŸš€ release: …`, `release/*`, `hotfix/*`) get a `package.json` bump commit from `release-pr-version.yml` while the PR is open. After merge, `auto-tag-release.yml` tags the merge commit and creates the GitHub Release. `sync-main-to-canary` runs on push to `main`.
Only two release types are used in practice (major releases are extremely rare and can be ignored):
@@ -64,12 +64,11 @@ Triggered by the following priority:
PRs that don't match any conditions above (e.g. `docs`, `chore`, `ci`, `test`) will not trigger a release when merged into main.
-## Post-Release Automated Actions
+## Automated Actions
-1. **Bump `package.json`** β€” commits `πŸ”– chore(release): release version v{x.y.z} [skip ci]`
-2. **Create annotated tag** β€” `v{x.y.z}`
-3. **Create GitHub Release**
-4. **Dispatch `sync-main-to-canary`** β€” syncs main back to canary
+1. **On the release PR** (`release-pr-version.yml`) β€” if `package.json` is behind, commit `πŸ”– chore(release): release version v{x.y.z}` to the PR head. Minor titles `πŸš€ release: v{x.y.z}` use that version; weekly / `release/*` / `hotfix/*` use latest stable tag + patch.
+2. **After merge** (`auto-tag-release.yml`) β€” tag `v{x.y.z}` on the merge commit and create the GitHub Release. Patch version is latest stable tag +1, not `package.json` +1.
+3. **`sync-main-to-canary`** β€” runs on push to `main`.
## Agent Action Guide
diff --git a/.agents/skills/version-release/references/minor-release.md b/.agents/skills/version-release/references/minor-release.md
index 51d28aca29b..dfc00c2cef7 100644
--- a/.agents/skills/version-release/references/minor-release.md
+++ b/.agents/skills/version-release/references/minor-release.md
@@ -30,7 +30,8 @@ Used to publish a new minor version (e.g. `v2.2.0`), roughly every 4 weeks. The
4. **Write the PR body as release notes** β€” Follow `release-notes-style.md`. Compare base is the latest semver tag on main (`git describe --tags --abbrev=0 origin/main`).
-5. **Automatic trigger after merge** β€” `auto-tag-release` detects the title format, uses the version number from the title, bumps `package.json`, tags `v{x.y.z}`, creates the GitHub Release, and dispatches `sync-main-to-canary`.
+5. **While the PR is open** β€” `release-pr-version.yml` commits `package.json` to the title version if it is not already there.
+6. **After merge** β€” `auto-tag-release` reads the title version, tags `v{x.y.z}` on the merge commit, and creates the GitHub Release.
## Scripts
@@ -42,6 +43,6 @@ bun run release:branch --minor # Directly specify minor
## Hard Rules (specific to Minor)
- PR title format is **strict**: `πŸš€ release: v{x.y.z}`. Any deviation falls through to patch detection.
-- Do **NOT** manually modify `package.json` version β€” CI will bump it.
+- Do **NOT** manually modify `package.json` version β€” CI commits it onto the release PR.
- Do **NOT** manually create the tag β€” CI will tag.
- Highlights bullet count is usually 8–12 (see `release-notes-style.md` size heuristics).
diff --git a/.agents/skills/version-release/references/patch-release-scenarios.md b/.agents/skills/version-release/references/patch-release-scenarios.md
index 6c2e81f63d3..0ac97f7758d 100644
--- a/.agents/skills/version-release/references/patch-release-scenarios.md
+++ b/.agents/skills/version-release/references/patch-release-scenarios.md
@@ -42,7 +42,8 @@ gh pr create \
--body-file changelog.md
```
-4. **After merge**: auto-tag-release detects `release/*` branch β†’ auto patch +1.
+4. **While the PR is open**: `release-pr-version.yml` commits `package.json` to latest stable tag + patch.
+5. **After merge**: auto-tag-release detects `release/*` branch β†’ tags latest stable tag +1.
---
@@ -66,7 +67,8 @@ git push -u origin hotfix/v{version}-{short-hash}
3. **Write a short hotfix changelog** β€” See `changelog-example/hotfix.md`. Keep it minimal: scope line, 1-3 fix bullets (symptom + fix in one sentence), upgrade note, owner. No long root-cause section β€” that lives in the commit message.
- **Hotfix owner**: Use the actual PR author (retrieve via `gh pr view <number> --json author --jq '.author.login'`), never hardcode a username.
-4. **After merge**: auto-tag-release detects `hotfix/*` branch β†’ auto patch +1.
+4. **While the PR is open**: `release-pr-version.yml` commits `package.json` to latest stable tag + patch.
+5. **After merge**: auto-tag-release detects `hotfix/*` branch β†’ tags latest stable tag +1.
### Script
@@ -124,4 +126,5 @@ gh pr create \
--body-file changelog.md
```
-4. **After merge**: auto-tag-release detects `release/*` branch β†’ auto patch +1.
+4. **While the PR is open**: `release-pr-version.yml` commits `package.json` to latest stable tag + patch.
+5. **After merge**: auto-tag-release detects `release/*` branch β†’ tags latest stable tag +1.
diff --git a/.github/workflows/auto-i18n.yml b/.github/workflows/auto-i18n.yml
index f3e22f591fc..668523f5f7b 100644
--- a/.github/workflows/auto-i18n.yml
+++ b/.github/workflows/auto-i18n.yml
@@ -16,6 +16,12 @@ jobs:
timeout-minutes: 30
steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
- name: Configure Git
run: |
git config --global user.name "lobehubbot"
@@ -24,6 +30,7 @@ jobs:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.ref }}
+ token: ${{ steps.app-token.outputs.token }}
- name: Setup environment
uses: ./.github/actions/setup-env
@@ -41,7 +48,7 @@ jobs:
id: cpr
uses: peter-evans/create-pull-request@v7
with:
- token: ${{ secrets.GH_TOKEN }}
+ token: ${{ steps.app-token.outputs.token }}
add-paths: |
locales/**/*.json
labels: |
diff --git a/.github/workflows/auto-tag-release.yml b/.github/workflows/auto-tag-release.yml
index f2cb19d683d..e807215c752 100644
--- a/.github/workflows/auto-tag-release.yml
+++ b/.github/workflows/auto-tag-release.yml
@@ -13,15 +13,20 @@ jobs:
auto-tag:
name: Auto Tag Release
runs-on: ubuntu-latest
- # Only trigger when PR is merged
if: github.event.pull_request.merged == true
steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
- name: Checkout
uses: actions/checkout@v7
with:
- token: ${{ secrets.GH_TOKEN }}
- # Fetch full history for proper tagging
+ token: ${{ steps.app-token.outputs.token }}
+ ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: 0
- name: Detect release PR (version from title)
@@ -68,31 +73,24 @@ jobs:
echo "⏭️ Not a patch PR (neither hotfix/release branch nor style/feat/fix/refactor/hotfix/build title prefix)"
fi
- - name: Prepare main branch
- if: steps.release.outputs.should_tag == 'true' || steps.patch.outputs.should_tag == 'true'
- run: |
- git checkout main
- git pull --rebase origin main
-
- - name: Setup environment
- if: steps.release.outputs.should_tag == 'true' || steps.patch.outputs.should_tag == 'true'
- uses: ./.github/actions/setup-env
-
- - name: Install deps
- if: steps.release.outputs.should_tag == 'true' || steps.patch.outputs.should_tag == 'true'
- run: pnpm install
-
- name: Resolve patch version (patch bump)
id: patch-version
if: steps.patch.outputs.should_tag == 'true'
run: |
- CURRENT_VERSION="$(node -p "require('./package.json').version")"
- echo "Current version: ${CURRENT_VERSION}"
+ git fetch --tags origin
+ LATEST_TAG="$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)"
+ if [ -z "$LATEST_TAG" ]; then
+ CURRENT_VERSION="$(node -p "require('./package.json').version")"
+ echo "No stable tag, falling back to package.json: ${CURRENT_VERSION}"
+ else
+ CURRENT_VERSION="${LATEST_TAG#v}"
+ echo "Latest stable tag: ${LATEST_TAG}"
+ fi
# Coerce to stable base (e.g. 2.0.0-beta.1 -> 2.0.0), then bump patch (-> 2.0.1)
BASE_VERSION="$(npx -y semver@7 "${CURRENT_VERSION}" -c)"
if [ -z "${BASE_VERSION}" ]; then
- echo "❌ Invalid version in package.json: ${CURRENT_VERSION}"
+ echo "❌ Invalid version: ${CURRENT_VERSION}"
exit 1
fi
@@ -127,82 +125,12 @@ jobs:
echo "βœ… Tag v$VERSION does not exist, can create"
fi
- - name: Bump package.json version
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- run: |
- VERSION="${{ env.VERSION }}"
- echo "πŸ“ Bumping package.json version to: $VERSION"
-
- # Validate VERSION is strict semver before writing
- if ! npx -y semver@7 "$VERSION" >/dev/null 2>&1; then
- echo "❌ Invalid semver version: $VERSION"
- exit 1
- fi
-
- # Update package.json using Node.js
- node -e "
- const fs = require('fs');
- const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
- const target = '$VERSION';
- if (pkg.version === target) {
- console.log('βœ… package.json already at version', target);
- process.exit(0);
- }
- pkg.version = target;
- fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
- console.log('βœ… package.json updated to', target);
- "
-
- - name: Generate changelog
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- run: bun run workflow:changelog:gen
-
- - name: Build static changelog
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- run: bun run workflow:changelog
-
- - name: Commit release changes and push
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- id: bump-version
- run: |
- VERSION="${{ env.VERSION }}"
-
- # Configure git
- git config --global user.name "lobehubbot"
- git config --global user.email "[email protected]"
-
- # Commit changes (if any) and push
- git add package.json CHANGELOG.md changelog/
- COMMIT_MSG="πŸ”– chore(release): release version v$VERSION [skip ci]"
- git commit -m "$COMMIT_MSG" || echo "Nothing to commit"
- git push origin HEAD:main
-
- # Output the SHA we will tag
- echo "tag_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
-
- - name: Create Tag
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- run: |
- VERSION="${{ env.VERSION }}"
- KIND="${{ env.KIND }}"
- echo "🏷️ Creating tag: v$VERSION"
-
- # Tag the bumped version commit SHA (not the PR merge commit SHA)
- TAG_SHA="${{ steps.bump-version.outputs.tag_sha }}"
-
- # Create annotated tag with single line message
- git tag -a "v$VERSION" "$TAG_SHA" -m "πŸš€ release: v$VERSION | PR #${{ github.event.pull_request.number }} | Author: ${{ github.event.pull_request.user.login }}"
-
- # Push tag
- git push origin "v$VERSION"
-
- echo "βœ… Tag v$VERSION created successfully!"
-
- name: Create GitHub Release
if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.VERSION }}
+ target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
name: πŸš€ Release v${{ env.VERSION }}
body: |
## πŸ“¦ Release v${{ env.VERSION }}
@@ -216,15 +144,7 @@ jobs:
${{ github.event.pull_request.body }}
draft: false
env:
- GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
-
- - name: Sync main to canary
- if: env.SHOULD_TAG == 'true' && steps.check-tag.outputs.exists == 'false'
- run: |
- gh workflow run sync-main-to-canary.yaml --ref main
- echo "βœ… Dispatched sync-main-to-canary workflow"
- env:
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Output result
run: |
diff --git a/.github/workflows/release-desktop-canary.yml b/.github/workflows/release-desktop-canary.yml
index 28f45e45f63..028e20dc4f4 100644
--- a/.github/workflows/release-desktop-canary.yml
+++ b/.github/workflows/release-desktop-canary.yml
@@ -440,6 +440,12 @@ jobs:
permissions:
contents: write
steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
- name: Download merged artifacts
uses: actions/download-artifact@v7
with:
@@ -467,7 +473,7 @@ jobs:
release/*.rpm*
release/*.tar.gz*
env:
- GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
+ GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# ============================================
# ε‘εΈƒεˆ° S3 ζ›΄ζ–°ζœεŠ‘ε™¨
diff --git a/.github/workflows/release-pr-version.yml b/.github/workflows/release-pr-version.yml
new file mode 100644
index 00000000000..846111100db
--- /dev/null
+++ b/.github/workflows/release-pr-version.yml
@@ -0,0 +1,93 @@
+name: Release PR Version
+
+on:
+ pull_request:
+ types: [opened, edited, synchronize, reopened]
+ branches:
+ - main
+
+permissions:
+ contents: write
+
+concurrency:
+ group: release-pr-version-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
+jobs:
+ bump:
+ name: Bump package.json on release PR
+ runs-on: ubuntu-latest
+ if: >
+ github.event.pull_request.head.repo.full_name == github.repository &&
+ (
+ startsWith(github.event.pull_request.head.ref, 'release/') ||
+ startsWith(github.event.pull_request.head.ref, 'hotfix/') ||
+ startsWith(github.event.pull_request.title, 'πŸš€ release:')
+ )
+ steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
+ - uses: actions/checkout@v7
+ with:
+ token: ${{ steps.app-token.outputs.token }}
+ ref: ${{ github.head_ref }}
+ fetch-depth: 0
+
+ - name: Resolve target version
+ id: version
+ env:
+ PR_TITLE: ${{ github.event.pull_request.title }}
+ run: |
+ set -euo pipefail
+ git fetch --tags origin
+
+ if [[ "$PR_TITLE" =~ ^πŸš€[[:space:]]+release:[[:space:]]*v([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?)$ ]]; then
+ VERSION="${BASH_REMATCH[1]}"
+ echo "Using version from PR title: $VERSION"
+ else
+ LATEST_TAG="$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true)"
+ if [ -z "$LATEST_TAG" ]; then
+ CURRENT="$(node -p "require('./package.json').version")"
+ else
+ CURRENT="${LATEST_TAG#v}"
+ fi
+ BASE="$(npx -y semver@7 "$CURRENT" -c)"
+ if [ -z "$BASE" ]; then
+ echo "Invalid current version: $CURRENT"
+ exit 1
+ fi
+ VERSION="$(npx -y semver@7 -i patch "$BASE")"
+ echo "Using next patch from ${LATEST_TAG:-package.json}: $VERSION"
+ fi
+
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
+
+ - name: Commit package.json if needed
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
+ HEAD_REF: ${{ github.head_ref }}
+ run: |
+ set -euo pipefail
+ CURRENT="$(node -p "require('./package.json').version")"
+ if [ "$CURRENT" = "$VERSION" ]; then
+ echo "package.json already at $VERSION"
+ exit 0
+ fi
+
+ node -e "
+ const fs = require('fs');
+ const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
+ pkg.version = process.env.VERSION;
+ fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
+ "
+
+ git config user.name 'lobe-tsukumo[bot]'
+ git config user.email '4998174+lobe-tsukumo[bot]@users.noreply.github.com'
+ git add package.json
+ git commit -m "πŸ”– chore(release): release version v${VERSION}"
+ git pull --rebase origin "$HEAD_REF"
+ git push origin "HEAD:$HEAD_REF"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6d899ad2edf..50add8436cb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -33,9 +33,15 @@ jobs:
- 5432:5432
steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
- uses: actions/checkout@v7
with:
- token: ${{ secrets.GH_TOKEN }}
+ token: ${{ steps.app-token.outputs.token }}
- name: Setup environment
uses: ./.github/actions/setup-env
@@ -70,4 +76,4 @@ jobs:
git commit -m "πŸ“ docs(bot): Auto sync agents & plugin to readme" || exit 0
git push
env:
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
diff --git a/.github/workflows/sync-main-to-canary.yaml b/.github/workflows/sync-main-to-canary.yaml
index 1c4079ce52a..4782772491f 100644
--- a/.github/workflows/sync-main-to-canary.yaml
+++ b/.github/workflows/sync-main-to-canary.yaml
@@ -18,11 +18,17 @@ jobs:
sync-branches:
runs-on: ubuntu-latest
steps:
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ vars.LOBEHUB_BOT_APP_ID }}
+ private-key: ${{ secrets.LOBEHUB_BOT_APP_PRIVATE_KEY }}
+
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- token: ${{ secrets.GH_TOKEN }}
+ token: ${{ steps.app-token.outputs.token }}
- name: Set up Git
run: |
@@ -126,4 +132,4 @@ jobs:
--body-file /tmp/pr-body.md
fi
env:
- GH_TOKEN: ${{ secrets.GH_TOKEN }}
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}