JA
apps/winzik / tools / release.sh · commit 6576d6f
#!/usr/bin/env bash# A new version of WinZik for the computers and the phones: the executables, the Android app (WinZik-android-<version>.apk),# their signed update.json (the installed WinZik reads it and updates itself, the phone app offers its new APK:# src/Core/AutoUpdate.php), the installers, a release v<version> on git.jumphp.net with them, then installer/update.json# and android/app.json (its versionCode) committed and pushed (what the installed programs read). Bump project.yaml version first.#   apps/winzik/tools/release.sh "the notes"                        (from anywhere)#   apps/winzik/tools/release.sh --sans-installateur "the notes"    an update only: the executables + update.json (the#                                                                    installed WinZik take it), the installers of before stay#   apps/winzik/tools/release.sh --sans-android "the notes"          no APK this time (the phones are not told of it)set -euo pipefailAPP="$(cd "$(dirname "$0")/.." && pwd)"ROOT="$(cd "$APP/../.." && pwd)"cd "$ROOT"INSTALLERS=1ANDROID=1while [ $# -gt 0 ]; do  case "$1" in    --sans-installateur) INSTALLERS=0; shift ;;    --sans-android) ANDROID=0; shift ;;    *) break ;;  esacdoneNOTES="${1:-}"VERSION="$(sed -n 's/^  version: *\([0-9.]*\).*/\1/p' "$APP/config/project.yaml" | head -1)"REPO=duchnoun/winzikBASE="https://git.jumphp.net/$REPO/releases/download/v$VERSION"KEYS="${JUMPHP_HOME:-$HOME/.jumphp}/keys"APK=""          # the phone app of this release, once built (its update.json entry: platform "android")EXTRA=""mkdir -p "$KEYS"echo "==> WinZik $VERSION"git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$" && { echo "v$VERSION exists: bump config/project.yaml version" >&2; exit 1; }sign() { docker run --rm --user "$(id -u):$(id -g)" -v "$ROOT:/workspace" -v "$KEYS:/keys" -w /workspace "${JUMPHP_DESKTOP_IMAGE:-jumphp/desktop:dev}" \  php tools/app-release.php apps/winzik /keys/winzik-update.pem "$BASE" "$NOTES" linux-x86_64,windows-x86_64 "$EXTRA"; }# the executables and the APK carry config/update.pub: the key exists before they are made (the first time it is made here)if [ ! -f "$APP/config/update.pub" ]; then sign >/dev/null 2>&1 || true; fi[ -f "$APP/config/update.pub" ] || { echo "no config/update.pub" >&2; exit 1; }bin/jumphp export:standalone winzik --linux --windowsif [ "$ANDROID" = 1 ]; then  # the Android app (versionCode + 1 in android/app.json), named as the release gives it  bin/jumphp android winzik --local --version-name "$VERSION"  CODE="$(sed -nE 's/^ *"versionCode": *([0-9]+).*/\1/p' "$APP/android/app.json")"  APK="$APP/dist/android-native/WinZik-android-$VERSION.apk"  cp "$APP/dist/android-native/winzik-$VERSION.apk" "$APK"  EXTRA="android=apps/winzik/dist/android-native/WinZik-android-$VERSION.apk;versionCode=$CODE"fi# the signed update.json (JumPHP's tools/app-release.php: the key stays in ~/.jumphp/keys, its public half in config/update.pub)signcp "$APP/dist/standalone/update.json" "$APP/installer/update.json"if [ "$INSTALLERS" = 1 ]; then bin/jumphp installer winzik --standalone --linux --windows --no-build; fiSA="$APP/dist/standalone"; IN="$APP/dist/installer"SDL_VIDEODRIVER=dummy SDL_RENDER_DRIVER=software SDL_AUDIODRIVER=dummy timeout 8 "$SA/winzik-linux-x86_64" >/dev/null 2>&1 || [ $? = 124 ] || { echo "the Linux executable does not run" >&2; exit 1; }FILES=("$SA/winzik-windows-x86_64.exe" "$SA/winzik-linux-x86_64" "$SA/update.json")if [ -n "$APK" ]; then FILES+=("$APK"); fiif [ "$INSTALLERS" = 1 ]; then FILES=("$IN/WinZik-setup.exe" "$IN/WinZik-setup-linux-x86_64" "${FILES[@]}"); fitools/bin/gh release create "v$VERSION" -R "$REPO" --title "WinZik $VERSION" --notes "${NOTES:-WinZik $VERSION}" --target main "${FILES[@]}"git add "$APP/installer/update.json" "$APP/config/update.pub"if [ -n "$APK" ]; then git add "$APP/android/app.json"; figit commit -q -m "WinZik $VERSION: update.json (the installed programs and the phone app update themselves)"git push -q origin HEAD:mainecho "==> done: https://git.jumphp.net/$REPO/releases/tag/v$VERSION"