Skip to content

Commit 3f35220

Browse files
authored
ci(release): Add post release workflow (#48)
* ci(release): Add initial post-release workflow * ci(release): Test trigger new workflow * ci(release): Upload tests coverage report to Codecov * ci(release): Fix using project as an output from previous job * ci(release): Remove test run branch push * ci(release): Remove hooks flag from Codecov upload * ci(pr): Rename verify PR job * ci(pr): Add report status job for properly setting PR status checks * ci(release): Add permissions to post-release workflow * ci(release): Add CODEOWNERS file
1 parent 0d96651 commit 3f35220

File tree

4 files changed

+88
-23
lines changed

4 files changed

+88
-23
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Code owners for all files
2+
* @minwork

.github/workflows/post-release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Post Release
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
tags:
9+
- "*@*.*.*"
10+
11+
jobs:
12+
extract-project:
13+
name: Extract project name from git tag
14+
runs-on: ubuntu-latest
15+
outputs:
16+
project: ${{ steps.extract-project-name.outputs.project }}
17+
steps:
18+
- name: Extract Project Name
19+
id: extract-project-name
20+
shell: bash
21+
run: |
22+
TAG_NAME=${{ github.ref_name }}
23+
if [[ "$TAG_NAME" =~ ^(.+)@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
24+
PROJECT_NAME=${BASH_REMATCH[1]}
25+
else
26+
PROJECT_NAME=""
27+
fi
28+
echo "project=$PROJECT_NAME" >> "$GITHUB_OUTPUT"
29+
echo "Extracted project '$PROJECT_NAME' from '$TAG_NAME'"
30+
31+
upload-test-coverage:
32+
name: Upload tests coverage for project
33+
runs-on: ubuntu-latest
34+
needs: extract-project
35+
if: ${{ needs.extract-project.outputs.project != '' }}
36+
env:
37+
PROJECT: ${{ needs.extract-project.outputs.project }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-tags: 'true'
43+
fetch-depth: '0'
44+
45+
- name: Enable Corepack
46+
run: corepack enable
47+
48+
- name: Install Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: 20
52+
registry-url: 'https://registry.npmjs.org/'
53+
cache: 'yarn'
54+
cache-dependency-path: 'yarn.lock'
55+
56+
- name: Install dependencies
57+
run: yarn install --immutable
58+
59+
- name: Run tests with coverage
60+
run: npx nx run ${{ env.PROJECT }}:test --coverage
61+
62+
- name: Upload ${{ env.PROJECT }} coverage reports to Codecov
63+
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
64+
with:
65+
token: ${{ secrets.CODECOV_TOKEN }}
66+
directory: ./coverage/packages/${{ env.PROJECT }}
67+
flags: ${{ env.PROJECT }}

.github/workflows/verify.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
branches: ['main']
1313

1414
jobs:
15-
build:
15+
verify-pr:
1616
runs-on: ubuntu-latest
1717

1818
strategy:
@@ -62,24 +62,20 @@ jobs:
6262
json-summary-path: ../../coverage/packages/${{ matrix.package }}/coverage-summary.json
6363
json-final-path: ../../coverage/packages/${{ matrix.package }}/coverage-final.json
6464

65-
66-
# - name: Upload use-long-press coverage reports to Codecov
67-
# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
68-
# with:
69-
# token: ${{ secrets.CODECOV_TOKEN }}
70-
# directory: ./coverage/packages/use-long-press
71-
# flags: hooks,use-long-press
72-
#
73-
# - name: Upload use-double-tap coverage reports to Codecov
74-
# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
75-
# with:
76-
# token: ${{ secrets.CODECOV_TOKEN }}
77-
# directory: ./coverage/packages/use-double-tap
78-
# flags: hooks,use-double-tap
79-
#
80-
# - name: Upload react-interval-hook coverage reports to Codecov
81-
# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
82-
# with:
83-
# token: ${{ secrets.CODECOV_TOKEN }}
84-
# directory: ./coverage/packages/react-interval-hook
85-
# flags: hooks,react-interval-hook
65+
report-status:
66+
name: Report PR verification status
67+
runs-on: ubuntu-latest
68+
needs: verify-pr
69+
if: always() # Ensures it runs even if a matrix job fails
70+
steps:
71+
- name: Determine overall status
72+
run: |
73+
if [[ "${{ needs.verify-pr.result }}" == "success" ]]; then
74+
echo "All matrix jobs passed ✅"
75+
exit 0
76+
else
77+
echo "Some matrix jobs failed ❌"
78+
exit 1
79+
fi
80+
outputs:
81+
status: ${{ job.status }}

nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"generatorOptions": {
9898
"fallbackCurrentVersionResolver": "disk"
9999
},
100-
"preVersionCommand": "yarn nx run-many -t build",
100+
"preVersionCommand": "yarn nx run-many -t build"
101101
},
102102
"changelog": {
103103
"projectChangelogs": true,

0 commit comments

Comments
 (0)