Skip to content

Commit a52a897

Browse files
chore: update publish_release workflow to bump package.json version too
1 parent 1d585d4 commit a52a897

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

.github/workflows/publish_release.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,24 @@ jobs:
3131
echo "Found draft version: ${{ steps.draft.outputs.tag_name }}"
3232
3333
34-
- name: Create branch and commit VERSION
34+
- name: Create branch and commit VERSION and package.json
3535
run: |
3636
branch="update-version-${{ steps.draft.outputs.tag_name }}"
3737
# Delete remote branch if exists
3838
git push origin --delete "$branch" || echo "No remote branch to delete"
3939
git fetch origin main
4040
git checkout -b "$branch" origin/main
41-
# Write VERSION file and timestamp to ensure a diff
41+
# Version without 'v' prefix (e.g. v1.2.3 -> 1.2.3)
4242
version="${{ steps.draft.outputs.tag_name }}"
43-
echo "$version" | sed 's/^v//' > VERSION
44-
git add VERSION
43+
version_plain=$(echo "$version" | sed 's/^v//')
44+
# Write VERSION file
45+
echo "$version_plain" > VERSION
46+
# Update package.json version
47+
jq --arg v "$version_plain" '.version = $v' package.json > package.json.tmp && mv package.json.tmp package.json
48+
git add VERSION package.json
4549
git config user.name "github-actions[bot]"
4650
git config user.email "github-actions[bot]@users.noreply.github.com"
47-
git commit -m "chore: add VERSION $version" --allow-empty
51+
git commit -m "chore: bump version to $version_plain (VERSION + package.json)" --allow-empty
4852
4953
- name: Push changes
5054
run: |
@@ -57,8 +61,8 @@ jobs:
5761
pr_url=$(gh pr create \
5862
--base main \
5963
--head update-version-${{ steps.draft.outputs.tag_name }} \
60-
--title "chore: add VERSION ${{ steps.draft.outputs.tag_name }}" \
61-
--body "Adds VERSION file for release ${{ steps.draft.outputs.tag_name }}" \
64+
--title "chore: bump version to ${{ steps.draft.outputs.tag_name }} (VERSION + package.json)" \
65+
--body "Updates VERSION file and package.json version for release ${{ steps.draft.outputs.tag_name }}" \
6266
--label automated)
6367
6468
pr_number=$(echo "$pr_url" | awk -F/ '{print $NF}')

0 commit comments

Comments
 (0)