-
Notifications
You must be signed in to change notification settings - Fork 20
208 lines (182 loc) · 6.95 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
# Copyright 2023 The original authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Releases
on:
workflow_dispatch:
inputs:
newVersion:
type: string
required: false
description: "New version (if null use current version)"
createTag:
type: boolean
required: true
description: "Create a Tag"
default: true
env:
JAVA_VERSION: '17'
JAVA_DISTRO: 'zulu'
GRAAL_VERSION: '22.3.3'
jobs:
set-release-version:
runs-on: ubuntu-latest
outputs:
HEAD: ${{ steps.version.outputs.HEAD }}
RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }}
steps:
- name: 'Checkout GitHub repository'
uses: actions/checkout@v4
with:
clean: true
- name: 'Set up Java'
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
check-latest: true
cache: maven
- name: 'Import GPG key'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Grant execute permission to MVN Wrapper
run: chmod +x ./mvnw
- name: Update release version
if: "${{ github.event.inputs.newVersion == '' }}"
run: |
echo 'Remove snapshot from maven version'
./mvnw -q versions:set -DremoveSnapshot -DprocessAllModules -DgenerateBackupPoms=false
- name: Set specific version to release
if: "${{ github.event.inputs.newVersion != '' }}"
run: |
./mvnw -q versions:set -DnewVersion=${{ github.event.inputs.newVersion }}
- name: 'Set env RELEASE_VERSION'
run: |
RELEASE_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: 'Configure Git'
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: 'Push release version'
id: version
if: "${{ github.event.inputs.createTag == 'true' }}"
run: |
find . -name 'pom.xml' | xargs git add
git commit -m "ci: release version ${{ env.RELEASE_VERSION }} 🎉"
git push --atomic origin HEAD:main
HEAD=$(git rev-parse HEAD)
echo "HEAD=$HEAD" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
build-distribution:
needs: [ set-release-version ]
name: 'Build with GraalVM on ${{ matrix.os }}'
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macOS-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Checkout GitHub repository'
uses: actions/checkout@v4
with:
ref: ${{ needs.set-release-version.outputs.HEAD }}
fetch-depth: 0
clean: true
- name: 'Set up GraalVM'
uses: graalvm/setup-graalvm@v1
with:
version: ${{ env.GRAAL_VERSION }}
java-version: ${{ env.JAVA_VERSION }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Build Native Image (Linux)'
if: ${{ runner.os == 'Linux' }}
run: |
./mvnw -ntp -B --file pom.xml -Pnative package
- name: 'Build Native Image (macOS)'
if: ${{ runner.os == 'macOS' }}
run: |
./mvnw -ntp -B --file pom.xml -Pnative package "-DskipTests"
- name: 'Build Distribution'
run: |
./mvnw -ntp -B --file pom.xml -Pdist package -DskipTests
- name: 'Build Debian Package (Linux)'
if: ${{ runner.os == 'Linux' }}
run: |
./mvnw -ntp -B --file pom.xml -Pdeb package
- name: 'Upload build artifact'
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
dist/*.zip
dist/*.tar.gz
dist/*.deb
dist/*.rpm
release-artifacts:
needs: [ set-release-version, build-distribution ]
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub repository'
uses: actions/checkout@v4
with:
ref: ${{ needs.set-release-version.outputs.HEAD }}
fetch-depth: 0
- name: 'Download all artifacts'
uses: actions/download-artifact@v3
- name: 'Set up Java'
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
- name: 'Cache Maven packages'
uses: actions/[email protected]
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: 'Configure Git'
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: 'Release with JReleaser'
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.PAT }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: ./mvnw -ntp -B --file ./jikkou-cli/pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release
- name: 'JReleaser output'
if: always()
uses: actions/upload-artifact@v3
with:
name: jreleaser-logs
path: |
target/jreleaser/trace.log
target/jreleaser/output.properties
- name: 'Bump version for next iteration'
if: "${{ github.event.inputs.newVersion == '' }}"
run: |
./mvnw -q build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT \
versions:commit
NEXT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
- name: 'Commit Bump Version'
if: "${{ github.event.inputs.newVersion == '' }}"
run: |
find . -name 'pom.xml' | xargs git add
git commit -m "ci: bump version for next iteration to ${{ env.NEXT_VERSION }} 🤖"
git push origin HEAD:main