@@ -2,9 +2,17 @@ name: Release
22
33on :
44 push :
5- branches :
6- - main
7- - next-major
5+ workflow_dispatch :
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.ref }}
9+ cancel-in-progress : true
10+
11+ permissions :
12+ id-token : write # Required for OIDC
13+ contents : read
14+ checks : write
15+ statuses : write
816
917jobs :
1018 release-main :
@@ -46,19 +54,104 @@ jobs:
4654 publish : npm run release
4755 env :
4856 GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
49- NPM_TOKEN : ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
5057 - uses : ./.github/actions/upload-versions
5158
52- release-next-major :
53- if : github.ref_name == 'next-major'
54- name : Next major
55- uses : primer/.github/.github/workflows/release_with_app.yml@v2.0.0
56- with :
57- title : Release tracking (next major)
58- secrets :
59- npm_token : ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
60- app-id : ${{ vars.PRIMER_APP_ID_SHARED }}
61- private-key : ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
62- client-id : ${{ vars.PRIMER_APP_CLIENT_ID_SHARED }}
63- client-secret : ${{ secrets.PRIMER_APP_CLIENT_SECRET_SHARED }}
64- installation-id : ${{ vars.PRIMER_APP_INSTALLATION_ID_SHARED }}
59+ release-candidate :
60+ if : github.ref_name == 'changeset-release/main'
61+ name : Candidate (@next)
62+ runs-on : ubuntu-latest
63+ steps :
64+ - name : Checkout repository
65+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
66+ with :
67+ # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
68+ fetch-depth : 0
69+
70+ - name : Set up Node
71+ uses : actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
72+ with :
73+ node-version-file : ' .nvmrc'
74+ cache : ' npm'
75+
76+ - name : Install dependencies
77+ run : npm ci
78+
79+ - name : Build
80+ run : npm run build
81+
82+ - name : Publish release candidate
83+ run : |
84+ if [[ -f '.changeset/pre.json' ]]; then
85+ npx changeset pre exit
86+ npx changeset version --snapshot
87+ else
88+ pkg_json_path=packages/react/package.json
89+ version=$(jq -r .version $pkg_json_path)
90+ echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" $pkg_json_path )" > $pkg_json_path
91+ fi
92+
93+ npx changeset publish --tag next
94+ env :
95+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96+
97+ - name : Output candidate version
98+ uses : actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293
99+ with :
100+ script : |
101+ const package = require(`${process.env.GITHUB_WORKSPACE}/packages/react/package.json`)
102+ github.repos.createCommitStatus({
103+ owner: context.repo.owner,
104+ repo: context.repo.repo,
105+ sha: context.sha,
106+ state: 'success',
107+ context: `Published ${package.name}`,
108+ description: package.version,
109+ target_url: `https://unpkg.com/${package.name}@${package.version}/`
110+ })
111+ - uses : ./.github/actions/upload-versions
112+
113+ release-canary :
114+ name : Canary
115+ if : github.ref_name != 'main' && github.ref_name != 'changeset-release/main'
116+ runs-on : ubuntu-latest
117+ steps :
118+ - name : Checkout repository
119+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
120+ with :
121+ # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
122+ fetch-depth : 0
123+ - name : Set up Node
124+ uses : actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
125+ with :
126+ node-version-file : ' .nvmrc'
127+ cache : ' npm'
128+ - name : Install dependencies
129+ run : npm ci
130+ - name : Build
131+ run : npm run build --if-present
132+ - name : Publish canary release
133+ run : |
134+ if [[ -f '.changeset/pre.json' ]]; then
135+ npx changeset pre exit
136+ fi
137+
138+ echo -e "---\n$( jq .name packages/react/package.json ): patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
139+ npx changeset version --snapshot
140+ npx changeset publish --tag canary
141+ env :
142+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
143+ - name : Output canary version
144+ uses : actions/github-script@a3e7071a34d7e1f219a8a4de9a5e0a34d1ee1293
145+ with :
146+ script : |
147+ const package = require(`${process.env.GITHUB_WORKSPACE}/packages/react/package.json`)
148+ github.repos.createCommitStatus({
149+ owner: context.repo.owner,
150+ repo: context.repo.repo,
151+ sha: context.sha,
152+ state: 'success',
153+ context: `Published ${package.name}`,
154+ description: package.version,
155+ target_url: `https://unpkg.com/${package.name}@${package.version}/`
156+ })
157+ - uses : ./.github/actions/upload-versions
0 commit comments