Skip to content

Commit f94c549

Browse files
committed
Signing packages scripts
1 parent 76e6aad commit f94c549

File tree

4 files changed

+57
-32
lines changed

4 files changed

+57
-32
lines changed

jpackage/cli.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
java-options=-DnoGui
1+
java-options=--add-opens java.base/java.nio=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED -DnoGui
22
win-console=true

jpackage/run_jpackage.sh

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ case "${unameOut}" in
1515
Darwin*) machine=mac;;
1616
CYGWIN*) machine=win;;
1717
MINGW*) machine=win;;
18-
MSYS_NT*) machine=win;;
1918
*) machine="UNKNOWN:${unameOut}"
2019
esac
2120
echo Machine type detected ${machine}
@@ -34,16 +33,16 @@ fi
3433

3534
export MSYS_NO_PATHCONV=1
3635

37-
WINDOWS_UUID="c71564cd-5068-4d6d-874b-6a189abd40d3"
36+
WINDOWS_UUID="${windows.uuid}"
3837
STAGING_DIR="${staging.dir}"
3938
APP_NAME="${project.name}"
4039
DESCRIPTION="${project.description}"
4140
MAIN_JAR="${main.jar.name}"
4241
MAIN_CLASS="pmedit.Main"
4342
APP_VERSION="${project.version}"
4443
ICON_FORMAT="${icon.format}"
45-
DEST_DIR=target/packages
46-
DEST_IMAGE_DIR=target/packages-image
44+
DEST_DIR="${STAGING_DIR}/packages"
45+
DEST_IMAGE_DIR="${STAGING_DIR}/packages-image"
4746
APP_IMAGE_DIR="${DEST_IMAGE_DIR}/${APP_NAME}/"
4847

4948
if [ "$TYPE" = "app-image" ]; then
@@ -63,12 +62,14 @@ JP_OPTS="$JP_OPTS --description '$DESCRIPTION'"
6362
if [ "$TYPE" = "app-image" -o "$machine" = "mac" ]; then
6463
JP_OPTS="$JP_OPTS --input '${STAGING_DIR}/jpackage'"
6564
JP_OPTS="$JP_OPTS --main-class '$MAIN_CLASS'"
65+
JP_OPTS="$JP_OPTS --java-options '--add-opens java.base/java.nio=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED'"
6666
JP_OPTS="$JP_OPTS --main-jar '$MAIN_JAR'"
6767
JP_OPTS="$JP_OPTS --add-launcher 'Batch ${APP_NAME}=${STAGING_DIR}/jpackage-scripts/batch-launcher.properties'"
6868
JP_OPTS="$JP_OPTS --add-launcher 'pmedit-cli=${STAGING_DIR}/jpackage-scripts/cli.properties'"
6969
JP_OPTS="$JP_OPTS --runtime-image '${STAGING_DIR}/preparedJDK'"
7070
JP_OPTS="$JP_OPTS --dest '${DEST_IMAGE_DIR}'"
7171
fi
72+
7273
if [ "$TYPE" != "app-image" -a "$machine" != "mac" ]; then
7374
JP_OPTS="$JP_OPTS --file-associations 'jpackage/file-associations.properties'"
7475
JP_OPTS="$JP_OPTS --dest '${DEST_DIR}'"
@@ -103,17 +104,14 @@ set -x
103104
eval jpackage $JP_OPTS
104105

105106
ls -la ${STAGING_DIR}/packages/
106-
ls -la $DEST_IMAGE_DIR
107+
ls -la ${DEST_IMAGE_DIR}
107108

108109

109110
#if [ "$machine" = "mac" -a "$TYPE" = "app-image" ]; then
110111
# (cd ${DEST_IMAGE_DIR}; zip -r "../packages/PdfMetadataEditor.app.zip" Pdf\ Metadata\ Editor.app/)
111112
# zip -r "${STAGING_DIR}/packages/$APP_NAME.app.zip" target/packages/
112113
#fi
113114

114-
ls -la ${STAGING_DIR}/packages/
115-
ls -la $DEST_IMAGE_DIR
116-
117115
set +x
118116
### Handle linux deliveries
119117
if [ "${machine}" = "linux" ]; then
@@ -136,14 +134,15 @@ if [ "${machine}" = "win" ]; then
136134
else
137135
SIGNTOOL=$(which signtool)
138136
fi
139-
echo SIGNTOOL is "${SIGNTOOL}"
140137

