Skip to content

Commit d996673

Browse files
authored
chore: new release workflow (#1434)
* chore: new release workflow * add id-token for npm trusted publishing
1 parent 205ce17 commit d996673

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/release.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
# Match SemVer major release branches
6+
# e.g. "12.x" or "8.x"
7+
- '[0-9]+.x'
8+
- 'main'
9+
- 'next'
10+
- 'next-major'
11+
- 'beta'
12+
- 'alpha'
13+
- '!all-contributors/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
id-token: write # to enable use of OIDC (npm trusted publishing and provenance)
21+
actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action)
22+
contents: read # to fetch code (actions/checkout)
23+
issues: write # to be able to comment on released issues
24+
pull-requests: write # to be able to comment on released pull requests
25+
26+
jobs:
27+
validate:
28+
continue-on-error: ${{ matrix.react != 'latest' }}
29+
# ignore all-contributors PRs
30+
if: ${{ !contains(github.head_ref, 'all-contributors') }}
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
node: [18, 20]
35+
react: ['18.x', latest, canary, experimental]
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: ⬇️ Checkout repo
39+
uses: actions/checkout@v4
40+
41+
- name: ⎔ Setup node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: ${{ matrix.node }}
45+
46+
- name: 📥 Download deps
47+
uses: bahmutov/npm-install@v1
48+
with:
49+
useLockFile: false
50+
51+
# TODO: Can be removed if https://github.com/kentcdodds/kcd-scripts/pull/146 is released
52+
- name: Verify format (`npm run format` committed?)
53+
run: npm run format -- --check --no-write
54+
55+
# as requested by the React team :)
56+
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
57+
- name: ⚛️ Setup react
58+
run: npm install react@${{ matrix.react }} react-dom@${{ matrix.react }}
59+
60+
- name: ⚛️ Setup react types
61+
if: ${{ matrix.react != 'canary' && matrix.react != 'experimental' }}
62+
run:
63+
npm install @types/react@${{ matrix.react }} @types/react-dom@${{
64+
matrix.react }}
65+
66+
- name: ▶️ Run validate script
67+
run: npm run validate
68+
69+
- name: ⬆️ Upload coverage report
70+
uses: codecov/codecov-action@v5
71+
with:
72+
fail_ci_if_error: true
73+
flags: ${{ matrix.react }}
74+
token: ${{ secrets.CODECOV_TOKEN }}
75+
76+
release:
77+
permissions:
78+
actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action)
79+
contents: write # to create release tags (cycjimmy/semantic-release-action)
80+
issues: write # to post release that resolves an issue (cycjimmy/semantic-release-action)
81+
82+
needs: validate
83+
runs-on: ubuntu-latest
84+
if:
85+
${{ github.repository == 'testing-library/react-testing-library' &&
86+
github.event_name == 'push' }}
87+
steps:
88+
- name: ⬇️ Checkout repo
89+
uses: actions/checkout@v4
90+
91+
- name: ⎔ Setup node
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version: 14
95+
96+
- name: 📥 Download deps
97+
uses: bahmutov/npm-install@v1
98+
with:
99+
useLockFile: false
100+
101+
- name: 🏗 Run build script
102+
run: npm run build
103+
104+
- name: 🚀 Release
105+
uses: cycjimmy/semantic-release-action@v2
106+
with:
107+
semantic_version: 17
108+
branches: |
109+
[
110+
'+([0-9])?(.{+([0-9]),x}).x',
111+
'main',
112+
'next',
113+
'next-major',
114+
{name: 'beta', prerelease: true},
115+
{name: 'alpha', prerelease: true}
116+
]
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)