Skip to content

Commit ac7b2fc

Browse files
feat: Automate version extraction and update for releases (#19)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent ba391fb commit ac7b2fc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/publish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19+
- name: Extract version from tag
20+
id: get_version
21+
run: |
22+
if [ "${{ github.event_name }}" = "release" ]; then
23+
# Extract version from release tag (strips 'v' prefix if present)
24+
VERSION="${{ github.event.release.tag_name }}"
25+
VERSION="${VERSION#v}"
26+
echo "version=$VERSION" >> $GITHUB_OUTPUT
27+
echo "Publishing version: $VERSION"
28+
else
29+
# Manual dispatch - use existing package.json version
30+
VERSION=$(node -p "require('./package.json').version")
31+
echo "version=$VERSION" >> $GITHUB_OUTPUT
32+
echo "Manual dispatch - using package.json version: $VERSION"
33+
fi
34+
35+
- name: Update package.json version
36+
if: github.event_name == 'release'
37+
run: |
38+
npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
39+
echo "Updated package.json to version ${{ steps.get_version.outputs.version }}"
40+
1941
- name: Setup Node.js
2042
uses: actions/setup-node@v4
2143
with:

0 commit comments

Comments
 (0)