Skip to content

Commit a402daa

Browse files
tobenotcursoragent
andauthored
Update publish workflow to conditionally bump version and improve build process (#5)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent fc3f155 commit a402daa

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

.github/workflows/publish-contract.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Publish API Contract to GitHub Packages
33

44
on:
55
push:
6-
branches:
7-
- main
8-
paths-ignore:
6+
paths:
7+
- 'src/**/*.ts'
8+
- 'dist/**/*.d.ts'
99
- 'package.json'
1010

1111
jobs:
@@ -25,15 +25,29 @@ jobs:
2525
registry-url: 'https://npm.pkg.github.com'
2626
scope: '@tobenot'
2727

28-
- name: Install dependencies and build
28+
- name: Install dependencies
29+
run: npm ci
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Bump version if needed
2934
run: |
30-
rm -rf package-lock.json node_modules
31-
npm install
32-
npm run build
35+
latest=$(npm view @tobenot/basic-web-game-backend-contract version --registry=https://npm.pkg.github.com || echo "0.0.0")
36+
current=$(node -p "require('./package.json').version")
37+
if [ "$current" = "$latest" ]; then
38+
next=$(npx semver $latest -i patch)
39+
jq ".version = \"$next\"" package.json > package.json.tmp && mv package.json.tmp package.json
40+
echo "Bumped version to $next"
41+
else
42+
echo "No need to bump version"
43+
fi
44+
45+
- name: Build
46+
run: npm run build
3347
env:
3448
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3549

3650
- name: Publish package
37-
run: npm publish
51+
run: npm publish --registry=https://npm.pkg.github.com
3852
env:
3953
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)