Skip to content

Commit 9fb756d

Browse files
committed
ci: split publish workflow into test and publish jobs with branch triggers
The workflow now runs on both push to main and pull requests targeting main, in addition to version tags. The single `publish` job has been split into separate `test` and `publish` jobs, where `publish` depends on `test` and only runs when a version tag is pushed. Action versions have been updated: `actions/checkout` from v6 to v7 and `pnpm/action-setup` from v4 to v6.
1 parent 4a1b2ca commit 9fb756d

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ name: Test and publish package
22

33
on:
44
push:
5+
branches: [main]
56
tags:
67
- "v*"
8+
pull_request:
9+
branches: [main]
710

811
permissions:
912
id-token: write # Required for OIDC
1013
contents: write # for semantic-versioning
1114

1215
jobs:
13-
publish:
16+
test:
1417
runs-on: ubuntu-latest
15-
1618
steps:
1719
- name: Checkout
18-
uses: actions/checkout@v6
20+
uses: actions/checkout@v7
1921
with:
2022
fetch-depth: 0
2123

2224
- name: Setup pnpm
23-
uses: pnpm/action-setup@v4
25+
uses: pnpm/action-setup@v6
2426

2527
- name: Setup Node.js
2628
uses: actions/setup-node@v6
@@ -44,6 +46,30 @@ jobs:
4446
- name: Run tests
4547
run: pnpm test
4648

49+
publish:
50+
runs-on: ubuntu-latest
51+
needs: test
52+
if: startsWith(github.ref, 'refs/tags/v')
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v7
57+
with:
58+
fetch-depth: 0
59+
60+
- name: Setup pnpm
61+
uses: pnpm/action-setup@v6
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v6
65+
with:
66+
node-version: lts/*
67+
registry-url: https://registry.npmjs.org
68+
cache: pnpm
69+
70+
- name: Install dependencies
71+
run: pnpm install
72+
4773
- name: Build module
4874
run: pnpm -w prepack
4975

0 commit comments

Comments
 (0)