Skip to content

Commit 0402b5f

Browse files
authored
chore: new release workflow
1 parent 205ce17 commit 0402b5f

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)