[18136] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
[18146] | 3 | ## Expected environment, passed from GitHub secrets:
|
---|
| 4 | # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
|
---|
| 5 | # SIGN_CERT PKCS12 certificate keystore used for code signing, base64 encoded
|
---|
| 6 | # SIGN_STOREPASS Password for that keystore
|
---|
| 7 | # SIGN_TSA URL of Time Stamping Authority to use
|
---|
[18136] | 8 |
|
---|
[18146] | 9 | set -Eeo pipefail
|
---|
| 10 |
|
---|
[18136] | 11 | # Don't show one time passwords
|
---|
| 12 | set +x
|
---|
| 13 |
|
---|
| 14 | if [ -z "${1-}" ]
|
---|
| 15 | then
|
---|
| 16 | echo "Usage: $0 josm_revision"
|
---|
| 17 | exit 1
|
---|
| 18 | fi
|
---|
| 19 |
|
---|
[18155] | 20 | echo "Building JOSM Windows Installer packages"
|
---|
[18136] | 21 |
|
---|
| 22 | mkdir app
|
---|
| 23 |
|
---|
[18146] | 24 | if [ -z "$SIGN_CERT" ] || [ -z "$SIGN_STOREPASS" ] || [ -z "$SIGN_TSA" ]
|
---|
| 25 | then
|
---|
| 26 | echo "SIGN_CERT, SIGN_STOREPASS and SIGN_TSA are not set in the environment."
|
---|
[18155] | 27 | echo "A JOSM.exe and JOSM.msi will be created but not signed."
|
---|
[18146] | 28 | SIGNAPP=false
|
---|
| 29 | else
|
---|
| 30 | SIGNAPP=true
|
---|
| 31 | fi
|
---|
| 32 |
|
---|
| 33 | set -u
|
---|
| 34 |
|
---|
[18164] | 35 | # jpackage copies resources files to temp dir but not all of them, only an hardcoded set
|
---|
| 36 | # see https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java#L437
|
---|
| 37 | # so we replace a placeholder to get an absolute path when wix reads this file
|
---|
| 38 | #sed -i "s|%josm-source-dir%|$(pwd)|g" native/windows/main.wxs
|
---|
| 39 | cp native/windows/main.wxs native/windows/main.wxs.bak
|
---|
| 40 | sed -i 's?%josm-source-dir%?'`pwd`'?' native/windows/main.wxs
|
---|
| 41 | sed -i 's?"/c/?"c:/?g' native/windows/main.wxs
|
---|
[18168] | 42 | sed -i 's?"/d/?"d:/?g' native/windows/main.wxs
|
---|
[18164] | 43 |
|
---|
[18136] | 44 | JPACKAGEOPTIONS=""
|
---|
| 45 |
|
---|
[18155] | 46 | echo "Building EXE and MSI"
|
---|
| 47 | for type in exe msi
|
---|
| 48 | do
|
---|
| 49 | jpackage $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
|
---|
[18136] | 50 | --main-class org.openstreetmap.josm.gui.MainApplication \
|
---|
[18155] | 51 | --icon ./native/windows/logo.ico --type $type --dest app \
|
---|
[18161] | 52 | --java-options "--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web" \
|
---|
[18136] | 53 | --java-options "--add-exports=java.base/sun.security.action=ALL-UNNAMED" \
|
---|
| 54 | --java-options "--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED" \
|
---|
| 55 | --java-options "--add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED" \
|
---|
| 56 | --java-options "--add-opens=java.base/java.lang=ALL-UNNAMED" \
|
---|
| 57 | --java-options "--add-opens=java.base/java.nio=ALL-UNNAMED" \
|
---|
| 58 | --java-options "--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED" \
|
---|
| 59 | --java-options "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED" \
|
---|
| 60 | --java-options "--add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED" \
|
---|
| 61 | --java-options "--add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED" \
|
---|
| 62 | --java-options "--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED" \
|
---|
[18138] | 63 | --app-version "1.5.$1" \
|
---|
[18136] | 64 | --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" \
|
---|
[18138] | 65 | --vendor "JOSM" \
|
---|
[18164] | 66 | --resource-dir native/windows \
|
---|
[18163] | 67 | --win-upgrade-uuid 79be9cf4-6dc7-41e2-a6cd-bbfaa4c07481 \
|
---|
[18162] | 68 | --win-per-user-install \
|
---|
| 69 | --win-dir-chooser \
|
---|
[18157] | 70 | --win-shortcut \
|
---|
| 71 | --win-menu \
|
---|
[18312] | 72 | --win-menu-group "JOSM" \
|
---|
[18136] | 73 | --file-associations native/file-associations/bz2.properties \
|
---|
| 74 | --file-associations native/file-associations/geojson.properties \
|
---|
| 75 | --file-associations native/file-associations/gpx.properties \
|
---|
| 76 | --file-associations native/file-associations/gz.properties \
|
---|
| 77 | --file-associations native/file-associations/jos.properties \
|
---|
| 78 | --file-associations native/file-associations/joz.properties \
|
---|
| 79 | --file-associations native/file-associations/osm.properties \
|
---|
[18304] | 80 | --file-associations native/file-associations/xz.properties \
|
---|
[18136] | 81 | --file-associations native/file-associations/zip.properties \
|
---|
[18155] | 82 | --add-launcher HWConsole=native/windows/MLConsole.properties \
|
---|
[18525] | 83 | --add-modules java.compiler,java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,javafx.controls,javafx.media,javafx.swing,javafx.web
|
---|
[18155] | 84 | done
|
---|
[18136] | 85 |
|
---|
[18164] | 86 | mv native/windows/main.wxs.bak native/windows/main.wxs
|
---|
| 87 |
|
---|
[18155] | 88 | mv app/JOSM-1.5.$1.exe app/JOSM.exe
|
---|
[18138] | 89 | mv app/JOSM-1.5.$1.msi app/JOSM.msi
|
---|
| 90 |
|
---|
[18155] | 91 | # Workaround to https://bugs.openjdk.java.net/browse/JDK-8261845
|
---|
| 92 | # to remove after we switch to Java 17+ for jpackage builds
|
---|
| 93 | chmod u+w app/JOSM.exe
|
---|
| 94 |
|
---|
[18136] | 95 | echo "Building done."
|
---|
[18146] | 96 |
|
---|
| 97 | if $SIGNAPP; then
|
---|
| 98 | CERTIFICATE_P12=certificate.p12
|
---|
| 99 | echo "$SIGN_CERT" | base64 --decode > $CERTIFICATE_P12
|
---|
[18155] | 100 | for ext in exe msi
|
---|
| 101 | do
|
---|
| 102 | signtool.exe sign //f $CERTIFICATE_P12 //d "Java OpenStreetMap Editor" //du "https://josm.openstreetmap.de" //p "$SIGN_STOREPASS" //v //fd SHA256 //tr "$SIGN_TSA" //td SHA256 "app/JOSM.$ext"
|
---|
| 103 | done
|
---|
[18146] | 104 | rm $CERTIFICATE_P12
|
---|
| 105 | fi
|
---|