1- ---
2- name : CI & Release
3-
4- # Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
5- run-name : >-
6- ${{
7- inputs.release && inputs.test && 'Build ➤ Test ➤ Publish to NPM' ||
8- inputs.release && !inputs.test && 'Build ➤ Skip Tests ➤ Publish to NPM' ||
9- github.event_name == 'workflow_dispatch' && inputs.test && 'Build ➤ Test' ||
10- github.event_name == 'workflow_dispatch' && !inputs.test && 'Build ➤ Skip Tests' ||
11- ''
12- }}
1+ name : CI
132
143on :
15- # Build on pushes branches that have a PR (including drafts)
164 pull_request :
17- # Build on commits pushed to branches without a PR if it's in the allowlist
5+ branches : [main]
186 push :
197 branches : [main]
20- # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
21- workflow_dispatch :
22- inputs :
23- test :
24- description : Run tests
25- required : true
26- default : true
27- type : boolean
28- release :
29- description : Release new version
30- required : true
31- default : false
32- type : boolean
338
349concurrency :
35- # On PRs builds will cancel if new pushes happen before the CI completes, as it defines `github.head_ref` and gives it the name of the branch the PR wants to merge into
36- # Otherwise `github.run_id` ensures that you can quickly merge a queue of PRs without causing tests to auto cancel on any of the commits pushed to main.
37- group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
38- cancel-in-progress : true
10+ group : ${{ github.workflow }}-${{ github.ref }}
3911
4012jobs :
41- log-the-inputs :
42- name : Log inputs
43- runs-on : ubuntu-latest
44- steps :
45- - run : |
46- echo "Inputs: $INPUTS"
47- env:
48- INPUTS: ${{ toJSON(inputs) }}
49-
5013 build :
5114 runs-on : ubuntu-latest
5215 name : Lint & Build
5316 steps :
54- - uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
55- - uses : actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
17+ - uses : actions/checkout@v5
18+ - uses : pnpm/action-setup@v4
19+ - uses : actions/setup-node@v6
5620 with :
57- cache : npm
21+ cache : pnpm
5822 node-version : lts/*
59- - run : npm ci
60- # Linting can be skipped
61- - run : npm run lint --if-present
62- if : github.event.inputs.test != 'false'
63- # But not the build script, as semantic-release will crash if this command fails so it makes sense to test it early
64- - run : npm run prepublishOnly --if-present
23+ - run : pnpm install
24+ - run : pnpm type-check
25+ - run : pnpm lint -f gha --max-warnings 0
26+ - run : pnpm prepublishOnly
6527
6628 test :
6729 needs : build
68- # The test matrix can be skipped, in case a new release needs to be fast-tracked and tests are already passing on main
69- if : github.event.inputs.test != 'false'
7030 runs-on : ${{ matrix.os }}
7131 name : Node.js ${{ matrix.node }} / ${{ matrix.os }}
7232 strategy :
@@ -91,42 +51,11 @@ jobs:
9151 run : |
9252 git config --global core.autocrlf false
9353 git config --global core.eol lf
94- - uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
95- - uses : actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
54+ - uses : actions/checkout@v5
55+ - uses : pnpm/action-setup@v4
56+ - uses : actions/setup-node@v6
9657 with :
97- cache : npm
58+ cache : pnpm
9859 node-version : ${{ matrix.node }}
99- - run : npm i
100- - run : npm test
101-
102- release :
103- needs : [build, test]
104- # only run if opt-in during workflow_dispatch
105- if : always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
106- runs-on : ubuntu-latest
107- name : Semantic release
108- steps :
109- - uses : actions/create-github-app-token@v2
110- id : app-token
111- with :
112- app-id : ${{ secrets.ECOSPARK_APP_ID }}
113- private-key : ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }}
114- - uses : actions/checkout@v4
115- with :
116- # Need to fetch entire commit history to
117- # analyze every commit since last release
118- fetch-depth : 0
119- # Uses generated token to allow pushing commits back
120- token : ${{ steps.app-token.outputs.token }}
121- # Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
122- persist-credentials : false
123- - uses : actions/setup-node@v4
124- with :
125- cache : npm
126- node-version : lts/*
127- - run : npm ci
128- # Branches that will release new versions are defined in .releaserc.json
129- - run : npx semantic-release
130- env :
131- GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
132- NPM_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
60+ - run : pnpm install
61+ - run : pnpm test
0 commit comments