Skip to content

Commit 6b89bd7

Browse files
BrainSlugs83Copilot
andcommitted
fix: publish workflow — dispatch trigger, version-aligned tags
Switched from release:published to workflow_dispatch so the version bump is committed and tagged before npm publish. Tag and package.json now always match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a2d3434 commit 6b89bd7

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

.github/workflows/publish.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
name: Publish to npm
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (e.g. 1.6.0)'
8+
required: true
9+
type: string
610

711
jobs:
812
publish:
@@ -21,12 +25,26 @@ jobs:
2125
- run: npm install -g npm@latest
2226
- run: npm ci
2327

24-
# Set package version from release tag (e.g. v1.6.0 → 1.6.0)
25-
- name: Set version from tag
26-
run: |
27-
VERSION="${GITHUB_REF_NAME#v}"
28-
npm version "$VERSION" --no-git-tag-version --allow-same-version
28+
# Bump package.json to the requested version
29+
- name: Set version
30+
run: npm version "${{ inputs.version }}" --no-git-tag-version --allow-same-version
2931

3032
- run: npm run check
3133

34+
# Commit version bump, tag, and push
35+
- name: Commit and tag
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+
git add package.json package-lock.json
40+
git commit -m "v${{ inputs.version }}"
41+
git tag "v${{ inputs.version }}"
42+
git push origin main --tags
43+
44+
# Create GitHub Release from the new tag
45+
- name: Create GitHub Release
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
run: gh release create "v${{ inputs.version }}" --generate-notes
49+
3250
- run: npm publish --provenance --access public

0 commit comments

Comments
 (0)