141-
if [ ! -f "$SIGNTOOL_PFX" ]; then
142-
echo "$SIGNTOOL_PFX" not found, trying to create it from SIGNTOOL_CERT env
143-
if [ "$SIGNTOOL_CERT" ]; then
144-
echo "$SIGNTOOL_CERT" | base64 -d > "$SIGNTOOL_PFX"
145-
else
146-
echo "SIGNTOOL_CERT not set"
138+
if [ -z "$CERTUM_SHA" ]; then
139+
if [ ! -f "$SIGNTOOL_PFX" ]; then
140+
echo "$SIGNTOOL_PFX" not found, trying to create it from SIGNTOOL_CERT env
141+
if [ "$SIGNTOOL_CERT" ]; then
142+
echo "$SIGNTOOL_CERT" | base64 -d > "$SIGNTOOL_PFX"
143+
else
144+
echo "SIGNTOOL_CERT not set"
145+
fi
147146
fi
148147
fi
149148

@@ -154,25 +153,29 @@ if [ "${machine}" = "win" ]; then
154153
DESC=$1
155154
FILE=$2
156155
echo ">>> Signing '$FILE' with signtool"
156+
if [ -z "${SIGNTOOL}" ]; then
157+
echo "!!!!!!!!! SKIP: no SIGNTOOL found"
158+
fi
157159
chmod a+w "$FILE"
158-
set -x
159-
"${SIGNTOOL}" sign /f jpackage/cert/win-cert.pfx /p 123456 /d "$DESC" /v /fd SHA256 /tr "http://timestamp.sectigo.com" /td SHA256 "$FILE"
160-
set +x
161-
}
162-
163-
if [ "$TYPE" = "app-image" ]; then
164-
if [ "${SIGNTOOL}" ]; then
165-
echo "====== Signing individual executables in app-image"
166-
OIFS="$IFS"
167-
IFS=$'\n'
168-
for file in $(find "${APP_IMAGE_DIR}" -type f -name "*.exe"); do
169-
signtool_file "$APP_NAME" "$file"
170-
done
171-
IFS="$OIFS"
172-
echo "====== Done signing individual executables in app-image"
160+
file "$FILE"
161+
if [ -z "$CERTUM_SHA" ]; then
162+
set -x
163+
"${SIGNTOOL}" sign /f jpackage/cert/win-cert.pfx /p 123456 /d "$DESC" /v /fd SHA256 /tr "http://timestamp.sectigo.com" /td SHA256 "$FILE"
164+
set +x
173165
else
174-
echo "====== SKIP signing individual executables in app-image, no SIGNTOOL defined"
166+
set -x
167+
"${SIGNTOOL}" sign /sha1 "$CERTUM_SHA" /tr http://time.certum.pl /td sha256 /fd sha256 /v "$FILE"
168+
set +x
175169
fi
170+
}
171+
172+
if [ "$TYPE" = "app-image" -a "${SIGNTOOL}" ]; then
173+
OIFS="$IFS"
174+
IFS=$'\n'
175+
for file in $(find "${APP_IMAGE_DIR}" -type f -name "*.exe"); do
176+
signtool_file "$APP_NAME" "$file"
177+
done
178+
IFS="$OIFS"
176179
fi
177180

178181
if [ "$TYPE" = "msi" ]; then

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<snakeyaml.path>${org.yaml:snakeyaml:jar}</snakeyaml.path>
3030
<main.file.name>${project.artifactId}-${project.version}</main.file.name>
3131
<main.jar.name>${main.file.name}.jar</main.jar.name>
32+
<windows.uuid>c71564cd-5068-4d6d-874b-6a189abd40d3</windows.uuid>
3233
<packages.list></packages.list>
3334
<icon.format></icon.format>
3435
<archive.format>zip</archive.format>
@@ -238,6 +239,7 @@
238239
<nonFilteredFileExtensions>
239240
<nonFilteredFileExtension>jar</nonFilteredFileExtension>
240241
<nonFilteredFileExtension>icns</nonFilteredFileExtension>
242+
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
241243
</nonFilteredFileExtensions>
242244
<resources>
243245
<resource>
@@ -262,6 +264,7 @@
262264
<nonFilteredFileExtension>icns</nonFilteredFileExtension>
263265
<nonFilteredFileExtension>ico</nonFilteredFileExtension>
264266
<nonFilteredFileExtension>png</nonFilteredFileExtension>
267+
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
265268
</nonFilteredFileExtensions>
266269
<resources>
267270
<resource>

upload-packages.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ -z "$PUBLISH_VERSION" ]; then
4+
echo env PUBLISH_VERSION must be set when using this script
5+
exit 1
6+
fi
7+
8+
UPLOAD_FILES=("target/packages/Pdf Metadata Editor-${PUBLISH_VERSION}.msi")
9+
10+
for f in "${UPLOAD_FILES[@]}"; do
11+
extension="${f##*.}"
12+
target="pmc/pdf-metadata-editor/release-files/$PUBLISH_VERSION/release.${extension}"
13+
if mc stat $target > /dev/null ; then
14+
echo $target already exists, skipping
15+
else
16+
echo Uploading $f as $target
17+
mc cp "$f"
18+
fi
19+
done

0 commit comments

Comments
 (0)