Skip to content

Commit 11b4480

Browse files
Add automatic version update to release workflow (#2)
* Initial plan * Implement automatic version update in release workflow Co-authored-by: jehernandezr <47890623+jehernandezr@users.noreply.github.com> * Final verification - workflow implementation complete Co-authored-by: jehernandezr <47890623+jehernandezr@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jehernandezr <47890623+jehernandezr@users.noreply.github.com>
1 parent 8e9b258 commit 11b4480

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

.github/workflows/release-package.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ jobs:
6565
runs-on: ubuntu-latest
6666
permissions:
6767
packages: write
68-
contents: read
68+
contents: write
6969
env:
7070
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
7171
steps:
7272
- uses: actions/checkout@v4
73+
with:
74+
token: ${{ secrets.GITHUB_TOKEN }}
7375
- uses: actions/setup-node@v4
7476
with:
7577
node-version: 20
@@ -87,5 +89,26 @@ jobs:
8789
- name: Install dependencies (if cache miss)
8890
if: steps.cache-node.outputs.cache-hit != 'true'
8991
run: npm install
92+
93+
- name: Extract version from release tag
94+
if: github.event_name == 'release'
95+
id: extract-version
96+
run: |
97+
TAG_NAME="${{ github.event.release.tag_name }}"
98+
# Remove 'v' prefix if present (e.g., v1.2.3 -> 1.2.3)
99+
VERSION=${TAG_NAME#v}
100+
echo "version=$VERSION" >> $GITHUB_OUTPUT
101+
102+
- name: Update package.json version
103+
if: github.event_name == 'release'
104+
run: |
105+
npm version --no-git-tag-version ${{ steps.extract-version.outputs.version }}
106+
107+
- name: Commit version update
108+
if: github.event_name == 'release'
109+
uses: stefanzweifel/git-auto-commit-action@v5
110+
with:
111+
commit_message: 'chore: update version to ${{ steps.extract-version.outputs.version }}'
112+
file_pattern: 'package.json package-lock.json'
90113

91114
- run: npm publish --access public

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)