2023-02-17 09:42:30 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
PWD="$(dirname $(readlink -f -- $0))"
|
|
|
|
|
2023-07-12 17:06:10 +03:00
|
|
|
CHANNEL=""
|
2023-02-17 09:42:30 +03:00
|
|
|
DO_SIGN="false"
|
|
|
|
DO_BUNDLE_UPDATE="false"
|
|
|
|
TAURI_PRIVATE_KEY=""
|
|
|
|
TAURI_KEY_PASSWORD=""
|
|
|
|
APPLE_CERTIFICATE=""
|
|
|
|
APPLE_CERTIFICATE_PASSWORD=""
|
|
|
|
APPLE_SIGNING_IDENTITY=""
|
|
|
|
APPLE_ID=""
|
|
|
|
APPLE_PASSWORD=""
|
2023-02-17 16:21:41 +03:00
|
|
|
VERSION=""
|
2023-02-17 09:42:30 +03:00
|
|
|
|
|
|
|
function help() {
|
|
|
|
local to="$1"
|
|
|
|
|
|
|
|
echo "Usage: $0 <flags>" 1>&$to
|
|
|
|
echo 1>&$to
|
|
|
|
echo "flags:" 1>&$to
|
2023-02-17 16:21:41 +03:00
|
|
|
echo " --version release version." 1>&$to
|
2023-02-20 18:17:02 +03:00
|
|
|
echo " --dist path to store artifacts in." 1>&$to
|
2023-02-17 09:42:30 +03:00
|
|
|
echo " --tauri-private-key path or string of tauri updater private key." 1>&$to
|
|
|
|
echo " --tauri-key-password password for tauri updater private key." 1>&$to
|
|
|
|
echo " --apple-certificate base64 string of the .p12 certificate, exported from the keychain." 1>&$to
|
|
|
|
echo " --apple-certificate-password password for the .p12 certificate." 1>&$to
|
|
|
|
echo " --apple-signing-identity the name of the keychain entry that contains the signing certificate." 1>&$to
|
|
|
|
echo " --apple-id the apple id to use for signing." 1>&$to
|
|
|
|
echo " --apple-password the password for the apple id." 1>&$to
|
|
|
|
echo " --sign if set, will sign the app." 1>&$to
|
2023-07-12 17:06:10 +03:00
|
|
|
echo " --channel the channel to use for the release (release | nightly)." 1>&$to
|
2023-02-17 09:42:30 +03:00
|
|
|
echo " --help display this message." 1>&$to
|
|
|
|
}
|
|
|
|
|
|
|
|
function error() {
|
|
|
|
echo "error: $@" 1>&2
|
|
|
|
echo 1>&2
|
|
|
|
help 2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function info() {
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function os() {
|
2023-02-17 14:46:13 +03:00
|
|
|
local os="$(uname -s)"
|
|
|
|
case "$os" in
|
|
|
|
Darwin)
|
|
|
|
echo "macos"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$os: unsupprted"
|
|
|
|
;;
|
|
|
|
esac
|
2023-02-17 09:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function arch() {
|
2023-02-17 14:46:13 +03:00
|
|
|
local arch="$(uname -m)"
|
|
|
|
case "$arch" in
|
|
|
|
arm64)
|
|
|
|
echo "aarch64"
|
|
|
|
;;
|
|
|
|
x86_64)
|
|
|
|
echo "x86_64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "$arch: unsupported architecture"
|
|
|
|
;;
|
|
|
|
esac
|
2023-02-17 09:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ARCH="$(arch)"
|
|
|
|
OS="$(os)"
|
2023-02-20 18:39:43 +03:00
|
|
|
DIST="release"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
|
|
|
function tauri() {
|
2023-02-20 18:39:43 +03:00
|
|
|
(cd "$PWD/.." && pnpm tauri "$@")
|
2023-02-17 09:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case "$1" in
|
|
|
|
--help)
|
|
|
|
help 1
|
|
|
|
exit 1
|
|
|
|
;;
|
2023-02-17 16:21:41 +03:00
|
|
|
--version)
|
|
|
|
VERSION="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2023-02-20 18:17:02 +03:00
|
|
|
--dist)
|
|
|
|
DIST="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2023-02-17 09:42:30 +03:00
|
|
|
--tauri-private-key)
|
|
|
|
TAURI_PRIVATE_KEY="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--tauri-key-password)
|
|
|
|
TAURI_KEY_PASSWORD="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--apple-certificate)
|
|
|
|
APPLE_CERTIFICATE="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--apple-certificate-password)
|
|
|
|
APPLE_CERTIFICATE_PASSWORD="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--apple-signing-identity)
|
|
|
|
APPLE_SIGNING_IDENTITY="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--apple-id)
|
|
|
|
APPLE_ID="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--apple-password)
|
|
|
|
APPLE_PASSWORD="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--sign)
|
|
|
|
DO_SIGN="true"
|
|
|
|
shift
|
|
|
|
;;
|
2023-07-12 17:06:10 +03:00
|
|
|
--channel)
|
|
|
|
CHANNEL="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2023-02-17 09:42:30 +03:00
|
|
|
*)
|
|
|
|
error "unknown flag $1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2023-02-17 16:21:41 +03:00
|
|
|
[ -z "$VERSION" ] && error "--version is not set"
|
|
|
|
|
2023-02-17 09:42:30 +03:00
|
|
|
[ -z "$TAURI_PRIVATE_KEY" ] && error "--tauri-private-key is not set"
|
|
|
|
[ -z "$TAURI_KEY_PASSWORD" ] && error "--tauri-key-password is not set"
|
|
|
|
|
2023-07-12 17:06:10 +03:00
|
|
|
if [ "$CHANNEL" != "release" ] && [ "$CHANNEL" != "nightly" ]; then
|
|
|
|
error "--channel must be either 'release' or 'nightly'"
|
|
|
|
fi
|
|
|
|
|
2023-02-17 09:42:30 +03:00
|
|
|
export TAURI_PRIVATE_KEY="$TAURI_PRIVATE_KEY"
|
|
|
|
export TAURI_KEY_PASSWORD="$TAURI_KEY_PASSWORD"
|
|
|
|
|
|
|
|
if [ "$DO_SIGN" = "true" ]; then
|
|
|
|
[ -z "$APPLE_CERTIFICATE" ] && error "--apple-certificate is not set"
|
|
|
|
[ -z "$APPLE_CERTIFICATE_PASSWORD" ] && error "--apple-certificate-password is not set"
|
|
|
|
[ -z "$APPLE_SIGNING_IDENTITY" ] && error "--apple-signing-identity is not set"
|
|
|
|
[ -z "$APPLE_ID" ] && error "--apple-id is not set"
|
|
|
|
[ -z "$APPLE_PASSWORD" ] && error "--apple-password is not set"
|
|
|
|
|
|
|
|
export APPLE_CERTIFICATE="$APPLE_CERTIFICATE"
|
|
|
|
export APPLE_CERTIFICATE_PASSWORD="$APPLE_CERTIFICATE_PASSWORD"
|
|
|
|
export APPLE_SIGNING_IDENTITY="$APPLE_SIGNING_IDENTITY"
|
|
|
|
export APPLE_ID="$APPLE_ID"
|
|
|
|
export APPLE_PASSWORD="$APPLE_PASSWORD"
|
|
|
|
fi
|
|
|
|
|
2023-02-17 14:46:13 +03:00
|
|
|
info "building:"
|
2023-07-12 17:06:10 +03:00
|
|
|
info " channel: $CHANNEL"
|
2023-02-17 16:21:41 +03:00
|
|
|
info " version: $VERSION"
|
2023-02-17 14:46:13 +03:00
|
|
|
info " os: $OS"
|
|
|
|
info " arch: $ARCH"
|
2023-02-20 18:19:23 +03:00
|
|
|
info " dist: $DIST"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
2023-02-17 16:21:41 +03:00
|
|
|
TMP_DIR="$(mktemp -d)"
|
|
|
|
trap "rm -rf '$TMP_DIR'" exit
|
|
|
|
|
2023-07-12 17:06:10 +03:00
|
|
|
CONFIG_PATH=$(readlink -f "$PWD/../src-tauri/tauri.conf.$CHANNEL.json")
|
|
|
|
|
2023-02-20 18:51:48 +03:00
|
|
|
# update the version in the tauri release config
|
2023-07-12 17:06:10 +03:00
|
|
|
jq '.package.version="'"$VERSION"'"' "$CONFIG_PATH" >"$TMP_DIR/tauri.conf.json"
|
2023-02-17 16:21:41 +03:00
|
|
|
|
2023-02-20 18:51:48 +03:00
|
|
|
# build the app with release config
|
2023-07-18 13:54:11 +03:00
|
|
|
SENTRY_RELEASE="$VERSION" tauri build --verbose --config "$TMP_DIR/tauri.conf.json"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
2023-07-12 17:06:10 +03:00
|
|
|
BUNDLE_DIR=$(readlink -f "$PWD/../src-tauri/target/release/bundle")
|
2023-02-17 09:42:30 +03:00
|
|
|
MACOS_DMG="$(find "$BUNDLE_DIR/dmg" -depth 1 -type f -name "*.dmg")"
|
|
|
|
MACOS_UPDATER="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz")"
|
|
|
|
MACOS_UPDATER_SIG="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz.sig")"
|
|
|
|
|
2023-02-17 16:21:41 +03:00
|
|
|
RELEASE_DIR="$DIST/$OS/$ARCH"
|
2023-02-20 18:17:02 +03:00
|
|
|
mkdir -p "$RELEASE_DIR"
|
2023-02-17 16:21:41 +03:00
|
|
|
cp "$MACOS_DMG" "$RELEASE_DIR"
|
|
|
|
cp "$MACOS_UPDATER" "$RELEASE_DIR"
|
|
|
|
cp "$MACOS_UPDATER_SIG" "$RELEASE_DIR"
|
|
|
|
|
|
|
|
info "built:"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_DMG")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_UPDATER")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_UPDATER_SIG")"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
|
|
|
info "done! bye!"
|