-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (171 loc) · 7.67 KB
/
release.yml
File metadata and controls
177 lines (171 loc) · 7.67 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
name: Build and Attach Installers on Release
on:
release:
types: [published]
workflow_dispatch: {}
permissions:
contents: write
env:
JAVA_VERSION: '21'
APP_NAME: StudentDataGUI
jobs:
linux:
name: Linux packages (deb, rpm, AppImage)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Install packaging tools
run: |
sudo apt-get update
sudo apt-get install -y rpm libfuse2 zsync
- name: Build JAR
run: mvn -B -U -e -DskipTests package
- name: Resolve meta
id: meta
run: |
set -euo pipefail
VERSION=$(mvn -q -Dexec.cleanupDaemonThreads=false -DforceStdout help:evaluate -Dexpression=project.version)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "vversion=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Find jar
id: jar
run: |
JAR=$(ls -t target/*-shaded.jar 2>/dev/null | head -n1)
if [ -z "$JAR" ]; then JAR=$(ls -t target/*.jar | grep -vE 'sources|original|tests' | head -n1); fi
echo "path=$JAR" >> "$GITHUB_OUTPUT"
echo "file=$(basename "$JAR")" >> "$GITHUB_OUTPUT"
- name: Build deb
run: |
mkdir -p dist/linux/deb
"$JAVA_HOME/bin/jpackage" --type deb --input target --main-jar "${{ steps.jar.outputs.file }}" --name "$APP_NAME" --app-version "${{ steps.meta.outputs.version }}" --icon examples/icons/scatter-plot-256.png --dest dist/linux/deb
f=$(ls -t dist/linux/deb/*.deb | head -n1); if [ -n "$f" ]; then mv "$f" "dist/linux/deb/${APP_NAME}-${{ steps.meta.outputs.vversion }}.deb"; fi
- name: Build rpm
run: |
mkdir -p dist/linux/rpm
"$JAVA_HOME/bin/jpackage" --type rpm --input target --main-jar "${{ steps.jar.outputs.file }}" --name "$APP_NAME" --app-version "${{ steps.meta.outputs.version }}" --icon examples/icons/scatter-plot-256.png --dest dist/linux/rpm
f=$(ls -t dist/linux/rpm/*.rpm | head -n1); if [ -n "$f" ]; then mv "$f" "dist/linux/rpm/${APP_NAME}-${{ steps.meta.outputs.vversion }}.rpm"; fi
- name: Build AppImage
run: |
set -euxo pipefail
APPDIR_ROOT="dist/linux/appimage"
"$JAVA_HOME/bin/jpackage" --type app-image --input target --main-jar "${{ steps.jar.outputs.file }}" --name "$APP_NAME" --app-version "${{ steps.meta.outputs.version }}" --icon examples/icons/scatter-plot-256.png --dest "$APPDIR_ROOT"
pushd "$APPDIR_ROOT"
APPDIR=$(find . -maxdepth 1 -type d -name "*${APP_NAME}*" | head -n1 | sed 's#^./##')
curl -fsSL https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -o appimagetool
chmod +x appimagetool || true
if ./appimagetool --appimage-extract-and-run "$APPDIR"; then
AI=$(ls -t *.AppImage 2>/dev/null | head -n1 || true)
if [ -n "$AI" ]; then mv "$AI" "${APP_NAME}-${{ steps.meta.outputs.vversion }}.AppImage"; fi
echo "Built AppImage"
else
zip -r "${APP_NAME}-${{ steps.meta.outputs.vversion }}-appimage.zip" "$APPDIR"
fi
popd
- name: Upload assets to release
uses: softprops/action-gh-release@v2
with:
files: |
dist/linux/**/*.deb
dist/linux/**/*.rpm
dist/linux/**/*.AppImage
dist/linux/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
windows:
name: Windows MSI
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Build JAR
run: mvn -B -U -e -DskipTests package
- name: Resolve meta
id: meta
shell: bash
run: |
set -euo pipefail
VERSION=$(mvn -q -Dexec.cleanupDaemonThreads=false -DforceStdout help:evaluate -Dexpression=project.version)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "vversion=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Find jar
id: jar
shell: pwsh
run: |
$jar = Get-ChildItem -Path target -Filter "*-shaded.jar" -File | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (-not $jar) { $jar = Get-ChildItem -Path target -Filter "*.jar" -File | Where-Object { $_.Name -notmatch 'sources|original|tests' } | Sort-Object LastWriteTime -Descending | Select-Object -First 1 }
if (-not $jar) { throw "No JAR found in target" }
"path=$($jar.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"file=$($jar.Name)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Build MSI
shell: pwsh
run: |
New-Item -ItemType Directory -Path dist\windows -Force | Out-Null
& "$env:JAVA_HOME\bin\jpackage.exe" `
--type msi `
--input target `
--main-jar "${{ steps.jar.outputs.file }}" `
--name "$env:APP_NAME" `
--app-version "${{ steps.meta.outputs.version }}" `
--icon examples\icons\scatter-plot-256.ico `
--dest dist\windows `
--win-menu --win-shortcut --win-dir-chooser
$msi = Get-ChildItem -Path dist\windows -Filter "*.msi" -File | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($msi) { Move-Item -Path $msi.FullName -Destination ("dist\windows\{0}-{1}.msi" -f $env:APP_NAME, "${{ steps.meta.outputs.vversion }}") -Force }
- name: Upload assets to release
uses: softprops/action-gh-release@v2
with:
files: |
dist/windows/*.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
macos:
name: macOS DMG
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: Build JAR
run: mvn -B -U -e -DskipTests package
- name: Resolve meta
id: meta
run: |
set -euo pipefail
VERSION=$(mvn -q -Dexec.cleanupDaemonThreads=false -DforceStdout help:evaluate -Dexpression=project.version)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "vversion=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Generate .icns
run: |
chmod +x examples/scripts/create-mac-iconset.sh
examples/scripts/create-mac-iconset.sh examples/icons scatter-plot.icns
- name: Find jar
id: jar
run: |
JAR=$(ls -t target/*-shaded.jar 2>/dev/null | head -n1)
if [ -z "$JAR" ]; then JAR=$(ls -t target/*.jar | grep -vE 'sources|original|tests' | head -n1); fi
echo "path=$JAR" >> "$GITHUB_OUTPUT"
echo "file=$(basename "$JAR")" >> "$GITHUB_OUTPUT"
- name: Build DMG
run: |
mkdir -p dist/macos
"$JAVA_HOME/bin/jpackage" --type dmg --input target --main-jar "${{ steps.jar.outputs.file }}" --name "$APP_NAME" --app-version "${{ steps.meta.outputs.version }}" --icon scatter-plot.icns --dest dist/macos
f=$(ls -t dist/macos/*.dmg | head -n1); if [ -n "$f" ]; then mv "$f" "dist/macos/${APP_NAME}-${{ steps.meta.outputs.vversion }}.dmg"; fi
- name: Upload assets to release
uses: softprops/action-gh-release@v2
with:
files: |
dist/macos/*.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}