Skip to content

Commit 3650c22

Browse files
committed
ci: separate workflow files
1 parent c63171d commit 3650c22

File tree

2 files changed

+143
-61
lines changed

2 files changed

+143
-61
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
branches:
66
- staging
77
- feature*
8-
tags:
9-
- v**
10-
11-
env:
12-
GIT_SUBMODULE_STRATEGY: recursive
13-
npm_config_cache: "${{ github.workspace }}/tmp/npm"
14-
npm_config_prefer_offline: "true"
158

169
jobs:
1710
check-lint:
@@ -95,37 +88,10 @@ jobs:
9588
name: cobertura-coverage
9689
path: tmp/coverage/cobertura-coverage.json
9790

98-
build-prerelease:
99-
name: "Build / Pre-release"
100-
runs-on: ubuntu-latest
101-
needs:
102-
- check-lint
103-
- check-build
104-
- check-test
105-
if: >
106-
startsWith(github.ref, 'refs/tags/v') &&
107-
contains(github.ref, '-')
108-
steps:
109-
- uses: actions/checkout@v4
110-
- name: Run deployment
111-
run: |
112-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
113-
echo 'Publishing library prerelease'
114-
npm install
115-
npm publish --tag prerelease --access public
116-
rm -f ./.npmrc
117-
11891
build-pull:
11992
name: "Build / Pull Request"
12093
runs-on: ubuntu-latest
121-
needs:
122-
- check-lint
123-
- check-build
124-
- check-test
125-
if: >
126-
github.ref == 'refs/heads/staging' ||
127-
(startsWith(github.ref, 'refs/tags/v') &&
128-
!contains(github.ref, '-'))
94+
if: github.ref == 'refs/head/staging'
12995
steps:
13096
- uses: actions/checkout@v4
13197
- name: Create pull request
@@ -150,11 +116,12 @@ jobs:
150116
concurrency:
151117
group: integration-merge
152118
cancel-in-progress: true
153-
needs: build-pull
154-
if: >
155-
github.ref == 'refs/heads/staging' ||
156-
(startsWith(github.ref, 'refs/tags/v') &&
157-
!contains(github.ref, '-'))
119+
needs:
120+
- build-pull
121+
- check-lint
122+
- check-build
123+
- check-test
124+
if: github.ref == 'refs/heads/staging'
158125
steps:
159126
- uses: actions/checkout@v4
160127
with:
@@ -175,24 +142,3 @@ jobs:
175142
git checkout master
176143
git merge --ff-only "$GITHUB_SHA"
177144
git push origin master
178-
179-
release-distribution:
180-
name: "Release / Distribution"
181-
runs-on: ubuntu-latest
182-
concurrency:
183-
group: release-distribution
184-
cancel-in-progress: false
185-
needs: integration-merge
186-
if: >
187-
startsWith(github.ref, 'refs/tags/v') &&
188-
!contains(github.ref, '-')
189-
steps:
190-
- uses: actions/checkout@v4
191-
- name: Publish release
192-
run: |
193-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
194-
echo 'Publishing library'
195-
npm install
196-
npm publish --access public
197-
rm -f ./.npmrc
198-

.github/workflows/release.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v**
7+
8+
jobs:
9+
check-lint:
10+
name: "Check / Lint"
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Run linting
15+
run: |
16+
npm install
17+
npm run lint
18+
npm run lint-shell
19+
20+
check-build:
21+
name: "Check / Build"
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Run build
26+
run: |
27+
npm install
28+
npm run build --verbose
29+
30+
check-matrix:
31+
name: "Check / Matrix"
32+
runs-on: ubuntu-latest
33+
outputs:
34+
matrix: ${{ steps.set-matrix.outputs.matrix }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
- id: set-matrix
38+
run: |
39+
files=$(find tests/* -maxdepth 0 -type d | sed 's/.*/"&"/' | paste -sd, -)
40+
files=$files,$(find tests/* -maxdepth 0 -type f | grep -e "/*.test.ts" | sed 's/.*/"&"/' | paste -sd, -)
41+
if [ -z "$files" ]; then
42+
echo "matrix={\"shard\":[]}" >> $GITHUB_OUTPUT
43+
else
44+
echo "matrix={\"shard\":[$files]}" >> $GITHUB_OUTPUT
45+
fi
46+
47+
check-test:
48+
name: "Check / Test"
49+
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix: ${{fromJson(needs.check-matrix.outputs.matrix)}}
53+
needs: check-matrix
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Set artifact name
57+
run: echo "SLUG=$(echo ${{ matrix.shard }} | sed 's/[/.]/-/g')" >> $GITHUB_ENV
58+
- name: Run tests
59+
run: |
60+
npm install
61+
npm run test -- \
62+
--coverageReporters json \
63+
--coverage \
64+
"${{ matrix.shard }}"
65+
mv tmp/coverage/coverage-final.json "tmp/coverage/${{ env.SLUG }}.json"
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: coverage-artifacts-${{ env.SLUG }}
69+
path: tmp/coverage/
70+
71+
check-coverage:
72+
name: "Check / Coverage"
73+
runs-on: ubuntu-latest
74+
needs: check-test
75+
steps:
76+
- uses: actions/checkout@v4
77+
- uses: actions/download-artifact@v4
78+
with:
79+
pattern: coverage-artifacts-*
80+
path: tmp/coverage/
81+
merge-multiple: true
82+
- run: rm .npmrc
83+
- name: Merge coverage results
84+
run: npx nyc merge tmp/coverage/ tmp/coverage/cobertura-coverage.json
85+
- uses: actions/upload-artifact@v4
86+
with:
87+
name: cobertura-coverage
88+
path: tmp/coverage/cobertura-coverage.json
89+
90+
build-prerelease:
91+
name: "Build / Pre-release"
92+
runs-on: ubuntu-latest
93+
concurrency:
94+
group: build-prerelease
95+
cancel-in-progress: false
96+
needs:
97+
- check-lint
98+
- check-build
99+
- check-test
100+
if: >
101+
startsWith(github.ref, 'refs/tags/v') &&
102+
contains(github.ref, '-')
103+
steps:
104+
- uses: actions/checkout@v4
105+
- name: Run deployment
106+
run: |
107+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
108+
echo 'Publishing library prerelease'
109+
npm install
110+
npm publish --tag prerelease --access public
111+
rm -f ./.npmrc
112+
113+
release-distribution:
114+
name: "Release / Distribution"
115+
runs-on: ubuntu-latest
116+
concurrency:
117+
group: release-distribution
118+
cancel-in-progress: false
119+
needs:
120+
- check-lint
121+
- check-build
122+
- check-test
123+
if: >
124+
startsWith(github.ref, 'refs/tags/v') &&
125+
!contains(github.ref, '-')
126+
steps:
127+
- uses: actions/checkout@v4
128+
- name: Publish release
129+
run: |
130+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
131+
echo 'Publishing library'
132+
npm install
133+
npm publish --access public
134+
rm -f ./.npmrc
135+
136+

0 commit comments

Comments
 (0)