-
Notifications
You must be signed in to change notification settings - Fork 42
254 lines (221 loc) · 8.47 KB
/
deploy.yml
File metadata and controls
254 lines (221 loc) · 8.47 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
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
# This workflow will build a Java project with Apache Ant and:
# - on release: upload the created files to the current release or tag
# - on workflow_dispatch: upload the created files as artifacts to the workflow
name: Java CD with Apache Ant
on:
release:
types: [published]
workflow_dispatch:
branches: [ "master", "devel" ]
permissions:
contents: write
jobs:
# Build and upload NearInfinity.jar
deploy-jar:
if: ${{ github.repository == 'Argent77/NearInfinity' }}
runs-on: ubuntu-latest
name: Build NearInfinity.jar
outputs:
ni_version: ${{ steps.ni-build.outputs.NI_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 1.8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Build with Ant
id: ni-build
run: |
ant -noinput -buildfile build.xml
zip -r NearInfinity.zip NearInfinity.jar
echo "NI_VERSION=$(java -jar "NearInfinity.jar" -version 2>/dev/null | grep -Eo '[0-9]{8}')" >> "$GITHUB_OUTPUT"
# Required internally to build the installer packages
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: NearInfinity-${{ steps.ni-build.outputs.NI_VERSION }}
path: NearInfinity.jar
- name: Upload JAR asset to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: NearInfinity.zip
tag: ${{ github.ref || github.event.release.tag_name }}
asset_name: NearInfinity-${{ steps.ni-build.outputs.NI_VERSION }}.zip
overwrite: true
# Build and upload installer versions for Windows, macOS-x86_64, macOS-arm64, and Linux
deploy-installer:
if: ${{ github.repository == 'Argent77/NearInfinity' }}
needs: deploy-jar
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-15-intel, macos-latest, ubuntu-latest ]
java: [ '21' ]
runs-on: ${{ matrix.os }}
name: Create installer for ${{ matrix.os }}, JDK ${{ matrix.java }}
steps:
# Initializations
- name: Git checkout
uses: actions/checkout@v4
- name: Set up JDK (windows)
if: startsWith(matrix.os, 'windows-')
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Set up JDK (macos)
if: startsWith(matrix.os, 'macos-')
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'oracle'
- name: Set up JRE (linux)
if: startsWith(matrix.os, 'ubuntu-')
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
java-package: 'jre'
- name: Echo JAVA_HOME (windows)
if: startsWith(matrix.os, 'windows-')
run: |
echo $env:JAVA_HOME
java -version
- name: Echo JAVA_HOME (macos/linux)
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
run: |
echo $JAVA_HOME
java -version
# Preparations
- name: Download JAR artifact
uses: actions/download-artifact@v4
with:
name: NearInfinity-${{ needs.deploy-jar.outputs.ni_version }}
path: jar
- name: Set up installer data
uses: actions/checkout@v4
with:
repository: NearInfinityBrowser/NearInfinity-assets
path: assets
# Building
- name: Build portable archive and installer (windows)
if: startsWith(matrix.os, 'windows-')
run: |
move assets\redistributable\windows\package .
move assets\redistributable\windows\build-image.cmd .
move assets\redistributable\windows\build-installer.cmd .
.\build-image.cmd
.\build-installer.cmd
- name: Build installer (macos)
if: startsWith(matrix.os, 'macos-')
run: |
mv assets/redistributable/macos/package .
mv assets/redistributable/macos/build.command .
chmod +x build.command
./build.command
- name: Build AppImage (linux)
if: startsWith(matrix.os, 'ubuntu-')
run: |
mv assets/redistributable/linux/package .
mv assets/redistributable/linux/build.sh .
chmod +x build.sh
./build.sh
# Validation
- name: List built files (windows)
if: startsWith(matrix.os, 'windows-')
run: dir
- name: List built files (macos/linux)
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
run: ls -l
# Uploading artifacts (workflow_dispatch)
- name: Upload portable artifact (windows)
if: startsWith(matrix.os, 'windows-') && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: portable-windows
path: NearInfinity-*.zip
- name: Upload exe artifact (windows)
if: startsWith(matrix.os, 'windows-') && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: installer-windows
path: NearInfinity-*.exe
- name: Upload pkg artifact (macos-x86_64)
if: (matrix.os == 'macos-15-intel') && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: installer-macos-x86_64
path: NearInfinity-*.pkg
- name: Upload pkg artifact (macos-arm64)
if: (matrix.os == 'macos-latest') && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: installer-macos-arm64
path: NearInfinity-*.pkg
- name: Upload appimage artifact (linux)
if: startsWith(matrix.os, 'ubuntu-') && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: installer-linux
path: NearInfinity-*.AppImage
# Uploading assets (release)
- name: Upload portable asset to release (windows)
if: startsWith(matrix.os, 'windows-') && github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: NearInfinity-*.zip
tag: ${{ github.ref || github.event.release.tag_name }}
overwrite: true
- name: Upload exe asset to release (windows)
if: startsWith(matrix.os, 'windows-') && github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: NearInfinity-*.exe
tag: ${{ github.ref || github.event.release.tag_name }}
overwrite: true
- name: Upload pkg asset to release (macos-x86_64)
if: (matrix.os == 'macos-15-intel') && github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: NearInfinity-*.pkg
tag: ${{ github.ref || github.event.release.tag_name }}
overwrite: true
- name: Upload pkg asset to release (macos-arm64)
if: (matrix.os == 'macos-latest') && github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: NearInfinity-*.pkg
tag: ${{ github.ref || github.event.release.tag_name }}
overwrite: true
- name: Upload appimage asset to release (linux)
if: startsWith(matrix.os, 'ubuntu-') && github.event_name == 'release'
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: NearInfinity-*.AppImage
tag: ${{ github.ref || github.event.release.tag_name }}
overwrite: true
# Remove JAR artifact (release)
cleanup:
if: ${{ github.repository == 'Argent77/NearInfinity' && github.event_name == 'release' }}
needs: [deploy-jar, deploy-installer]
runs-on: ubuntu-latest
name: Clean up artifacts
steps:
- uses: actions/checkout@v4
- name: Remove JAR artifact
uses: geekyeggo/delete-artifact@v5
with:
name: NearInfinity-*