Skip to content

Commit 64f7fb7

Browse files
committed
fix publish
1 parent 5146f67 commit 64f7fb7

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
name: Publish to npm
1+
name: Build and Publish
22

33
on:
44
push:
55
branches:
66
- main
77

88
jobs:
9-
publish:
10-
# Prevent infinite loop from version bump commits
11-
if: !startsWith(github.event.head_commit.message, 'chore: release')
9+
build-and-publish:
1210
runs-on: ubuntu-latest
1311
permissions:
14-
contents: write # Needed to push the new version commit and tag
15-
12+
contents: write
13+
1614
steps:
15+
- name: Check for release commit
16+
run: |
17+
if [[ "${{ github.event.head_commit.message }}" == *"chore: release"* ]]; then
18+
echo "Release commit detected. Skipping publish to prevent infinite loop."
19+
exit 0
20+
fi
21+
echo "Proceeding with build and publish..."
22+
1723
- name: Checkout repository
1824
uses: actions/checkout@v4
19-
# Fetch all history to enable correct version bumping
2025
with:
2126
fetch-depth: 0
27+
token: ${{ secrets.GITHUB_TOKEN }}
2228

2329
- name: Set up Node.js
2430
uses: actions/setup-node@v4
@@ -34,18 +40,23 @@ jobs:
3440
- name: Install dependencies
3541
run: npm ci
3642

43+
- name: Build project
44+
run: npm run build
45+
46+
- name: Run tests
47+
run: npm test
48+
3749
- name: Configure Git
3850
run: |
3951
git config --global user.name 'github-actions[bot]'
4052
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4153
42-
- name: Bump version and publish
54+
- name: Bump version and create tag
4355
run: |
44-
# Create a new version, commit, and tag
45-
npm version patch -m "chore: release %s"
46-
# Push the changes back to the repository
56+
npm version patch -m "chore: release v%s"
4757
git push --follow-tags
48-
# Publish to npm
49-
npm publish
58+
59+
- name: Publish to npm
60+
run: npm publish
5061
env:
5162
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)