Skip to content

Commit 55b3209

Browse files
committed
ci: streamline version and publish workflows
- Restrict version workflow to main branch only - Add ci-release label to version PRs for publish triggering - Change publish trigger to PR merge with ci-release label - Remove redundant test jobs (main already passes CI) - Replace softprops/action-gh-release with gh CLI
1 parent 412bad7 commit 55b3209

2 files changed

Lines changed: 13 additions & 83 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,17 @@
11
name: Publish to npm
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- "package.json"
94
workflow_dispatch:
5+
pull_request:
6+
types: [closed]
7+
branches: [main]
108

119
jobs:
12-
test:
13-
runs-on: ubuntu-latest
14-
environment: test
15-
16-
strategy:
17-
matrix:
18-
node-version: [20, 22]
19-
20-
steps:
21-
- uses: actions/checkout@v4
22-
23-
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
cache: "npm"
28-
29-
- name: Install dependencies
30-
run: npm ci
31-
32-
- name: Build
33-
run: npm run build
34-
35-
- name: Lint
36-
run: npm run lint
37-
38-
- name: Type check
39-
run: npm run typecheck
40-
41-
- name: Test
42-
run: npm run test:coverage
43-
4410
publish-dry-run:
45-
needs: test
11+
if: >
12+
github.event_name == 'workflow_dispatch' ||
13+
(github.event.pull_request.merged == true &&
14+
contains(github.event.pull_request.labels.*.name, 'ci-release'))
4615
runs-on: ubuntu-latest
4716
environment: general
4817

@@ -93,9 +62,9 @@ jobs:
9362
echo "- **Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
9463
echo "- **Already published:** ${{ steps.check.outputs.exists }}" >> $GITHUB_STEP_SUMMARY
9564
if [ "${{ steps.check.outputs.exists }}" == "false" ]; then
96-
echo "- **Dry run:** Success" >> $GITHUB_STEP_SUMMARY
65+
echo "- **Dry run:** Success" >> $GITHUB_STEP_SUMMARY
9766
else
98-
echo "- **Dry run:** ⏭️ Skipped (version exists)" >> $GITHUB_STEP_SUMMARY
67+
echo "- **Dry run:** Skipped (version exists)" >> $GITHUB_STEP_SUMMARY
9968
fi
10069
10170
outputs:
@@ -130,13 +99,9 @@ jobs:
13099
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
131100

132101
- name: Create GitHub Release
133-
uses: softprops/action-gh-release@v2
134-
with:
135-
tag_name: v${{ needs.publish-dry-run.outputs.version }}
136-
name: v${{ needs.publish-dry-run.outputs.version }}
137-
generate_release_notes: true
102+
run: gh release create "v${{ needs.publish-dry-run.outputs.version }}" --generate-notes
138103
env:
139-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140105

141106
- name: Summary
142107
run: |

.github/workflows/version.yml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,8 @@ on:
1313
- major
1414

1515
jobs:
16-
test:
17-
runs-on: ubuntu-latest
18-
environment: test
19-
20-
strategy:
21-
matrix:
22-
node-version: [20, 22]
23-
24-
steps:
25-
- uses: actions/checkout@v4
26-
27-
- name: Use Node.js ${{ matrix.node-version }}
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: ${{ matrix.node-version }}
31-
cache: "npm"
32-
33-
- name: Install dependencies
34-
run: npm ci
35-
36-
- name: Build
37-
run: npm run build
38-
39-
- name: Lint
40-
run: npm run lint
41-
42-
- name: Type check
43-
run: npm run typecheck
44-
45-
- name: Test
46-
run: npm run test:coverage
47-
4816
version:
49-
needs: test
17+
if: github.ref == 'refs/heads/main'
5018
runs-on: ubuntu-latest
5119
environment: test
5220
permissions:
@@ -87,14 +55,11 @@ jobs:
8755
8856
This PR bumps the version to `${{ steps.bump.outputs.version }}` (${{ inputs.version_type }} release).
8957
90-
### Checklist
91-
- [ ] Version bump looks correct
92-
- [ ] Ready to publish to npm
93-
9458
---
9559
*This PR was automatically created by the version workflow.*
9660
branch: release/v${{ steps.bump.outputs.version }}
9761
base: main
9862
labels: |
9963
release
10064
automated
65+
ci-release

0 commit comments

Comments
 (0)