-
Notifications
You must be signed in to change notification settings - Fork 44
267 lines (219 loc) · 8.23 KB
/
release_workflow.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
name: Build and Publish Geoweaver App
on:
release:
types:
- published
tags:
- '*'
workflow_dispatch:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11 for x64
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
- name: Run Tests
run: |
mvn test jacoco:report
working-directory: ${{ github.workspace }}
- name: Check Test Results
run: |
if [ $? -eq 0 ]; then
echo "Tests passed successfully."
else
echo "Tests failed."
exit 1 # Exit with an error code to stop the workflow
fi
build-jar:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean install -DskipTests
- name: Install XML parsing tools
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: Extract version from pom.xml
run: |
VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" $GITHUB_WORKSPACE/pom.xml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Append version to DEBIAN/control
run: |
echo "Version: ${{ env.VERSION }}" >> $GITHUB_WORKSPACE/linux-deployment/DEBIAN/control
- name: Set execute permissions for postinst script
run: chmod 755 $GITHUB_WORKSPACE/linux-deployment/DEBIAN/postinst
- name: Copy geoweaver.jar to linux-deployment directory
run: cp $GITHUB_WORKSPACE/target/geoweaver.jar $GITHUB_WORKSPACE/linux-deployment/usr/local/bin/
- name: Make geoweaver.sh executable
run: chmod +x $GITHUB_WORKSPACE/linux-deployment/usr/local/bin/geoweaver.sh
- name: Build deb package
run: |
cd $GITHUB_WORKSPACE/linux-deployment
dpkg-deb --build . geoweaver.deb
- name: Upload Geoweaver Artifacts
uses: actions/upload-artifact@v3
with:
name: geoweaver-artifacts
path: |
target/*.jar
pom.xml
linux-deployment/*.deb
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: geoweaver
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: geoweaver/geoweaver:${{ env.VERSION }}, geoweaver/geoweaver:latest
- name: Logout from Docker
if: always()
run: docker logout
build-windows:
needs: build-jar
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Geoweaver Artifacts
uses: actions/download-artifact@v3
with:
name: geoweaver-artifacts
path: artifact
- name: Prepare Deployment Directory
run: |
cp artifact/target/geoweaver.jar windows-deployment/geoweaver.jar
- name: Install NSIS
run: choco install nsis
- name: Install PyInstaller
run: pip install pyinstaller
- name: Build Executable with PyInstaller
run: pyinstaller windows-deployment/pyinstaller.spec
- name: Build NSIS Installer
run: '& "C:\Program Files (x86)\NSIS\makensis.exe" windows-deployment/installer.nsi'
- name: Upload Windows Installer to Release
uses: actions/upload-artifact@v3
with:
name: geoweaver-windows-installer
path: D:\a\Geoweaver\Geoweaver\windows-deployment\GeoweaverInstaller.exe
build-macos:
needs: build-jar
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Geoweaver Artifacts
uses: actions/download-artifact@v3
with:
name: geoweaver-artifacts
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build .app file
run: |
chmod +x ${GITHUB_WORKSPACE}/macos-deployment/make-app.sh
${GITHUB_WORKSPACE}/macos-deployment/make-app.sh
- name: Create .dmg file with Applications shortcut
run: |
APP_NAME="Geoweaver"
DMG_TEMP_DIR="${GITHUB_WORKSPACE}/dmg_temp"
mkdir -p "${DMG_TEMP_DIR}"
cp -r "${GITHUB_WORKSPACE}/geoweaver.app" "${DMG_TEMP_DIR}"
ln -s /Applications "${DMG_TEMP_DIR}/Applications"
df -h
hdiutil create -volname "$APP_NAME" -srcfolder "${DMG_TEMP_DIR}" -ov -format UDZO -fs HFS+ "${GITHUB_WORKSPACE}/${APP_NAME}.dmg"
- name: Upload .dmg file as an artifact
uses: actions/upload-artifact@v3
with:
name: geoweaver-dmg
path: /Users/runner/work/Geoweaver/Geoweaver/Geoweaver.dmg
release:
needs: [build-jar, build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- name: Install XML parsing tools
run: sudo apt-get update && sudo apt install libxml2-utils
- name: Install jq
run: sudo apt-get install jq
- name: Download Geoweaver Artifacts
uses: actions/download-artifact@v3
with:
name: geoweaver-artifacts
- name: Download .dmg file
uses: actions/download-artifact@v3
with:
name: geoweaver-dmg
- name: Download Windows Installer Artifact
uses: actions/download-artifact@v3
with:
name: geoweaver-windows-installer
- name: Get ID and upload URL of the latest release
run: |
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/latest")
UPLOAD_URL=$(echo "$RESPONSE" | jq -r .upload_url)
RELEASE_ID=$(echo "$RESPONSE" | jq -r .id)
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
- name: Set release title to version
run: |
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }} \
-d '{"name": "${{ env.VERSION }}"}'
- name: Upload JAR Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: /home/runner/work/Geoweaver/Geoweaver/target/geoweaver.jar
asset_name: geoweaver.jar
asset_content_type: application/java-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload DEB Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: /home/runner/work/Geoweaver/Geoweaver/linux-deployment/geoweaver.deb
asset_name: geoweaver.deb
asset_content_type: application/vnd.debian.binary-package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload .dmg file to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: Geoweaver.dmg
asset_name: Geoweaver.dmg
asset_content_type: application/x-diskcopy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows Installer to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: GeoweaverInstaller.exe
asset_name: GeoweaverInstaller.exe
asset_content_type: application/vnd.microsoft.portable-executable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}