1
1
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2
- # TODO: Clean-up
3
2
# See: https://github.com/JulianCataldo/gh-actions
4
3
5
- name : ' Release'
4
+ # For matrix setup:
5
+ # https://github.com/withastro/astro/blob/main/.github/workflows/ci.yml
6
+ # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
7
+
8
+ name : CI / Release
6
9
7
10
on :
11
+ workflow_dispatch :
8
12
push :
13
+ paths-ignore :
14
+ - .github/**
15
+ - ' !.github/workflows/release.yaml'
16
+ - ' **/*.md'
9
17
branches :
10
18
- ' ([0-9])?(.{+([0-9]),x}).x'
11
- - ' main'
12
- - ' next'
13
- - ' next-major'
14
- - ' alpha'
15
- - ' beta'
19
+ - main
20
+ - next
21
+ - next-major
22
+ - alpha
23
+ - beta
24
+ - ' feat/*'
25
+ - ' fix/*'
26
+ # - to-integrate
27
+ # - to-integrate-next
16
28
17
29
permissions :
18
- contents : ' read' # for checkout
30
+ contents : read # for checkout
19
31
20
32
jobs :
21
33
release :
22
- name : ' Release'
23
- runs-on : ' ubuntu-latest '
34
+ name : CI / Release
35
+
24
36
permissions :
25
- contents : ' write' # to be able to publish a GitHub release
26
- issues : ' write' # to be able to comment on released issues
27
- pull-requests : ' write' # to be able to comment on released pull requests
28
- id-token : ' write' # to enable use of OIDC for npm provenance
37
+ contents : write # to be able to publish a GitHub release
38
+ issues : write # to be able to comment on released issues
39
+ pull-requests : write # to be able to comment on released pull requests
40
+ id-token : write # to enable use of OIDC for npm provenance
41
+
42
+ runs-on : ubuntu-latest
43
+ # TODO:
44
+ # runs-on: ${{ matrix.os }}
45
+ # timeout-minutes: 25
46
+ # # needs: build
47
+ # strategy:
48
+ # matrix:
49
+ # OS: [ubuntu-latest]
50
+ # NODE_VERSION: [18, 20]
51
+ # include:
52
+ # - os: macos-14
53
+ # NODE_VERSION: 18
54
+ # - os: windows-latest
55
+ # NODE_VERSION: 18
56
+ # fail-fast: false
57
+ # env:
58
+ # NODE_VERSION: ${{ matrix.NODE_VERSION }}
29
59
30
60
steps :
31
- # - name: "Harden Runner"
32
- # uses: "step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09" # v2.5.1
33
- # with:
34
- # egress-policy: "audit"
61
+ # MARK: Setup GH Action
62
+
63
+ - name : ' Harden Runner'
64
+ uses : ' step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142' # v2.7.0
65
+ with :
66
+ egress-policy : ' audit'
35
67
36
- - name : ' Git checkout'
37
- uses : ' actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 ' # v3.6.0
68
+ - name : Git checkout
69
+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
38
70
# run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
39
71
with :
40
72
fetch-depth : 0
@@ -46,71 +78,101 @@ jobs:
46
78
# GIT_AUTHOR_NAME: "GitHub Actions Shell"
47
79
# EMAIL: "github-actions[bot]@users.noreply.github.com"
48
80
49
- - name : ' Setup PNPM'
50
- uses : ' pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598' # v2.4.0
81
+ # MARK: Setup Node env.
82
+
83
+ - name : Setup PNPM
84
+ uses : pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
51
85
with :
52
86
run_install : false
53
87
54
- - name : ' Use Node.js 20.6.1 '
55
- uses : ' actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d ' # v3.8.1
88
+ - name : Use Node.js 22.2.0
89
+ uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
56
90
with :
57
91
# registry-url: "https://registry.npmjs.org"
58
- node-version : ' 20.6.1 '
59
- cache : ' pnpm'
92
+ node-version : 22.2.0
93
+ cache : pnpm
60
94
61
- # @see: npm install -g npm@latest is necessary to make provenance available. More info: https://docs.npmjs.com/generating-provenance-statements
62
- # - name: "Upgrade npm to latest version"
63
- # run: "npm install --global [email protected] "
64
- # env:
65
- # SKIP_CHECK: "true"
95
+ - name : Install packages
96
+ shell : bash
97
+ run : pnpm install --frozen-lockfile
66
98
67
- # - name: "Check npm version"
68
- # run: "npm -v"
69
- # env:
70
- # SKIP_CHECK: "true"
99
+ # TODO: More tests
100
+ # - name: Syncpack Lint
101
+ # shell: bash
102
+ # run: node --run syncpack:lint
71
103
72
- - name : ' Install packages'
73
- run : ' pnpm install --frozen-lockfile'
104
+ # NOTE: Audit is for prod only because a lot of root packages (like lerna etc.)
105
+ # are used old packages with intricate dependency trees, and they are
106
+ # never shipped to the user. But that's not 100% optimal, as devDeps could
107
+ # provoke some sec issues, too? A middleground is better than nothing and
108
+ # regularly blocked releases for obscure root mono-repo tooling deps.
109
+ - name : ' Verify the integrity of provenance attestations and registry signatures for installed [prod] dependencies'
110
+ run : node --run audit
74
111
75
- # - name: "Verify the integrity of provenance attestations and registry signatures for installed dependencies"
76
- # run: "pnpm audit signatures"
112
+ # MARK: Lint/Checks pre-build
77
113
78
- # - name: "npm v8.5+ requires workspaces-update to be set to false"
79
- # run: "echo 'workspaces-update=false' >> .npmrc"
114
+ # TODO: Setup Husky etc.
115
+ # - name: Lint last commit — Commitlint
116
+ # shell: bash
117
+ # run: node --run lint:commit
80
118
81
- # - name: "Semantic Release"
82
- # if: "success()"
83
- # env:
84
- # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
85
- # NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
86
- # GIT_AUTHOR_NAME: "github-actions-shell"
87
- # GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com"
88
- # GIT_COMMITTER_NAME: "github-actions-shell"
89
- # GIT_COMMITTER_EMAIL: "github-actions[bot]@users.noreply.github.com"
90
- # run: "pnpm exec multi-semantic-release"
119
+ # - name: Lint CSS — Stylelint
120
+ # shell: bash
121
+ # run: node --run lint:css
122
+
123
+ - name : Check all formatting — Prettier
124
+ shell : bash
125
+ run : node --run format
126
+
127
+ # MARK: Build packages
128
+
129
+ - name : Setup Turbo cache
130
+ uses : dtinth/setup-github-actions-caching-for-turbo@a0e976d970c2a94366a26984efcef3030e2c0115 # v1.2.0
131
+
132
+ - name : Build all packages
133
+ shell : bash
134
+ run : node --run build
135
+
136
+ # MARK: Lint/Checks post-build
91
137
92
- - name : ' Setup Turbo cache'
93
- uses : dtinth/setup-github-actions-caching-for-turbo@v1
138
+ - name : Lint JS/TS — ESLint
139
+ shell : bash
140
+ run : node --run lint:es
94
141
95
- - name : ' Build all packages'
96
- run : ' pnpm build'
142
+ # MARK:Tests
97
143
98
- - name : ' Create temporary NPM identity'
144
+ - name : Tests — Units
145
+ shell : bash
146
+ run : node --run test:unit
147
+
148
+ # - name: Tests — Integration
149
+ # shell: bash
150
+ # run: node --run test:integration
151
+
152
+ # TODO: Build and launch example-app
153
+ # - name: Tests — E2E
154
+ # shell: bash
155
+ # run: node --run test:e2e
156
+
157
+ # MARK: Publish packages
158
+
159
+ - name : Create temporary NPM identity # + Enable Provenance
99
160
env :
100
161
NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
162
+ # run: |
163
+ # echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN\nprovenance=true" > .npmrc
164
+ # echo "provenance=true" > .npmrc
101
165
run : |
102
166
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
103
167
104
- - name : ' Git user configuration'
168
+ - name : Git user configuration
105
169
run : |
106
170
git config --global user.name "${{ github.actor }}"
107
171
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
108
172
109
- # - name: 'Lerna version'
110
- # run: |
111
- # pnpm lerna version --conventional-commits --yes
112
-
173
+ # MARK: [MAIN]
113
174
- name : ' Lerna publish [main]'
175
+ # if: github.ref == 'refs/heads/to-integrate'
114
176
if : github.ref == 'refs/heads/main'
115
177
# https://github.com/lerna/lerna/issues/2532
116
178
id : graduateRelease
@@ -119,7 +181,7 @@ jobs:
119
181
GH_TOKEN : ' ${{ secrets.GITHUB_TOKEN }}'
120
182
NPM_TOKEN : ' ${{ secrets.NPM_TOKEN }}' # Not really needed (already global)
121
183
run : |
122
- pnpm lerna publish --conventional-commits --exact --conventional-graduate --create-release=github --yes
184
+ pnpm lerna publish --message 'chore: publish [main] release [skip ci]' --create-release=github --conventional-graduate --yes
123
185
124
186
- name : Bump Prod Version Fallback
125
187
if : ${{ always() && steps.graduateRelease.outcome == 'failure' }}
@@ -129,18 +191,28 @@ jobs:
129
191
run : |
130
192
echo Falling back to non-graduate release due to https://github.com/lerna/lerna/issues/2532
131
193
git stash
132
- pnpm lerna publish --conventional-commits --exact --create-release=github --yes
194
+ pnpm lerna publish --message 'chore: publish [main] release [skip ci]' --create-release=github --yes
133
195
196
+ # # TRY: https://www.jessesquires.com/blog/2021/10/17/github-actions-workflows-for-automatic-rebasing-and-merging/
197
+ # - name: Merge (rebase) back main into next
198
+ # env:
199
+ # GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
200
+ # run: |
201
+ # git checkout next
202
+ # git rebase main
203
+ # git push
204
+
205
+ # MARK: [NEXT]
134
206
- name : ' Lerna publish [next]'
135
207
if : github.ref == 'refs/heads/next'
208
+ # if: github.ref == 'refs/heads/to-integrate-next'
136
209
env :
137
210
NPM_TOKEN : ' ${{ secrets.NPM_TOKEN }}' # Not really needed (already global)
138
- run : |
139
- pnpm lerna publish --conventional-commits --exact --conventional-prerelease --canary --dist-tag=next --preid=next --yes
140
211
141
- # pnpm publish -r
142
-
143
- # - name: "Publish"
144
- # run: "pnpm publish -r"
145
-
146
- # --changelog-preset conventionalcommits
212
+ # --canary next
213
+ # https://github.com/lerna/lerna/issues/1433
214
+ # pnpm lerna publish --conventional-prerelease --dist-tag=next --preid=next --no-changelog --yes
215
+ # pnpm lerna publish --conventional-prerelease --pre-dist-tag=next --preid=next --yes
216
+ # pnpm lerna publish --force-publish='*' --canary --pre-dist-tag=next --preid=next --yes
217
+ run : |
218
+ pnpm lerna publish --message 'chore: publish [next] pre-release' --conventional-prerelease --pre-dist-tag=next --preid=next --yes
0 commit comments