Skip to content

Commit 85e9ab2

Browse files
authored
Combine release workflows into one file (#448)
1 parent 62cf583 commit 85e9ab2

File tree

3 files changed

+114
-130
lines changed

3 files changed

+114
-130
lines changed

.github/workflows/release.yml

Lines changed: 114 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
name: Release
2+
23
on:
34
push:
4-
branches:
5-
- main
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
id-token: write # Required for OIDC
12+
contents: read
13+
checks: write
14+
statuses: write
15+
616
jobs:
7-
release:
17+
release-main:
18+
if: ${{ github.ref_name == 'main' }}
19+
name: Main
820
runs-on: ubuntu-latest
921
steps:
1022
- name: Checkout repository
@@ -15,9 +27,9 @@ jobs:
1527
persist-credentials: false
1628

1729
- name: Set up Node.js
18-
uses: actions/setup-node@v4
30+
uses: actions/setup-node@v6
1931
with:
20-
node-version: 20
32+
node-version: 24
2133

2234
- name: Install dependencies
2335
run: npm ci
@@ -29,6 +41,101 @@ jobs:
2941
title: Release Tracking
3042
# This expects you to have a script called release which does a build for your packages and calls changeset publish
3143
publish: npm run release
44+
45+
release-canary:
46+
name: Canary
47+
if: ${{ github.repository == 'primer/eslint-plugin-primer-react' && github.ref_name != 'main' && github.ref_name != 'changeset-release/main' }}
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v5
52+
with:
53+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
54+
fetch-depth: 0
55+
56+
- name: Set up Node.js
57+
uses: actions/setup-node@v6
58+
with:
59+
node-version: 24
60+
61+
- name: Install dependencies
62+
run: npm ci
63+
64+
- name: Build
65+
run: npm run build --if-present
66+
67+
- name: Publish canary version
68+
run: |
69+
echo "$( jq '.version = "0.0.0"' package.json )" > package.json
70+
echo -e "---\n'eslint-plugin-primer-react': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
71+
npx changeset version --snapshot
72+
npx changeset publish --tag canary
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Output canary version number
77+
uses: actions/github-script@v7.0.1
78+
with:
79+
script: |
80+
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
81+
github.rest.repos.createCommitStatus({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
sha: context.sha,
85+
state: 'success',
86+
context: `Published ${package.name}`,
87+
description: package.version,
88+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
89+
})
90+
91+
- name: Upload versions json file
92+
uses: primer/.github/.github/actions/upload-versions@main
93+
94+
release-candidate:
95+
name: Candidate
96+
if: ${{ github.repository == 'primer/eslint-plugin-primer-react' && github.ref_name == 'changeset-release/main' }}
97+
98+
runs-on: ubuntu-latest
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v5
102+
with:
103+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
104+
fetch-depth: 0
105+
106+
- name: Set up Node.js
107+
uses: actions/setup-node@v6
108+
with:
109+
node-version: 24
110+
111+
- name: Install dependencies
112+
run: npm ci
113+
114+
- name: Build
115+
run: npm run build --if-present
116+
117+
- name: Publish release candidate
118+
run: |
119+
version=$(jq -r .version package.json)
120+
echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" package.json )" > package.json
121+
yarn publish --tag next
32122
env:
33-
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
34-
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
125+
- name: Output release candidate version number
126+
uses: actions/github-script@v7.0.1
127+
with:
128+
script: |
129+
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
130+
github.rest.repos.createCommitStatus({
131+
owner: context.repo.owner,
132+
repo: context.repo.repo,
133+
sha: context.sha,
134+
state: 'success',
135+
context: `Published ${package.name}`,
136+
description: package.version,
137+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
138+
})
139+
140+
- name: Upload versions json file
141+
uses: primer/.github/.github/actions/upload-versions@main

.github/workflows/release_canary.yml

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

.github/workflows/release_candidate.yml

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

0 commit comments

Comments
 (0)