Skip to content

Commit 1b4c1aa

Browse files
committed
Update publish workflow
1 parent 8f88a7e commit 1b4c1aa

3 files changed

Lines changed: 66 additions & 13 deletions

File tree

.github/workflows/publish.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: Publish
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "The npm tag to publish to"
8+
required: true
9+
type: choice
10+
options:
11+
- latest
12+
- test
713

8-
concurrency: ${{ github.workflow }}-${{ github.ref }}
14+
concurrency: publish
915

1016
permissions: {} # each job should define its own permission explicitly
1117

@@ -15,10 +21,9 @@ jobs:
1521
if: github.repository == 'Thinkmill/manypkg'
1622
runs-on: ubuntu-latest
1723
timeout-minutes: 20
24+
environment: Release
1825
permissions:
19-
contents: write # to create release (changesets/action)
20-
issues: write # to post issue comments (changesets/action)
21-
pull-requests: write # to create pull request (changesets/action)
26+
contents: write # to push tags
2227
id-token: write # to use OpenID Connect token for trusted publishing (changesets/action)
2328
steps:
2429
- uses: actions/checkout@v4
@@ -28,9 +33,28 @@ jobs:
2833
with:
2934
node-version: 24
3035

31-
- run: git branch -a
36+
- run: yarn build
3237

33-
- name: "Create Pull Request or Publish to npm"
34-
uses: changesets/action@v1
35-
with:
36-
publish: yarn release
38+
- name: git config
39+
run: |
40+
git config --global user.name 'GitHub Actions'
41+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
42+
43+
- name: version packages
44+
if: inputs.tag != 'latest'
45+
run: |
46+
yarn changeset version --snapshot ${{ inputs.tag }}
47+
git commit -a -m 'test'
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: npm publish, git tag
52+
run: yarn changeset publish --tag ${{ inputs.tag }}
53+
54+
# reset, then we have a tagged dangling commit
55+
- name: git push
56+
if: inputs.tag != 'latest'
57+
run: |
58+
git reset HEAD~1 --hard
59+
60+
- run: git push origin --tags

.github/workflows/release-pr.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Create Release PR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
create-release-pr:
12+
name: Create Release PR
13+
if: github.repository == 'Thinkmill/manypkg'
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 20
16+
permissions:
17+
contents: write # to push for release PR (changesets/action)
18+
issues: write # to post issue comments (changesets/action)
19+
pull-requests: write # to create pull request (changesets/action)
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- uses: ./.github/actions/ci-setup
25+
with:
26+
node-version: 24
27+
28+
- name: "Create Pull Request"
29+
uses: changesets/action@v1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"packages/*"
88
],
99
"scripts": {
10+
"build": "preconstruct build",
1011
"format": "prettier --write .",
1112
"format:check": "prettier --check .",
1213
"postinstall": "preconstruct dev && NODE_OPTIONS=--experimental-strip-types packages/cli/bin.js check",
1314
"knip": "knip",
14-
"release": "preconstruct build && changeset publish",
1515
"test": "vitest"
1616
},
1717
"devDependencies": {

0 commit comments

Comments
 (0)