-
Notifications
You must be signed in to change notification settings - Fork 5
220 lines (182 loc) · 7.19 KB
/
cli-release.yaml
File metadata and controls
220 lines (182 loc) · 7.19 KB
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
# Based on https://blogs.oracle.com/developers/building-cross-platform-native-images-with-graalvm
name: spot
on:
push:
tags:
- "v*"
jobs:
build-jar-job:
name: 'Build JAR'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Setup Java 11'
uses: actions/setup-java@v1
with:
java-version: 11
- name: 'Get Version Number'
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: 'Build JAR'
run: |
./mvnw clean package
- name: 'Publish JAR'
uses: actions/upload-artifact@v2
with:
name: 'spot-${{env.VERSION}}.jar'
path: 'target/spot-${{env.VERSION}}.jar'
- name: 'Create Release'
if: contains(github.ref, 'v')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: Release ${{github.ref}}
body: |
Spotify CLI ${{github.ref}}
draft: false
prerelease: false
- name: 'Upload Release Asset'
if: contains(github.ref, 'v')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: 'target/spot-${{env.VERSION}}.jar'
asset_name: spot-${{env.VERSION}}.jar
asset_content_type: application/java-archive
- name: 'Write Upload URL To File'
if: contains(github.ref, 'v')
run: |
echo "${{steps.create_release.outputs.upload_url}}" > upload_url.txt
- name: 'Publish Upload URL'
if: contains(github.ref, 'v')
uses: actions/upload-artifact@v2
with:
name: 'upload_url.txt'
path: 'upload_url.txt'
build-non-windows-image:
name: 'Build Non-Windows Image'
needs: [build-jar-job]
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest']
include:
- os: 'ubuntu-latest'
label: 'linux'
- os: 'macos-latest'
label: 'mac'
runs-on: ${{matrix.os}}
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Setup Java 11'
uses: actions/setup-java@v1
with:
java-version: 11
- name: 'Setup GraalVM Environment'
uses: DeLaGuardo/setup-graalvm@3.1
with:
graalvm-version: '20.3.0.java11'
- name: 'Install Native Image Plugin'
run: |
gu install native-image
- name: 'Get Version Number'
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: 'Get JAR Artifact'
uses: actions/download-artifact@v2
with:
name: 'spot-${{env.VERSION}}.jar'
- name: 'Get Release URL'
if: contains(github.ref, 'v')
uses: actions/download-artifact@v2
with:
name: 'upload_url.txt'
- name: 'Get Upload URL'
if: contains(github.ref, 'v')
run: |
echo "UPLOAD_URL=$(cat upload_url.txt)" >> $GITHUB_ENV
- name: 'Build Native Image'
run: |
native-image -jar spot-${{env.VERSION}}.jar --report-unsupported-elements-at-runtime --enable-http --enable-https --no-fallback --initialize-at-build-time=org.eclipse.jetty --initialize-at-build-time=org.slf4j --initialize-at-build-time=javax.servlet --allow-incomplete-classpath -H:ReflectionConfigurationResources=reflection.json -H:IncludeResources=reference.conf -H:Class=dev.trietsch.spotify.cli.SpotKt -H:Name=spot-${{env.VERSION}}-${{matrix.label}}
- name: 'Publish Native Image'
if: success()
uses: actions/upload-artifact@v2
with:
name: 'spot-${{env.VERSION}}-${{matrix.label}}'
path: 'spot-${{env.VERSION}}-${{matrix.label}}'
- name: 'Release Native Image Asset'
if: success() && contains(github.ref, 'v')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
with:
upload_url: ${{env.UPLOAD_URL}}
asset_name: 'spot-${{env.VERSION}}-${{matrix.label}}'
asset_path: 'spot-${{env.VERSION}}-${{matrix.label}}'
asset_content_type: application/octet-stream
build-windows-image:
needs: [build-jar-job]
name: 'Build Windows Image'
runs-on: windows-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Download GraalVM'
run: |
Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.3.0/graalvm-ce-java11-windows-amd64-20.3.0.zip -OutFile 'graal.zip'
- name: 'Install GraalVM'
run: |
Expand-Archive -path 'graal.zip' -destinationpath '.'
- name: 'Install Native Image'
run: |
graalvm-ce-java11-20.3.0\bin\gu.cmd install native-image
- name: 'Set up Visual C Build Tools Workload for Visual Studio 2017 Build Tools' # choco install visualstudio2017-workload-vctools
run: |
choco upgrade -y visualstudio2017-workload-vctools
- name: 'Get Version Number'
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
shell: bash
- name: 'Get JAR Artifact'
uses: actions/download-artifact@v2
with:
name: 'spot-${{env.VERSION}}.jar'
- name: 'Build Native Image'
shell: cmd
env:
JAVA_HOME: ./graalvm-ce-java11-20.3.0
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
./graalvm-ce-java11-20.3.0/bin/native-image -jar spot-${{env.VERSION}}.jar --report-unsupported-elements-at-runtime --enable-http --enable-https --no-fallback --initialize-at-build-time=org.eclipse.jetty --initialize-at-build-time=org.slf4j --initialize-at-build-time=javax.servlet --allow-incomplete-classpath -H:ReflectionConfigurationResources=reflection.json -H:IncludeResources=reference.conf -H:Class=dev.trietsch.spotify.cli.SpotKt -H:Name=spot-${{env.VERSION}}-windows
- name: 'Get Release URL'
if: contains(github.ref, 'v')
uses: actions/download-artifact@v2
with:
name: 'upload_url.txt'
- name: 'Get Upload URL'
if: contains(github.ref, 'v')
run: |
echo "UPLOAD_URL=$(cat upload_url.txt)" >> $GITHUB_ENV
shell: bash
- name: 'Publish Windows Image'
if: success()
uses: actions/upload-artifact@v2
with:
name: 'spot-${{env.VERSION}}-windows.exe'
path: 'spot-${{env.VERSION}}-windows.exe'
- name: 'Release Windows Image Asset'
if: success() && contains(github.ref, 'v')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
with:
upload_url: ${{env.UPLOAD_URL}}
asset_name: 'spot-${{env.VERSION}}-windows.exe'
asset_path: 'spot-${{env.VERSION}}-windows.exe'
asset_content_type: application/octet-stream