@@ -6,11 +6,13 @@ source $(dirname $0)/utils.sh
66
77function print_help() {
88 echo " Script for building Ouisync App in a Docker container"
9- echo " Usage: $0 --host <HOST> (--commit <COMMIT> | --srcdir <SRCDIR>) [--out <OUTPUT_DIRECTORY>]"
9+ echo " Usage: $0 --host <HOST> (--commit <COMMIT> | --srcdir <SRCDIR>) [--out <OUTPUT_DIRECTORY>] [--flavor <FLAVOR>] "
1010 echo " HOST: IP or entry in ~/.ssh/config of machine running Docker"
1111 echo " COMMIT: Commit from which to build"
1212 echo " SRCDIR: Source dir from which to build"
1313 echo " OUTPUT_DIRECTORY: Directory where artifacts will be stored"
14+ echo " FLAVOR: One of {production,nightly,unofficial}. The default is 'production' when '--commit'"
15+ echo " is used and 'unofficial' when '--srcdir' is used"
1416}
1517
1618build_exe=" --exe"
@@ -25,6 +27,7 @@ while [[ "$#" -gt 0 ]]; do
2527 --no-exe) build_exe=' ' ;;
2628 --no-msix) build_msix=' ' ;;
2729 --out) out_dir=" $2 " ; shift ;;
30+ --flavor) flavor=" $2 " ; shift ;;
2831 * ) error " Unknown argument: $1 " ;;
2932 esac
3033 shift
@@ -42,14 +45,26 @@ export DOCKER_BUILDKIT=0
4245
4346out_dir=${out_dir:= ./ releases/ $container_name }
4447
45- # Collect secrets (only sentry DSN on Windows)
48+ # Check dependencies and set flavor
4649if [ -n " $commit " ]; then
4750 check_dependency git
48- secretSentryDSN=$( pass cenoers/ouisync/app/production/sentry_dsn)
49- flavor=production
51+ flavor=${flavor:= production}
5052else
5153 check_dependency rsync
52- flavor=unofficial
54+ flavor=${flavor:= unofficial}
55+ fi
56+
57+ case " $flavor " in
58+ production|nightly|unofficial) ;;
59+ * ) error " Invalid --flavor argument ($flavor )"
60+ esac
61+
62+ # Collect secrets
63+ if [ " $flavor " != " unofficial" ]; then
64+ secretSentryDSN=$( pass cenoers/ouisync/app/$flavor /sentry_dsn)
65+ secretCertHex=$( pass cenoers/ouisync/app/$flavor /windows/private.pfx | xxd -p)
66+ publicCertHex=$( pass cenoers/ouisync/app/$flavor /windows/public.cer | xxd -p)
67+ secretCertPassword=$( pass cenoers/ouisync/app/$flavor /windows/certificatePassword)
5368fi
5469
5570# Build image
@@ -75,10 +90,15 @@ function on_exit() {
7590 dock container rm -f $container_name
7691}
7792
93+ function container_cat() {
94+ exe -i powershell -Command " [Console]::OpenStandardInput().CopyTo([IO.File]::Create(\" $1 \" ))"
95+ }
96+
7897# Prepare secrets
79- if [ " $flavor " = " production " ]; then
80- exe mkdir c:\\ secrets
98+ if [ " $flavor " ! = " unofficial " ]; then
99+ exe mkdir -p c:\\ secrets
81100 exe powershell -Command " Add-Content -Force -Path c:/secrets/sentry_dsn -Value \" $secretSentryDSN \" "
101+ echo $secretCertHex | xxd -p -r | container_cat c:/secrets/private.pfx
82102 sentry_arg=' --sentry=C:/secrets/sentry_dsn'
83103fi
84104
@@ -100,11 +120,21 @@ exe -w c:/ouisync-app/ouisync/bindings/dart dart tool/bindgen.dart
100120exe -w c:/ouisync-app dart pub get
101121exe -w c:/ouisync-app dart run util/release.dart --flavor=$flavor $sentry_arg $build_exe $build_msix
102122
123+ host_out_dir=c:/ouisync-app/releases/latest
124+
125+ # Sign the msix and add public certificate to artifacts
126+ if [ -n " $build_msix " -a " $flavor " != " unofficial" ]; then
127+ msix=$( exe " ls $host_out_dir /*.msix" )
128+ exe -w c:/ouisync-app powershell -Command " util/windows/sign-msix.ps1 -msixPath $msix -pfxPath c:/secrets/private.pfx -certPassword $secretCertPassword "
129+ echo $publicCertHex | xxd -p -r | container_cat $host_out_dir /public.cer
130+ fi
131+
132+ # Collect artifacts
103133function dock_rsync() {
104134 rsync -e " docker -H ssh://$host exec -i" " $@ "
105135}
106136
107137mkdir -p $out_dir
108- for asset in $( exe -w c:/ouisync-app/releases/latest ls) ; do
138+ for asset in $( exe -w $host_out_dir ls) ; do
109139 dock_rsync -av $container_name :/c/ouisync-app/releases/latest/$asset $out_dir
110140done
0 commit comments