Skip to content

Commit 1c42705

Browse files
committed
chore(workflows/publish): use tracked publishing
1 parent 3797467 commit 1c42705

File tree

3 files changed

+79
-55
lines changed

3 files changed

+79
-55
lines changed

.github/workflows/auto-alpha-publish.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/create-release-pr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- uses: actions/checkout@v6
5959
with:
6060
fetch-depth: 0
61+
- uses: pnpm/action-setup@v4
62+
with:
63+
version: 10
6164

6265
- name: Use version bump from check step
6366
id: version_bump

.github/workflows/publish.yml

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,90 @@
11
name: publish
2-
env:
3-
CI: true
42
on:
5-
workflow_dispatch:
63
push:
74
branches:
85
- master
9-
paths:
10-
- "package.json"
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
CI: true
13+
14+
permissions:
15+
contents: read
16+
id-token: write
17+
packages: write
1118

1219
jobs:
13-
build:
20+
check:
1421
runs-on: ubuntu-latest
15-
permissions:
16-
contents: read
17-
packages: write
22+
timeout-minutes: 5
23+
outputs:
24+
can_publish: ${{ steps.can-publish.outputs.can_publish }}
1825
steps:
19-
- uses: actions/checkout@v6
26+
- uses: actions/checkout@v4
2027
- name: Setup node
21-
uses: actions/setup-node@v6
28+
uses: actions/setup-node@v4
2229
with:
23-
node-version-file: package.json
30+
node-version: 24
2431
registry-url: "https://registry.npmjs.org"
2532
- uses: ./.github/actions/pnpm-install
2633
- run: pnpm run build
27-
- run: |
28-
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
29-
npx can-npm-publish --verbose && npm publish || echo "Does not publish"
30-
env:
31-
NODE_AUTH_TOKEN: ${{ secrets.NPM_NODE_AUTH_TOKEN }}
34+
- name: Check if can publish
35+
id: can-publish
36+
run: |
37+
npx can-npm-publish --verbose && echo "can_publish=true" >> $GITHUB_OUTPUT || echo "can_publish=false" >> $GITHUB_OUTPUT
38+
continue-on-error: true
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: dist
42+
path: dist
43+
retention-days: 1
44+
45+
publish-release:
46+
needs: check
47+
if: needs.check.outputs.can_publish == 'true'
48+
runs-on: ubuntu-latest
49+
timeout-minutes: 5
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Setup node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: 24
56+
registry-url: "https://registry.npmjs.org"
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: dist
60+
path: dist
61+
- name: Publish
62+
run: |
63+
npm publish
64+
65+
publish-alpha:
66+
needs: check
67+
if: needs.check.outputs.can_publish != 'true'
68+
runs-on: ubuntu-latest
69+
timeout-minutes: 5
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
- name: Setup node
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: 24
78+
registry-url: "https://registry.npmjs.org"
79+
- uses: actions/download-artifact@v4
80+
with:
81+
name: dist
82+
path: dist
83+
- name: Update version
84+
run: |
85+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
86+
git config --global user.name "github-actions[bot]"
87+
npm version prepatch --preid alpha-$(($(date +%s%N)/1000000))-$(git rev-parse --short HEAD)
88+
- name: Publish
89+
run: |
90+
npm publish --tag alpha

0 commit comments

Comments
 (0)