From 6b4947b3a84ec49962f50f871a037e845cfbad62 Mon Sep 17 00:00:00 2001 From: Arnaud Lheureux Date: Tue, 26 May 2026 14:01:25 +0800 Subject: [PATCH] fix(release): bump plugin.json and marketplace.json on tag-push releases The 'Commit version bump' step that lands plugin.json + marketplace.json on the source branch is gated to workflow_dispatch only. On the normal tag-push trigger (git push origin vX.Y.Z, or 'gh release create' which pushes a tag), the bumped files are used in-process to build the VSIX but never committed back to main. Result: after v0.0.2 and v0.0.3 shipped via tag push, main was still at 0.0.1, and the post-release 'Update CHANGELOG.md on main' step left a dangling 'changelog/' PR each time (since main lacked the bump, that PR also did not bring the bump in). Fix: extend the post-release main-update step to re-apply the version bump against the freshly-checked-out main tree, and stage plugin.json + .github/plugin/marketplace.json alongside CHANGELOG.md in the same commit. The push (or fallback PR) now lands the bump and the changelog entry together. - Renames the step to 'Bump version files and update CHANGELOG.md on main' - Re-applies the same jq bumps used by the earlier 'Bump' step - Adds plugin.json + marketplace.json to the diff check and 'git add' - Renames the fallback PR branch from 'changelog/' to 'release/' and updates its title/body to reflect the broader scope - Prereleases (-rc.x etc.) are still skipped, matching prior behaviour Workflow file passes actionlint. --- .github/workflows/git-ape-release.yml | 40 +++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/git-ape-release.yml b/.github/workflows/git-ape-release.yml index d1d0f77..76a6bba 100644 --- a/.github/workflows/git-ape-release.yml +++ b/.github/workflows/git-ape-release.yml @@ -331,7 +331,7 @@ jobs: # shellcheck disable=SC2086 vsce publish --packagePath "$VSIX_FILE" --no-dependencies $FLAG - - name: Update CHANGELOG.md on main + - name: Bump version files and update CHANGELOG.md on main if: steps.ver.outputs.prerelease == 'false' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -340,11 +340,29 @@ jobs: run: | set -euo pipefail - # Always work against the tip of main so the changelog stays current, - # even when this run was triggered by a tag push from an older commit. + # Always work against the tip of main so the bump + changelog stay + # current, even when this run was triggered by a tag push from an + # older commit. (On tag-push the earlier "Commit version bump" step + # is skipped, so plugin.json / marketplace.json on main would + # otherwise stay at the previous version.) git fetch origin main git checkout -B changelog-update origin/main + # Re-apply the version bump against the fresh main tree so the same + # commit lands the version-bearing files AND the changelog entry. + PLUGIN_JSON="plugin.json" + MARKETPLACE_JSON=".github/plugin/marketplace.json" + PLUGIN_NAME=$(jq -r '.name' "$PLUGIN_JSON") + + jq --arg v "$VERSION" '.version = $v' "$PLUGIN_JSON" > "$PLUGIN_JSON.tmp" + mv "$PLUGIN_JSON.tmp" "$PLUGIN_JSON" + + jq --arg v "$VERSION" --arg name "$PLUGIN_NAME" ' + .metadata.version = $v + | .plugins |= map(if .name == $name then .version = $v else . end) + ' "$MARKETPLACE_JSON" > "$MARKETPLACE_JSON.tmp" + mv "$MARKETPLACE_JSON.tmp" "$MARKETPLACE_JSON" + DATE=$(date -u +%Y-%m-%d) # Strip the heading + install footer from release-notes.md to get just @@ -386,25 +404,25 @@ jobs: } > CHANGELOG.md fi - if git diff --quiet CHANGELOG.md; then - echo "CHANGELOG.md unchanged; skipping commit." + if git diff --quiet CHANGELOG.md plugin.json .github/plugin/marketplace.json; then + echo "No version or changelog drift on main; skipping commit." exit 0 fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add CHANGELOG.md - git commit -m "docs(changelog): add entry for $TAG" + git add CHANGELOG.md plugin.json .github/plugin/marketplace.json + git commit -m "chore(release): bump to $TAG and update changelog" # Push directly to main. If the push fails (someone else moved main), - # fall back to opening a PR so the changelog still lands. + # fall back to opening a PR so the bump + changelog still land. if ! git push origin HEAD:main; then echo "Direct push to main rejected; opening a PR instead." - BRANCH="changelog/${TAG}" + BRANCH="release/${TAG}" git push origin "HEAD:$BRANCH" gh pr create \ --base main \ --head "$BRANCH" \ - --title "docs(changelog): add entry for $TAG" \ - --body "Automated changelog update for [$TAG](https://github.com/${{ github.repository }}/releases/tag/$TAG)." + --title "chore(release): bump to $TAG and update changelog" \ + --body "Automated post-release update for [$TAG](https://github.com/${{ github.repository }}/releases/tag/$TAG): bumps \`plugin.json\` + \`.github/plugin/marketplace.json\` to \`$VERSION\` and appends the changelog entry." fi