Skip to content

Commit 0c89d70

Browse files
committed
Publishing workflow updates
1 parent 24d4890 commit 0c89d70

File tree

6 files changed

+111
-52
lines changed

6 files changed

+111
-52
lines changed

.github/actions/setup-deps/action.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Setup Dependencies"
2+
runs:
3+
using: "composite"
4+
steps:
5+
- run: corepack enable pnpm
6+
shell: bash
7+
8+
- name: Setup Node.js LTS
9+
uses: actions/setup-node@v4
10+
with:
11+
node-version: lts/*
12+
registry-url: "https://registry.npmjs.org"
13+
cache: pnpm
14+
15+
- name: Install Dependencies
16+
run: pnpm install
17+
shell: bash

.github/workflows/main.yml

+3-30
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@main
1515

16-
- name: Set Node.js 22.x
17-
uses: actions/setup-node@main
18-
with:
19-
node-version: 22.x
20-
21-
- name: Install pnpm
22-
run: corepack enable pnpm
23-
24-
- name: Install Dependencies
25-
run: pnpm i
16+
- uses: ./.github/actions/setup-deps
2617

2718
- name: Check Types
2819
run: pnpm run types
@@ -32,16 +23,7 @@ jobs:
3223
steps:
3324
- uses: actions/checkout@main
3425

35-
- name: Set Node.js 22.x
36-
uses: actions/setup-node@main
37-
with:
38-
node-version: 22.x
39-
40-
- name: Install pnpm
41-
run: corepack enable pnpm
42-
43-
- name: Install Dependencies
44-
run: pnpm i
26+
- uses: ./.github/actions/setup-deps
4527

4628
- name: Linting
4729
run: pnpm run lint
@@ -51,16 +33,7 @@ jobs:
5133
steps:
5234
- uses: actions/checkout@main
5335

54-
- name: Set Node.js 22.x
55-
uses: actions/setup-node@main
56-
with:
57-
node-version: 22.x
58-
59-
- name: Install pnpm
60-
run: corepack enable pnpm
61-
62-
- name: Install Dependencies
63-
run: pnpm i
36+
- uses: ./.github/actions/setup-deps
6437

6538
- name: Tests
6639
run: pnpm run test

.github/workflows/publish.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
id-token: write
9+
10+
jobs:
11+
publish:
12+
name: Publish
13+
runs-on: ubuntu-latest
14+
environment: release
15+
steps:
16+
- uses: actions/checkout@main
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: true # needed for git push
20+
21+
- uses: ./.github/actions/setup-deps
22+
23+
- run: pnpm build
24+
25+
- name: git config
26+
run: |
27+
git config --global user.name 'Thinkmill Release Bot'
28+
git config --global user.email '[email protected]'
29+
30+
- name: npm publish, git tag
31+
run: pnpm changeset publish
32+
env:
33+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
NPM_CONFIG_PROVENANCE: true
35+
36+
- run: git push origin --follow-tags
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish (Snapshot)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
id-token: write
9+
10+
jobs:
11+
publish_snapshot:
12+
name: Publish (Snapshot)
13+
runs-on: ubuntu-latest
14+
environment: release
15+
steps:
16+
- uses: actions/checkout@main
17+
with:
18+
persist-credentials: true # needed for git push
19+
20+
- uses: ./.github/actions/setup-deps
21+
22+
- name: version packages
23+
run: pnpm changeset version --snapshot ${{ inputs.tag }}
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: git commit
28+
run: |
29+
git config --global user.name 'Thinkmill Release Bot'
30+
git config --global user.email '[email protected]'
31+
git commit -a -m 'snapshot release'
32+
33+
- run: pnpm build
34+
35+
- name: npm publish, git tag
36+
run: pnpm changeset publish --tag test
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
NPM_CONFIG_PROVENANCE: true
40+
41+
# reset, then push the dangling commit
42+
- name: git push
43+
run: |
44+
git reset HEAD~1 --hard
45+
git push origin --tags

.github/workflows/release.yml

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
name: Release
1+
name: Version Packages
22

33
on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
78

89
jobs:
9-
release:
10-
name: Release
10+
versioning:
11+
name: Pull Request
1112
runs-on: ubuntu-latest
1213
steps:
13-
- name: Checkout Repo
14-
uses: actions/checkout@main
14+
- uses: actions/checkout@main
1515
with:
1616
fetch-depth: 0
17+
persist-credentials: false
1718

18-
- name: Set Node.js 22.x
19-
uses: actions/setup-node@main
20-
with:
21-
node-version: 22.x
22-
23-
- name: Install pnpm
24-
run: corepack enable pnpm
25-
26-
- name: Install Dependencies
27-
run: pnpm i
19+
- uses: ./.github/actions/setup-deps
2820

29-
- name: "Create Pull Request or Publish to npm"
30-
uses: changesets/action@master
21+
- uses: changesets/action@v1
3122
with:
32-
publish: pnpm run release
33-
version: pnpm run version
23+
version: pnpm run version-packages
3424
env:
3525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
},
2727
"scripts": {
2828
"postinstall": "preconstruct dev && manypkg check",
29-
"release": "preconstruct build && changeset publish",
30-
"version": "changeset version && pnpm i --frozen-lockfile=false",
29+
"version-packages": "changeset version && pnpm i --frozen-lockfile=false",
3130
"test": "jest",
3231
"types": "tsc",
3332
"lint": "eslint .",

0 commit comments

Comments
 (0)