-
Notifications
You must be signed in to change notification settings - Fork 95
432 lines (427 loc) · 20.1 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
name: Release
on:
release:
types: [published]
jobs:
build:
name: Release artifacts to Maven Central & SDKMAN, and publish documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set the current release version
id: release_version
run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: Run pre-release
uses: micronaut-projects/github-actions/pre-release@master
env:
MICRONAUT_BUILD_EMAIL: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: projectVersion is not a snapshot
run: ./gradlew projectVersionNotSnapshot
- name: Micronaut Core is not a snapshot
run: ./gradlew micronautCoreNotSnapshot
- name: Micronaut Platform is not a snapshot
run: ./gradlew micronautPlatformNotSnapshot
- name: Build All
run: ./gradlew micronaut-cli:assemble
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: Publish to Maven Central
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
GPG_FILE: ${{ secrets.GPG_FILE }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
run: echo $GPG_FILE | base64 -d > secring.gpg && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository docs
- name: Upload CLI Zip
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: starter-cli/build/distributions/micronaut-cli-${{ steps.release_version.outputs.release_version }}.zip
asset_name: micronaut-cli-${{ steps.release_version.outputs.release_version }}.zip
asset_content_type: application/zip
- name: Publish to Github Pages
if: success()
uses: micronaut-projects/github-pages-deploy-action@master
env:
BETA: ${{ contains(steps.release_version.outputs.release_version, 'M') || contains(steps.release_version.outputs.release_version, 'RC') }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BASE_BRANCH: master
BRANCH: gh-pages
FOLDER: build/docs
VERSION: ${{ steps.release_version.outputs.release_version }}
- name: Run post-release
if: success()
id: post_release
continue-on-error: true
uses: micronaut-projects/github-actions/post-release@master
env:
MICRONAUT_BUILD_EMAIL: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Back to Micronaut snapshot
continue-on-error: true
run: |
echo "Setting new Micronaut snapshot version"
sed -i "s/^micronautVersion.*$/micronautVersion\=${{ steps.post_release.outputs.next_version }}-SNAPSHOT/" gradle.properties
- uses: stefanzweifel/git-auto-commit-action@v5.0.0
continue-on-error: true
with:
commit_message: Back Micronaut version to snapshot
commit_user_name: micronaut-build
commit_user_email: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
commit_author: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
file_pattern: gradle.properties
linux:
name: Release Linux Native CLI
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set the current release version
id: release_version
run: |
release_version=${GITHUB_REF:11}
sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: "☕️ Setup GraalVM CE"
uses: graalvm/setup-graalvm@v1.1.5
with:
version: '22.3.2'
java-version: '17'
native-image-musl: 'true'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image (with libc=musl)"
run: ./gradlew micronaut-cli:nativeCompile --no-daemon -Pmusl
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: "✅ Verify Build"
run: ./starter-cli/build/native/nativeCompile/mn --version
- name: "✅ Verify Create App"
run: ./starter-cli/build/native/nativeCompile/mn create-app test
- name: "👷♀️Package Build"
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
mkdir -p "mn-linux-amd64-${VERSION}/bin"
mv ./starter-cli/build/native/nativeCompile/mn "mn-linux-amd64-${VERSION}/bin"
cp ./LICENSE "mn-linux-amd64-${VERSION}/"
zip -r "mn-linux-amd64-${VERSION}.zip" "mn-linux-amd64-${VERSION}/"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./mn-linux-amd64-${{ github.event.release.tag_name }}.zip
asset_name: mn-linux-amd64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
macos:
name: Release OS X Native CLI
runs-on: macos-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set the current release version
id: release_version
run: |
release_version=${GITHUB_REF:11}
sed -i -e "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: "☕️ Setup GraalVM CE"
uses: graalvm/setup-graalvm@v1.1.5
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
run: ./gradlew micronaut-cli:nativeCompile --no-daemon
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: "✅ Verify Build"
run: ./starter-cli/build/native/nativeCompile/mn --version
- name: "✅ Verify Create App"
run: ./starter-cli/build/native/nativeCompile/mn create-app test
- name: Package Build
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
mkdir -p "mn-darwin-amd64-${VERSION}/bin"
mv ./starter-cli/build/native/nativeCompile/mn "mn-darwin-amd64-${VERSION}/bin"
cp ./LICENSE "mn-darwin-amd64-${VERSION}/"
zip -r "mn-darwin-amd64-${VERSION}.zip" "mn-darwin-amd64-${VERSION}/" -x '*.DS_Store*' -x '__MAC_OSX'
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./mn-darwin-amd64-${{ github.event.release.tag_name }}.zip
asset_name: mn-darwin-amd64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
windows:
name: Release Windows Native CLI
runs-on: windows-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: "☕️ Setup GraalVM CE"
uses: graalvm/setup-graalvm@v1.1.5
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
run: ./gradlew micronaut-cli:nativeCompile --no-daemon
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: "✅ Verify Build (Powershell)"
shell: powershell
run: ./starter-cli/build/native/nativeCompile/mn.exe --version
- name: "✅ Verify Create App (Powershell)"
run: ./starter-cli/build/native/nativeCompile/mn.exe create-app test
- name: "✅ Verify Build (CMD)"
shell: cmd
run: starter-cli\\build\\native\\nativeCompile\\mn --version
- name: "✅ Verify Create App (CMD)"
shell: cmd
run: starter-cli\\build\\native\\nativeCompile\\mn create-app test2
- name: "🤐 ZIP Archive"
run: |
New-Item ./mn-win-amd64-${{ github.event.release.tag_name }}/bin -ItemType Directory -ea 0
Move-Item -Path ./starter-cli/build/native/nativeCompile/mn.exe -Destination ./mn-win-amd64-${{ github.event.release.tag_name }}/bin
Copy-Item ./LICENSE -Destination ./mn-win-amd64-${{ github.event.release.tag_name }}
Compress-Archive -Path ./mn-win-amd64-${{ github.event.release.tag_name }} -Update -DestinationPath ./mn-win-amd64-${{ github.event.release.tag_name }}.zip
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./mn-win-amd64-${{ github.event.release.tag_name }}.zip
asset_name: mn-win-amd64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
sdkman:
name: Release to SDKMAN!
runs-on: ubuntu-latest
needs: [linux, macos, windows]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set the current release version
id: release_version
run: |
release_version=${GITHUB_REF:11}
sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: SDKMAN release
env:
GVM_SDKVENDOR_KEY: ${{ secrets.GVM_SDKVENDOR_KEY }}
GVM_SDKVENDOR_TOKEN: ${{ secrets.GVM_SDKVENDOR_TOKEN }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
run: ./gradlew sdkRelease --no-daemon
gcr:
name: Deploy to Cloud Run
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set the current release version
id: release_version
run: |
release_version=${GITHUB_REF:11}
sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: Run Tests
run: ./gradlew starter-api:test starter-web-netty:test starter-gcp-function:shadowJar
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: Build Docker image
run: |
./gradlew starter-web-netty:dockerBuild -PdockerImageName="gcr.io/${{ secrets.GCLOUD_PROJECT }}/micronaut-starter:${{ steps.release_version.outputs.release_version }}"
- name: Authenticate into Google Cloud Platform
uses: google-github-actions/setup-gcloud@v0.2.1
with:
service_account_email: ${{ secrets.GCLOUD_EMAIL }}
service_account_key: ${{ secrets.GCLOUD_AUTH }}
- name: Configure Docker to use Google Cloud Platform
run: "gcloud auth configure-docker --quiet"
- name: Push image to Google Cloud Container Registry
run: |
./gradlew starter-web-netty:dockerPush -PdockerImageName="gcr.io/${{ secrets.GCLOUD_PROJECT }}/micronaut-starter:${{ steps.release_version.outputs.release_version }}"
- name: Deploy to Cloud Run
env:
release_version: ${{ steps.release_version.outputs.release_version }}
run: |
gcloud components install beta --quiet
gcloud beta run deploy micronaut-starter-latest --quiet --image gcr.io/${{ secrets.GCLOUD_PROJECT }}/micronaut-starter:${{ steps.release_version.outputs.release_version }} --project ${{ secrets.GCLOUD_PROJECT }} --region us-central1 --update-env-vars=HOSTNAME="launch.micronaut.io",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_CLIENT_SECRET }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }}
version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')"
gcloud beta run deploy "micronaut-starter-$version" --quiet --image gcr.io/${{ secrets.GCLOUD_PROJECT }}/micronaut-starter:${{ steps.release_version.outputs.release_version }} --project ${{ secrets.GCLOUD_PROJECT }} --region us-central1 --update-env-vars=HOSTNAME="launch.micronaut.io",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_CLIENT_SECRET }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }}
homebrew:
name: Update Homebrew cask
needs: [macos]
runs-on: ubuntu-latest
steps:
- name: Checkout https://github.com/micronaut-projects/homebrew-tap
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
repository: micronaut-projects/homebrew-tap
- name: Download ZIP
run: wget -q https://github.com/micronaut-projects/micronaut-starter/releases/download/${{ github.event.release.tag_name }}/mn-darwin-amd64-${{ github.event.release.tag_name }}.zip -O mn.zip
- name: Calculate SHA256
id: sha
run: |
s=$(sha256sum mn.zip | awk '{ print $1 }')
echo "SHA256 is: $s"
echo "sha=${s}" >> $GITHUB_OUTPUT
- name: Update Cask file
env:
SHA: ${{ steps.sha.outputs.sha }}
run: |
sed -i -e "s/ version.*/ version '${GITHUB_REF:11}'/" Casks/micronaut.rb
sed -i -e "s/sha256.*/sha256 '${SHA}'/" Casks/micronaut.rb
cat Casks/micronaut.rb
- uses: stefanzweifel/git-auto-commit-action@v5.0.0
with:
commit_message: Update Micronaut cask to ${{ github.event.release.tag_name }}
commit_user_name: micronaut-build
commit_user_email: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
commit_author: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
chocolatey:
name: Bump Chocolatey package
runs-on: windows-latest
needs: [windows]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}
token: ${{ secrets.GH_TOKEN }}
- name: Download ZIP, update versions and checksum
id: choco
working-directory: chocolatey
shell: pwsh
run: |
Invoke-RestMethod -Uri https://github.com/micronaut-projects/micronaut-starter/releases/download/${{ github.event.release.tag_name }}/mn-win-amd64-${{ github.event.release.tag_name }}.zip -OutFile 'mn.zip'
$SHA = (Get-FileHash ./mn.zip -Algorithm SHA256).Hash
echo $SHA
$Version = "${{ github.event.release.tag_name }}".substring(1)
echo $Version
#Fix semver
$NugetVersion = $Version
$Parts = $Version.Split(".")
if ($Parts.Count -eq 4) {
$NugetVersion = $Parts[0] + "." + $Parts[1] + "." + $Parts[2] + "-" + $Parts[3]
}
echo $NugetVersion
(Get-Content ./micronaut.nuspec) -replace '<version>.*</version>', "<version>$NugetVersion</version>" | Set-Content ./micronaut.nuspec
Get-Content ./micronaut.nuspec
(Get-Content ./tools/chocolateyinstall.ps1) -replace '^\$version.*', "`$version = '$Version'" | Set-Content ./tools/chocolateyinstall.ps1
(Get-Content ./tools/chocolateyinstall.ps1) -replace ' checksum\s+=.*', " checksum = '$SHA'" | Set-Content ./tools/chocolateyinstall.ps1
Get-Content ./tools/chocolateyinstall.ps1
echo "nuget_version=$NugetVersion" >> $env:GITHUB_OUTPUT
- name: Create package
working-directory: chocolatey
run: choco pack
- name: Push package
working-directory: chocolatey
env:
API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
run: |
choco apikey --key $Env:API_KEY --source https://push.chocolatey.org/
choco push micronaut.${{ steps.choco.outputs.nuget_version }}.nupkg --source https://push.chocolatey.org/ --force
- uses: stefanzweifel/git-auto-commit-action@v5.0.0
with:
commit_message: Bump Micronaut Chocolatey package to ${{ github.event.release.tag_name }}
commit_user_name: micronaut-build
commit_user_email: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
commit_author: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
backtosnapshots:
name: Core and Platform to Snapshot Versions
runs-on: ubuntu-latest
needs: [chocolatey, sdkman, gcr, homebrew]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: ${{ github.event.release.target_commitish }}
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Back to Micronaut Core snapshot
continue-on-error: true
run: ./gradlew micronautCoreNextSnapshot
- name: Back to Micronaut Platform snapshot
continue-on-error: true
run: ./gradlew micronautPlatformNextSnapshot
- uses: stefanzweifel/git-auto-commit-action@v5.0.0
continue-on-error: true
with:
commit_message: Back Core and Platform version to snapshot
commit_user_name: micronaut-build
commit_user_email: ${{ secrets.MICRONAUT_BUILD_EMAIL }}
commit_author: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
file_pattern: gradle.properties