-
Notifications
You must be signed in to change notification settings - Fork 0
263 lines (261 loc) · 9.75 KB
/
main.yaml
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
name: Main
on:
push:
schedule:
- cron: '21 5 22 * *'
env:
ARTIFACT: wait-for-ports
GRAALVM_VERSION: 22.2.0
JAVA_VERSION: 21
jobs:
debug:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJSON(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: echo "$MATRIX_CONTEXT"
- name: Dump environment variables
run: set
version:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.output.outputs.new_version }}
build_timestamp: ${{ steps.output.outputs.build_timestamp }}
steps:
- uses: actions/[email protected]
- name: Bump version and push tag
id: tag
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
uses: ArloL/[email protected]
- id: output
env:
NEW_VERSION: ${{ steps.tag.outputs.new_version }}
run: |
echo "new_version=${NEW_VERSION:-$GITHUB_SHA}" >> $GITHUB_OUTPUT
echo "build_timestamp=$(date --iso-8601=seconds)" >> $GITHUB_OUTPUT
- name: Make sure build did not change anything
run: git diff --exit-code
macos:
runs-on: macos-latest
needs: version
env:
REVISION: ${{ needs.version.outputs.new_version }}
BUILD_TIMESTAMP: ${{ needs.version.outputs.build_timestamp }}
steps:
- uses: actions/[email protected]
- uses: graalvm/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: graalvm
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Build with Maven
run: |
set -o xtrace
./mvnw \
--batch-mode \
-Dsha1="${GITHUB_SHA}" \
-Drevision="${REVISION}" \
verify
- name: Test executable
run: sh ./src/test/native/test-executable.sh "${{ env.ARTIFACT }}" macos "${{ env.REVISION }}"
- name: Move artifacts
run: |
mkdir target/artifacts
cp target/${{ env.ARTIFACT }}-* target/artifacts
- uses: actions/[email protected]
with:
name: ${{ env.ARTIFACT }}-${{ github.job }}-${{ needs.version.outputs.new_version }}
path: target/artifacts
- name: Make sure build did not change anything
run: git diff --exit-code
linux:
runs-on: ubuntu-latest
needs: version
env:
REVISION: ${{ needs.version.outputs.new_version }}
BUILD_TIMESTAMP: ${{ needs.version.outputs.build_timestamp }}
steps:
- uses: actions/[email protected]
- uses: graalvm/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: graalvm
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Build with Maven
run: |
set -o xtrace
./mvnw \
--batch-mode \
-Dsha1="${GITHUB_SHA}" \
-Drevision="${REVISION}" \
verify
- name: Test executable
run: sh ./src/test/native/test-executable.sh "${{ env.ARTIFACT }}" linux "${{ env.REVISION }}"
- name: Move artifacts
run: |
mkdir target/artifacts
cp target/${{ env.ARTIFACT }}-* target/artifacts
- uses: actions/[email protected]
with:
name: ${{ env.ARTIFACT }}-${{ github.job }}-${{ needs.version.outputs.new_version }}
path: target/artifacts
- name: Make sure build did not change anything
run: git diff --exit-code
windows:
runs-on: windows-latest
needs: version
env:
REVISION: ${{ needs.version.outputs.new_version }}
BUILD_TIMESTAMP: ${{ needs.version.outputs.build_timestamp }}
steps:
- uses: actions/[email protected]
- uses: graalvm/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: graalvm
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Remove WindowsImageHeapProviderFeature
run: '& 7z d "$env:JAVA_HOME\lib\svm\builder\svm.jar" com/oracle/svm/core/windows/WindowsImageHeapProviderFeature.class'
- name: Build with Maven
run: |
.\mvnw --batch-mode -Dsha1="$env:GITHUB_SHA" -Drevision="$env:REVISION" verify
- name: Test executable
run: sh ./src/test/native/test-executable.sh "${{ env.ARTIFACT }}" windows "${{ env.REVISION }}"
- name: Move artifacts
run: |
mkdir target/artifacts
copy target/${{ env.ARTIFACT }}-* target/artifacts
- uses: actions/[email protected]
with:
name: ${{ env.ARTIFACT }}-${{ github.job }}-${{ needs.version.outputs.new_version }}
path: target/artifacts
- name: Make sure build did not change anything
run: git diff --exit-code
release:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [version, macos, linux, windows]
permissions:
contents: write
steps:
- uses: actions/[email protected]
- name: Download all workflow run artifacts
uses: actions/[email protected]
with:
path: ./target
- name: Build project
working-directory: target
run: |
zip -r windows.zip ${{ env.ARTIFACT }}-windows-${{ needs.version.outputs.new_version }}/
zip -r linux.zip ${{ env.ARTIFACT }}-linux-${{ needs.version.outputs.new_version }}/
zip -r macos.zip ${{ env.ARTIFACT }}-macos-${{ needs.version.outputs.new_version }}/
- name: Create Release
id: create_release
uses: ncipollo/[email protected]
with:
tag: v${{ needs.version.outputs.new_version }}
name: Release ${{ needs.version.outputs.new_version }}
body: ${{ needs.version.outputs.changelog }}
draft: true
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/linux.zip
asset_name: ${{ env.ARTIFACT }}-linux-${{ needs.version.outputs.new_version }}.zip
asset_content_type: application/zip
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/${{ env.ARTIFACT }}-linux-${{ needs.version.outputs.new_version }}/${{ env.ARTIFACT }}-linux-${{ needs.version.outputs.new_version }}
asset_name: ${{ env.ARTIFACT }}-linux
asset_content_type: application/x-executable
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/windows.zip
asset_name: ${{ env.ARTIFACT }}-windows-${{ needs.version.outputs.new_version }}.zip
asset_content_type: application/zip
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/${{ env.ARTIFACT }}-windows-${{ needs.version.outputs.new_version }}/${{ env.ARTIFACT }}-windows-${{ needs.version.outputs.new_version }}.exe
asset_name: ${{ env.ARTIFACT }}-windows.exe
asset_content_type: application/vnd.microsoft.portable-executable
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/macos.zip
asset_name: ${{ env.ARTIFACT }}-macos-${{ needs.version.outputs.new_version }}.zip
asset_content_type: application/zip
- name: Upload Release Asset
uses: shogo82148/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/${{ env.ARTIFACT }}-macos-${{ needs.version.outputs.new_version }}/${{ env.ARTIFACT }}-macos-${{ needs.version.outputs.new_version }}
asset_name: ${{ env.ARTIFACT }}-macos
asset_content_type: application/octet-stream
- uses: eregon/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
- name: Make sure build did not change anything
run: git diff --exit-code
deploy:
needs: [version, macos, linux, windows]
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/heads/dependabot/') }}
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
cache: 'maven'
- name: Publish to GitHub Packages Apache Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REVISION: ${{ needs.version.outputs.new_version }}
BUILD_TIMESTAMP: ${{ needs.version.outputs.build_timestamp }}
run: |
./mvnw \
--batch-mode \
-Dsha1="${GITHUB_SHA}" \
-Drevision="${REVISION}" \
-DaltDeploymentRepository="github::default::https://maven.pkg.github.com/${GITHUB_REPOSITORY}" \
deploy
- name: Make sure build did not change anything
run: git diff --exit-code