-
Notifications
You must be signed in to change notification settings - Fork 293
executable file
·237 lines (213 loc) · 12.7 KB
/
build-installer.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
name: Build installers
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ env.WEASIS_VERSION }}
cleanversion: ${{ env.WEASIS_CLEAN_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK for compilation
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '22'
cache: 'maven'
- name: Build with Maven
shell: bash
run: |
mvn -B clean install
mvn -B -P compressXZ -f weasis-distributions clean package
- name: Retrieve version
shell: bash
run: |
FVERSION=$(awk -F'[<>]' '/<revision>/{print $3}' weasis-parent/pom.xml)$(awk -F'[<>]' '/<changelist>/{print $3}' weasis-parent/pom.xml)
echo "WEASIS_VERSION=${FVERSION}" >> $GITHUB_ENV
- name: Set compatible version
shell: bash
run: |
CVERSION=$(echo $WEASIS_VERSION | sed -e 's/"//g' -e 's/-.*//')
echo "WEASIS_CLEAN_VERSION=${CVERSION}" >> $GITHUB_ENV
- name: Upload the weasis package for building the native distribution
uses: actions/upload-artifact@v4
with:
name: weasis-native-${{ env.WEASIS_VERSION }}
path: weasis-distributions/target/native-dist/weasis-native.zip
jpackage:
env:
JDK_MODULES: "java.base,java.compiler,java.datatransfer,java.net.http,java.desktop,java.logging,java.management,java.prefs,java.xml,jdk.localedata,jdk.charsets,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported,jdk.jdwp.agent,java.sql"
NAME: "Weasis"
IDENTIFIER: "org.weasis.launcher"
WEASIS_INPUT: "native-dist/weasis-native/bin-dist"
WEASIS_OUTPUT: "output-dist"
WEASIS_INPUT_BIN: "native-dist/weasis-native/bin-dist/weasis"
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, platform: x64, wsystem: linux, warc: x86-64 }
- { os: macos-13, platform: x64, wsystem: macosx, warc: x86-64 }
- { os: macos-latest, platform: arm64, wsystem: macosx, warc: aarch64 }
- { os: windows-latest, platform: x64, wsystem: windows, warc: x86-64 }
steps:
- name: Set output version from build
shell: bash
run: |
echo ${{needs.build.outputs.version}}
echo ${{needs.build.outputs.cleanversion}}
echo "WEASIS_VERSION=${{needs.build.outputs.version}}" >> $GITHUB_ENV
echo "WEASIS_CLEAN_VERSION=${{needs.build.outputs.cleanversion}}" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '22'
- name: Download weasis-native
uses: actions/download-artifact@v4
with:
name: weasis-native-${{ env.WEASIS_VERSION }}
path: native-dist
- name: Unzip the native package version
shell: bash
run: |
unzip -o "native-dist/weasis-native.zip" -d "native-dist/weasis-native"
- name: Remove binaries not related to the current architecture
shell: bash
run: |
# Remove pack jar for launcher
rm -f ${{ env.WEASIS_INPUT_BIN }}/*.jar.pack.gz
# Remove the unrelated native packages
find ${{ env.WEASIS_INPUT_BIN }}/bundle/weasis-opencv-core-* -type f ! -name *weasis-opencv-core-${{ matrix.wsystem }}-${{ matrix.warc }}-* -exec rm -f {} \;
# Special case with 32-bit architecture, remove 64-bit lib
if [ "${{ matrix.warc }}" = "x86" ] ; then
rm -f ${{ env.WEASIS_INPUT_BIN }}/bundle/weasis-opencv-core-${{ matrix.wsystem }}-x86-64-*
fi
echo "$(ls ${{ env.WEASIS_INPUT_BIN }}/bundle/)"
- name: Import Developer Certificate
uses: apple-actions/import-codesign-certs@v3
if: matrix.wsystem == 'macosx'
id: cert
with:
p12-file-base64: ${{ secrets.MACOS_CERTIFICATE_DEVELOPMENT }}
p12-password: ${{ secrets.MACOS_CERTIFICATE_PWD }}
- name: Import Installer Certificate
uses: apple-actions/import-codesign-certs@v3
if: matrix.wsystem == 'macosx'
with:
create-keychain: "false"
keychain-password: ${{ steps.cert.outputs.keychain-password }}
p12-file-base64: ${{ secrets.MACOS_CERTIFICATE_INSTALLER }}
p12-password: ${{ secrets.MACOS_CERTIFICATE_PWD }}
- name: Build app binary with jpackage
shell: bash
env:
RES: "native-dist/weasis-native/build/script/resources/${{ matrix.wsystem }}"
run: |
machine=${{ matrix.wsystem }}
if [ "$machine" = "macosx" ] ; then
mkdir jar_contents
unzip "${{ env.WEASIS_INPUT_BIN }}"/weasis-launcher.jar -d jar_contents
codesign --force --deep --timestamp --sign "${{ secrets.MACOS__DEVELOPER_ID }}" -vvv --keychain "$HOME/Library/Keychains/signing_temp.keychain-db" jar_contents/com/formdev/flatlaf/natives/libflatlaf-macos-arm64.dylib
codesign --force --deep --timestamp --sign "${{ secrets.MACOS__DEVELOPER_ID }}" -vvv --keychain "$HOME/Library/Keychains/signing_temp.keychain-db" jar_contents/com/formdev/flatlaf/natives/libflatlaf-macos-x86_64.dylib
jar cfv weasis-launcher.jar -C jar_contents .
mv -f weasis-launcher.jar "${{ env.WEASIS_INPUT_BIN }}"/weasis-launcher.jar
rm -rf jar_contents
declare -a customOptions=("--java-options" "-splash:\$APPDIR/resources/images/about-round.png" "--java-options" "-Dapple.laf.useScreenMenuBar=true" "--java-options" "-Dapple.awt.application.appearance=NSAppearanceNameDarkAqua")
declare -a signArgs=("--mac-package-identifier" "${{ env.IDENTIFIER }}" "--mac-signing-keychain" "$HOME/Library/Keychains/signing_temp.keychain-db" "--mac-sign")
elif [ "$machine" = "windows" ] ; then
declare -a customOptions=("--java-options" "-splash:\$APPDIR\resources\images\about-round.png" )
declare -a signArgs=()
else
declare -a customOptions=("--java-options" "-splash:\$APPDIR/resources/images/about-round.png" )
declare -a signArgs=()
fi
declare -a commonOptions=("--java-options" "-Dgosh.port=17179" \
"--java-options" "-Djavax.accessibility.assistive_technologies=org.weasis.launcher.EmptyAccessibilityProvider" \
"--java-options" "-Djavax.accessibility.screen_magnifier_present=false" \
"--java-options" "--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED" "--java-options" "--add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED" \
"--java-options" "--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED" "--java-options" "--add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED" \
"--java-options" "--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" "--java-options" "--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED" \
"--java-options" "--add-opens=java.base/java.net=ALL-UNNAMED" "--java-options" "--add-opens=java.base/java.lang=ALL-UNNAMED" \
"--java-options" "--add-opens=java.base/java.security=ALL-UNNAMED" "--java-options" "--add-opens=java.base/java.io=ALL-UNNAMED" \
"--java-options" "--add-opens=java.desktop/javax.imageio.stream=ALL-UNNAMED" "--java-options" "--add-opens=java.desktop/javax.imageio=ALL-UNNAMED" \
"--java-options" "--add-opens=java.desktop/com.sun.awt=ALL-UNNAMED" )
jpackage --type app-image --input "${{ env.WEASIS_INPUT_BIN }}" --dest "${{ env.WEASIS_OUTPUT }}" --name "${{ env.NAME }}" \
--main-jar weasis-launcher.jar --main-class org.weasis.launcher.AppLauncher --add-modules "${{ env.JDK_MODULES }}" \
--resource-dir "${{ env.RES }}" --app-version "${{ env.WEASIS_CLEAN_VERSION }}" --add-launcher "Dicomizer=${{ env.RES }}/dicomizer-launcher.properties" \
"${signArgs[@]}" "${customOptions[@]}" "${commonOptions[@]}"
if [ "$machine" = "macosx" ] ; then
codesign --timestamp --entitlements "${{ env.RES }}/uri-launcher.entitlements" --options runtime --force -vvv --keychain "$HOME/Library/Keychains/signing_temp.keychain-db" --sign "${{ secrets.MACOS__DEVELOPER_ID }}" "${{ env.WEASIS_OUTPUT }}/${{ env.NAME }}.app"
fi
echo "$(ls -la ${{ env.WEASIS_OUTPUT }})"
- name: Build package with jpackage
shell: bash
env:
RES: "native-dist/weasis-native/build/script/resources/${{ matrix.wsystem }}"
FILE_ASSOC: "native-dist/weasis-native/build/script/file-associations.properties"
VENDOR: "Weasis Team"
COPYRIGHT: "© 2009-2024 Weasis Team"
run: |
mkdir -p final-dist
machine=${{ matrix.wsystem }}
ARC_NAME=${{ matrix.warc }}
if [ "$machine" = "windows" ] ; then
[ "$ARC_NAME" = "x86" ] && UPGRADE_UID="3aedc24e-48a8-4623-ab39-0c3c01c7383b" || UPGRADE_UID="3aedc24e-48a8-4623-ab39-0c3c01c7383a"
jpackage --type "msi" --app-image "${{ env.WEASIS_OUTPUT }}/${{ env.NAME }}" --dest "${{ env.WEASIS_OUTPUT }}" --name "${{ env.NAME }}" --resource-dir "${{ env.RES }}/msi/${ARC_NAME}" \
--license-file "${{ env.WEASIS_INPUT }}/Licence.txt" --description "Weasis DICOM viewer" --win-upgrade-uuid "$UPGRADE_UID" \
--win-menu --win-menu-group "${{ env.NAME }}" --copyright "${{ env.COPYRIGHT }}" --app-version "${{ env.WEASIS_CLEAN_VERSION }}" \
--vendor "${{ env.VENDOR }}" --file-associations "${{ env.FILE_ASSOC }}" --verbose
cp ${{ env.WEASIS_OUTPUT }}/*.msi final-dist/${{ env.NAME }}-${{ env.WEASIS_CLEAN_VERSION }}-${ARC_NAME}.msi
elif [ "$machine" = "linux" ] ; then
if [ "${ARC_NAME}" = "x86" ] ; then
declare -a installerTypes=("deb")
else
declare -a installerTypes=("deb" "rpm")
fi
for installerType in ${installerTypes[@]}; do
[ "${installerType}" = "rpm" ] && DEPENDENCIES="" || DEPENDENCIES="libstdc++6, libgcc1"
jpackage --type "${installerType}" --app-image "${{ env.WEASIS_OUTPUT }}/${{ env.NAME }}" --dest "${{ env.WEASIS_OUTPUT }}" --name "${{ env.NAME }}" --resource-dir "${{ env.RES }}" \
--license-file "${{ env.WEASIS_INPUT }}/Licence.txt" --description "Weasis DICOM viewer" --vendor "${{ env.VENDOR }}" \
--copyright "${{ env.COPYRIGHT }}" --app-version "${{ env.WEASIS_CLEAN_VERSION }}" --file-associations "${{ env.FILE_ASSOC }}" \
--linux-app-release "1" --linux-package-name "weasis" --linux-deb-maintainer "Nicolas Roduit" --linux-rpm-license-type "EPL-2.0" \
--linux-menu-group "Viewer;MedicalSoftware;Graphics;" --linux-app-category "science" --linux-package-deps "${DEPENDENCIES}" --linux-shortcut --verbose
cp ${{ env.WEASIS_OUTPUT }}/*.${installerType} final-dist
done
elif [ "$machine" = "macosx" ] ; then
# Do not set verbose for public build
jpackage --type "pkg" --app-image "${{ env.WEASIS_OUTPUT }}/${{ env.NAME }}.app" --dest "${{ env.WEASIS_OUTPUT }}" --name "${{ env.NAME }}" --resource-dir "${{ env.RES }}" \
--license-file "${{ env.WEASIS_INPUT }}/Licence.txt" --copyright "${{ env.COPYRIGHT }}" --app-version "${{ env.WEASIS_CLEAN_VERSION }}" --mac-package-identifier "${{ env.IDENTIFIER }}" \
--mac-signing-keychain "$HOME/Library/Keychains/signing_temp.keychain-db" --mac-sign
cp ${{ env.WEASIS_OUTPUT }}/*.pkg final-dist/${{ env.NAME }}-${{ env.WEASIS_CLEAN_VERSION }}-${ARC_NAME}.pkg
fi
echo "APP_ARTIFACT=weasis-${machine}-${ARC_NAME}-${{ env.WEASIS_CLEAN_VERSION }}" >> $GITHUB_ENV
- name: "Notarize Release Build"
if: matrix.wsystem == 'macosx'
run: |
xcrun notarytool submit \
"final-dist/${{ env.NAME }}-${{ env.WEASIS_CLEAN_VERSION }}-${{ matrix.warc }}.pkg" \
--apple-id "${{ secrets.APPLE_DEVELOPER_AC_USERNAME }}" \
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
--password "${{ secrets.WEASIS_PWD }}" \
--wait
- name: "Staple Release Build"
if: matrix.wsystem == 'macosx'
run: |
xcrun stapler staple \
"final-dist/${{ env.NAME }}-${{ env.WEASIS_CLEAN_VERSION }}-${{ matrix.warc }}.pkg"
- name: "Add checksum sha256 file"
shell: bash
run: |
for file in "final-dist/*"; do
if [[ -f "$file" ]]; then
sha256sum "$file" >> "$file.sha256"
fi
done
- name: Upload the installer
uses: actions/upload-artifact@v4
with:
name: ${{ env.APP_ARTIFACT }}
path: final-dist