@@ -2,7 +2,7 @@ name: Naisdevice
22
33on :
44 pull_request :
5- types : [opened, reopened, synchronize]
5+ types : [opened, reopened, synchronize, labeled ]
66 push :
77 branches : [main]
88 paths :
3030 - " pkg/pb/**"
3131
3232env :
33+ PRE_RELEASE : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'pre-release') && 'true' || 'false' }}
3334 # some mise tasks use this to determine how they package/sign stuff.
34- RELEASE : ${{ (github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]') && 'true' || 'false' }}
35+ RELEASE : ${{ (( github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]') || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'pre-release')) ) && 'true' || 'false' }}
3536
3637concurrency :
3738 group : ${{ github.ref }}
@@ -50,14 +51,18 @@ jobs:
5051 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
5152 with :
5253 fetch-depth : 0
53- - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v3
54+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
55+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
5456 - id : generate
5557 run : mise run ci:release-info
5658 env :
5759 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60+ PRE_RELEASE : ${{ env.PRE_RELEASE }}
61+ PR_NUMBER : ${{ github.event.pull_request.number }}
5862 outputs :
5963 version : ${{ steps.generate.outputs.version }}
6064 changelog : ${{ steps.generate.outputs.changelog }}
65+ pre_release : ${{ env.PRE_RELEASE }}
6166
6267 checks :
6368 strategy :
7681 contents : read
7782 steps :
7883 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
79- - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v3
84+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
8085 - run : mise run ${{ matrix.mise_task }}
8186
8287 builds :
@@ -109,7 +114,7 @@ jobs:
109114 OUTFILE : ./release_artifacts/naisdevice${{ matrix.gotags == 'tenant' && '-tenant' || '' }}_${{ matrix.platform.os }}_${{ matrix.arch }}.${{ matrix.platform.ext }}
110115 steps :
111116 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
112- - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v3
117+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
113118 - if : matrix.platform.os == 'windows'
114119 run : sudo apt-get update && sudo apt-get install --yes nsis osslsigncode
115120 - if : matrix.platform.os == 'macos'
@@ -129,34 +134,83 @@ jobs:
129134 run : |
130135 mkdir -p "$(dirname $OUTFILE)"
131136 mise run "package:${{ matrix.platform.os }}"
132- - uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # ratchet:actions/upload-artifact@v5
137+ - uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # ratchet:actions/upload-artifact@v7
133138 with :
134139 name : installer-${{ matrix.platform.os }}-${{ matrix.arch }}-${{ matrix.gotags || 'nav' }}
135140 path : ${{ env.OUTFILE }}
136141
142+ smoke-tests :
143+ name : smoke test ${{ matrix.artifact }}
144+ needs : [builds]
145+ strategy :
146+ fail-fast : false
147+ matrix :
148+ include :
149+ - os : macos
150+ runner : macos-latest
151+ artifact : installer-macos-arm64-nav
152+ installer_glob : " *.pkg"
153+ - os : macos
154+ runner : macos-latest
155+ artifact : installer-macos-arm64-tenant
156+ installer_glob : " *.pkg"
157+ - os : linux
158+ runner : ubuntu-latest
159+ artifact : installer-linux-amd64-nav
160+ installer_glob : " *.deb"
161+ - os : linux
162+ runner : ubuntu-latest
163+ artifact : installer-linux-amd64-tenant
164+ installer_glob : " *.deb"
165+ - os : windows
166+ runner : windows-latest
167+ artifact : installer-windows-amd64-nav
168+ installer_glob : " *.exe"
169+ - os : windows
170+ runner : windows-latest
171+ artifact : installer-windows-amd64-tenant
172+ installer_glob : " *.exe"
173+ runs-on : ${{ matrix.runner }}
174+ steps :
175+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
176+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
177+ - uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # ratchet:actions/download-artifact@v8
178+ with :
179+ name : ${{ matrix.artifact }}
180+ path : ./downloaded-artifact/
181+ - name : run smoke test
182+ shell : bash
183+ run : mise run smoke-test:${{ matrix.os }} ./downloaded-artifact/${{ matrix.installer_glob }}
184+
137185 # Used by GitHub to determine if all checks/builds have passed
138186 branch-protection-checkpoint :
139- needs : [checks, builds]
187+ needs : [checks, builds, smoke-tests ]
140188 if : ${{ always() }}
141189 runs-on : ubuntu-latest
142190 steps :
143- - if : ${{ needs.checks.result != 'success' || needs.builds.result != 'success' }}
191+ - if : ${{ needs.checks.result != 'success' || needs.builds.result != 'success' || needs.smoke-tests.result != 'success' }}
144192 run : exit 1
145- - run : echo "All checks and builds passed."
193+ - run : echo "All checks, builds, and smoke tests passed."
146194
147195 release-github :
148- if : github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]' && needs.release-info.outputs.changelog != '' && needs.release-info.outputs.version != ''
196+ if : >-
197+ needs.release-info.outputs.changelog != '' && needs.release-info.outputs.version != '' &&
198+ (
199+ (github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]') ||
200+ needs.release-info.outputs.pre_release == 'true'
201+ )
149202 needs : [release-info, branch-protection-checkpoint]
150203 runs-on : ubuntu-latest
151204 permissions :
152205 contents : write
206+ env :
207+ RELEASE_TARGET_COMMIT : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
153208 steps :
154209 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
155210 with :
156- fetch-depth : 0
157- - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v3
158- - run : git tag ${{ needs.release-info.outputs.version }}
159- - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # ratchet:actions/download-artifact@v6
211+ ref : ${{ env.RELEASE_TARGET_COMMIT }}
212+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
213+ - uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # ratchet:actions/download-artifact@v8
160214 with :
161215 merge-multiple : true
162216 path : release_artifacts
@@ -165,15 +219,18 @@ jobs:
165219 id : release
166220 with :
167221 tag_name : ${{ needs.release-info.outputs.version }}
222+ target_commitish : ${{ env.RELEASE_TARGET_COMMIT }}
168223 body : ${{ needs.release-info.outputs.changelog }}
169- prerelease : false
224+ prerelease : ${{ needs.release-info.outputs.pre_release == 'true' }}
170225 files : ./release_artifacts/*
171226 env :
172227 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
173- - env :
228+ - if : needs.release-info.outputs.pre_release != 'true'
229+ env :
174230 VERSION : ${{ needs.release-info.outputs.version }}
175231 run : mise run ci:prepare-template-vars ./release_artifacts/checksums.txt -v > template.vars
176- - uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # ratchet:actions/upload-artifact@v5
232+ - if : needs.release-info.outputs.pre_release != 'true'
233+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # ratchet:actions/upload-artifact@v7
177234 with :
178235 name : template-vars
179236 path : ./template.vars
@@ -182,12 +239,13 @@ jobs:
182239 echo "A new release is available over at https://github.com/${{ github.repository }}/releases/tag/${{ needs.release-info.outputs.version }}." >> $GITHUB_STEP_SUMMARY
183240
184241 release-gar :
242+ if : needs.release-info.outputs.pre_release != 'true'
185243 strategy :
186244 fail-fast : false
187245 matrix :
188246 arch : [arm64, amd64]
189247 suffix : [nav, tenant]
190- needs : [release-github]
248+ needs : [release-info, release- github]
191249 runs-on : ubuntu-latest
192250 permissions :
193251 contents : read
@@ -201,15 +259,16 @@ jobs:
201259 service_account : gh-naisdevice@nais-io.iam.gserviceaccount.com
202260 token_format : access_token
203261 - uses : google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # ratchet:google-github-actions/setup-gcloud@v3
204- - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # ratchet:actions/download-artifact@v6
262+ - uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # ratchet:actions/download-artifact@v8
205263 with :
206264 name : installer-linux-${{ matrix.arch }}-${{ matrix.suffix }}
207265 path : ./downloaded-artifact/
208266 - run : |
209267 gcloud artifacts apt upload nais-ppa --project nais-io --quiet --location europe-north1 --source ./downloaded-artifact/*
210268
211269 release-external-repos :
212- needs : [release-github]
270+ if : needs.release-info.outputs.pre_release != 'true'
271+ needs : [release-info, release-github]
213272 strategy :
214273 fail-fast : false
215274 matrix :
@@ -234,8 +293,8 @@ jobs:
234293 private-key : ${{ secrets.NAIS_APP_PRIVATE_KEY }}
235294 app-id : ${{ secrets.NAIS_APP_ID }}
236295 repo : ${{ matrix.target.repo }}
237- - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v3
238- - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # ratchet:actions/download-artifact@v6
296+ - uses : jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # ratchet:jdx/mise-action@v4
297+ - uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # ratchet:actions/download-artifact@v8
239298 with :
240299 name : template-vars
241300 - name : update ${{ matrix.target.repo }}
0 commit comments