Skip to content

Commit cc2e3df

Browse files
committed
chore: separate versioning and publishing jobs
1 parent 994e82b commit cc2e3df

File tree

3 files changed

+62
-14
lines changed

3 files changed

+62
-14
lines changed

.changeset/all-windows-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"sorted-queue": patch
3+
---
4+
5+
Separate versioning and publishing jobs

.github/workflows/version-or-publish.yml

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,17 @@ jobs:
2323
with:
2424
node-version: 22
2525
cache: npm
26-
registry-url: "https://registry.npmjs.org"
2726
- run: npm ci
2827
- run: npm run lint
2928
- run: npm run typecheck
3029
- run: npm test
3130

32-
publish:
31+
changesets:
3332
needs: check
3433
runs-on: ubuntu-latest
3534
permissions:
3635
contents: write
37-
id-token: write
3836
pull-requests: write
39-
issues: read
4037
steps:
4138
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4239
with:
@@ -45,17 +42,65 @@ jobs:
4542
with:
4643
node-version: 22
4744
cache: npm
48-
registry-url: "https://registry.npmjs.org"
49-
# Ensure npm 11.5.1 or later is installed for OIDC authentication.
50-
- name: Update npm
51-
run: npm install -g npm@latest
5245
- name: Install dependencies
5346
run: npm ci
54-
- name: Create Release Pull Request or Publish to npm
47+
- name: Create release pull request or GitHub release
5548
id: changesets
5649
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
5750
with:
58-
version: npm run bump
59-
publish: npm run release
51+
publish: echo 0
6052
env:
6153
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
build:
56+
needs: changesets
57+
if: needs.release.outputs.published == 'true'
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
steps:
62+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63+
with:
64+
persist-credentials: false
65+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
66+
with:
67+
node-version: 22
68+
cache: npm
69+
- name: Install dependencies
70+
run: npm ci
71+
- name: Build package
72+
run: npm run build
73+
- name: Upload build artifact
74+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
75+
with:
76+
name: package-build
77+
path: dist/
78+
79+
publish:
80+
environment: publish
81+
needs:
82+
- changesets
83+
- build
84+
if: needs.release.outputs.published == 'true'
85+
runs-on: ubuntu-latest
86+
permissions:
87+
contents: read
88+
id-token: write
89+
steps:
90+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
91+
with:
92+
persist-credentials: false
93+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
94+
with:
95+
node-version: 22
96+
cache: npm
97+
# Ensure npm 11.5.1 or later is installed for OIDC authentication.
98+
- name: Update npm
99+
run: npm install -g npm@latest
100+
- name: Download build artifact
101+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
102+
with:
103+
name: package-build
104+
path: ./dist
105+
- name: Publish to npm
106+
run: npm publish

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
"build:node-cjs": "tsc -p ./tsconfig.cjs.json --target es2022 --outDir ./dist/node-cjs",
3737
"build:mjs": "tsc -p ./tsconfig.esm.json --outDir ./dist/mjs && mv ./dist/mjs/index.js ./dist/mjs/index.mjs && mv ./dist/mjs/index.d.ts ./dist/mjs/index.d.mts",
3838
"build:node-mjs": "tsc -p ./tsconfig.esm.json --target es2022 --outDir ./dist/node-mjs && mv ./dist/node-mjs/index.js ./dist/node-mjs/index.mjs && mv ./dist/node-mjs/index.d.ts ./dist/node-mjs/index.d.mts",
39-
"changeset": "changeset",
40-
"bump": "changeset version",
41-
"release": "npm run build && changeset publish"
39+
"changeset": "changeset"
4240
},
4341
"devDependencies": {
4442
"@changesets/changelog-github": "^0.5.1",

0 commit comments

Comments
 (0)