2023-02-17 09:42:30 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
2024-07-09 17:18:49 +03:00
|
|
|
PWD="$(dirname "$(readlink -f -- "$0")")"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
2023-07-12 17:06:10 +03:00
|
|
|
CHANNEL=""
|
2023-02-17 09:42:30 +03:00
|
|
|
DO_SIGN="false"
|
2023-02-17 16:21:41 +03:00
|
|
|
VERSION=""
|
2023-02-17 09:42:30 +03:00
|
|
|
|
|
|
|
function help() {
|
2024-07-09 17:18:49 +03:00
|
|
|
local to
|
|
|
|
to="$1"
|
|
|
|
|
|
|
|
echo "Usage: $0 <flags>" 1>&"$to"
|
|
|
|
echo 1>&"$to"
|
|
|
|
echo "flags:" 1>&"$to"
|
|
|
|
echo " --version release version." 1>&"$to"
|
|
|
|
echo " --dist path to store artifacts in." 1>&"$to"
|
|
|
|
echo " --sign if set, will sign the app." 1>&"$to"
|
|
|
|
echo " --channel the channel to use for the release (release | nightly)." 1>&"$to"
|
|
|
|
echo " --help display this message." 1>&"$to"
|
2023-02-17 09:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function error() {
|
2024-07-09 17:18:49 +03:00
|
|
|
echo "error: $*" 1>&2
|
2023-02-17 09:42:30 +03:00
|
|
|
echo 1>&2
|
|
|
|
help 2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function info() {
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
function os() {
|
2024-07-09 17:18:49 +03:00
|
|
|
local os
|
|
|
|
os="$(uname -s)"
|
2023-02-17 14:46:13 +03:00
|
|
|
case "$os" in
|
|
|
|
Darwin)
|
|
|
|
echo "macos"
|
|
|
|
;;
|
2023-07-31 17:15:21 +03:00
|
|
|
Linux)
|
|
|
|
echo "linux"
|
|
|
|
;;
|
2024-07-09 17:18:49 +03:00
|
|
|
Windows | MSYS* | MINGW*)
|
2024-03-22 00:19:33 +03:00
|
|
|
echo "windows"
|
|
|
|
;;
|
2023-02-17 14:46:13 +03:00
|
|
|
*)
|
2024-03-22 00:19:33 +03:00
|
|
|
error "$os: unsupported"
|
2023-02-17 14:46:13 +03:00
|
|
|
;;
|
|
|
|
esac
|
2023-02-17 09:42:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function arch() {
|
2024-07-09 17:18:49 +03:00
|
|
|
local arch
|
|
|
|
arch="$(uname -m)"
|
2023-02-17 14:46:13 +03:00
|
|
|
case "$arch" in
|
2023-08-01 18:45:19 +03:00
|
|
|
arm64 | aarch64)
|
2023-02-17 14:46:13 +03:00
|
|
|
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
|
|
|
--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
|
|
|
|
|
2024-03-22 00:19:33 +03:00
|
|
|
[ -z "${VERSION-}" ] && error "--version is not set"
|
2023-02-17 16:21:41 +03:00
|
|
|
|
2024-07-09 17:18:49 +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-02-17 09:42:30 +03:00
|
|
|
|
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
|
2023-07-31 17:13:28 +03:00
|
|
|
if [ "$OS" = "macos" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
[ -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_TEAM_ID-}" ] && error "$APPLE_TEAM_ID is not set"
|
|
|
|
[ -z "${APPLE_PASSWORD-}" ] && error "$APPLE_PASSWORD is not set"
|
2023-07-31 16:55:10 +03:00
|
|
|
export APPLE_CERTIFICATE="$APPLE_CERTIFICATE"
|
|
|
|
export APPLE_CERTIFICATE_PASSWORD="$APPLE_CERTIFICATE_PASSWORD"
|
|
|
|
export APPLE_SIGNING_IDENTITY="$APPLE_SIGNING_IDENTITY"
|
|
|
|
export APPLE_ID="$APPLE_ID"
|
2023-10-09 10:06:28 +03:00
|
|
|
export APPLE_TEAM_ID="$APPLE_TEAM_ID"
|
2023-07-31 16:55:10 +03:00
|
|
|
export APPLE_PASSWORD="$APPLE_PASSWORD"
|
2023-07-31 17:13:28 +03:00
|
|
|
elif [ "$OS" == "linux" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
[ -z "${APPIMAGE_KEY_ID-}" ] && error "$APPIMAGE_KEY_ID is not set"
|
|
|
|
[ -z "${APPIMAGE_KEY_PASSPHRASE-}" ] && error "$APPIMAGE_KEY_PASSPHRASE is not set"
|
2023-07-31 16:55:10 +03:00
|
|
|
export SIGN=1
|
|
|
|
export SIGN_KEY="$APPIMAGE_KEY_ID"
|
|
|
|
export APPIMAGETOOL_SIGN_PASSPHRASE="$APPIMAGE_KEY_PASSPHRASE"
|
2024-03-22 00:19:33 +03:00
|
|
|
elif [ "$OS" == "windows" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
# Nothing to do on windows
|
|
|
|
:
|
2023-07-31 16:55:10 +03:00
|
|
|
else
|
|
|
|
error "signing is not supported on $(uname -s)"
|
|
|
|
fi
|
2023-02-17 09:42:30 +03:00
|
|
|
fi
|
|
|
|
|
2023-02-17 14:46:13 +03:00
|
|
|
info "building:"
|
2024-07-09 17:18:49 +03:00
|
|
|
info " channel: $CHANNEL"
|
|
|
|
info " version: $VERSION"
|
|
|
|
info " os: $OS"
|
|
|
|
info " arch: $ARCH"
|
|
|
|
info " dist: $DIST"
|
|
|
|
info " sign: $DO_SIGN"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
2023-02-17 16:21:41 +03:00
|
|
|
TMP_DIR="$(mktemp -d)"
|
2024-07-09 17:18:49 +03:00
|
|
|
trap 'rm -rf "$TMP_DIR"' exit
|
2023-02-17 16:21:41 +03:00
|
|
|
|
2024-04-04 12:56:56 +03:00
|
|
|
CONFIG_PATH=$(readlink -f "$PWD/../crates/gitbutler-tauri/tauri.conf.$CHANNEL.json")
|
2023-07-12 17:06:10 +03:00
|
|
|
|
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
|
|
|
|
2024-04-25 12:17:52 +03:00
|
|
|
if [ "$OS" = "windows" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
FEATURES="windows"
|
2024-04-25 12:17:52 +03:00
|
|
|
else
|
2024-07-09 17:18:49 +03:00
|
|
|
FEATURES=""
|
2024-04-25 12:17:52 +03:00
|
|
|
fi
|
2023-07-21 14:05:46 +03:00
|
|
|
|
2023-02-20 18:51:48 +03:00
|
|
|
# build the app with release config
|
2024-07-10 16:45:18 +03:00
|
|
|
tauri build \
|
2023-08-01 10:20:55 +03:00
|
|
|
--verbose \
|
2023-07-31 16:55:10 +03:00
|
|
|
--features "$FEATURES" \
|
|
|
|
--config "$TMP_DIR/tauri.conf.json"
|
2023-02-17 09:42:30 +03:00
|
|
|
|
2023-09-06 11:46:07 +03:00
|
|
|
BUNDLE_DIR=$(readlink -f "$PWD/../target/release/bundle")
|
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-07-31 17:13:28 +03:00
|
|
|
|
2023-08-01 12:04:19 +03:00
|
|
|
if [ "$OS" = "macos" ]; then
|
2023-07-31 17:15:21 +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-08-01 10:20:40 +03:00
|
|
|
|
2023-07-31 17:15:21 +03:00
|
|
|
cp "$MACOS_DMG" "$RELEASE_DIR"
|
|
|
|
cp "$MACOS_UPDATER" "$RELEASE_DIR"
|
|
|
|
cp "$MACOS_UPDATER_SIG" "$RELEASE_DIR"
|
2023-08-01 10:20:40 +03:00
|
|
|
|
2023-07-31 17:15:21 +03:00
|
|
|
info "built:"
|
2024-07-09 17:18:49 +03:00
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_DMG")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_UPDATER")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$MACOS_UPDATER_SIG")"
|
2023-08-01 12:04:19 +03:00
|
|
|
elif [ "$OS" = "linux" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
APPIMAGE="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage)"
|
|
|
|
APPIMAGE_UPDATER="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz)"
|
|
|
|
APPIMAGE_UPDATER_SIG="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz.sig)"
|
|
|
|
DEB="$(find "$BUNDLE_DIR/deb" -name \*.deb)"
|
|
|
|
RPM="$(find "$BUNDLE_DIR/rpm" -name \*.rpm)"
|
2023-08-01 14:22:50 +03:00
|
|
|
|
2023-08-01 10:20:40 +03:00
|
|
|
cp "$APPIMAGE" "$RELEASE_DIR"
|
2023-08-01 14:22:50 +03:00
|
|
|
cp "$APPIMAGE_UPDATER" "$RELEASE_DIR"
|
|
|
|
cp "$APPIMAGE_UPDATER_SIG" "$RELEASE_DIR"
|
2023-09-07 18:50:58 +03:00
|
|
|
cp "$DEB" "$RELEASE_DIR"
|
2024-06-25 21:44:11 +03:00
|
|
|
cp "$RPM" "$RELEASE_DIR"
|
2023-08-01 10:20:40 +03:00
|
|
|
|
|
|
|
info "built:"
|
2024-07-09 17:18:49 +03:00
|
|
|
info " - $RELEASE_DIR/$(basename "$APPIMAGE")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$APPIMAGE_UPDATER")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$APPIMAGE_UPDATER_SIG")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$DEB")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$RPM")"
|
2024-03-22 00:19:33 +03:00
|
|
|
elif [ "$OS" = "windows" ]; then
|
2024-07-09 17:18:49 +03:00
|
|
|
WINDOWS_INSTALLER="$(find "$BUNDLE_DIR/msi" -name \*.msi)"
|
|
|
|
WINDOWS_UPDATER="$(find "$BUNDLE_DIR/msi" -name \*.msi.zip)"
|
|
|
|
WINDOWS_UPDATER_SIG="$(find "$BUNDLE_DIR/msi" -name \*.msi.zip.sig)"
|
2024-03-22 00:19:33 +03:00
|
|
|
|
|
|
|
cp "$WINDOWS_INSTALLER" "$RELEASE_DIR"
|
|
|
|
cp "$WINDOWS_UPDATER" "$RELEASE_DIR"
|
|
|
|
cp "$WINDOWS_UPDATER_SIG" "$RELEASE_DIR"
|
|
|
|
|
|
|
|
info "built:"
|
2024-07-09 17:18:49 +03:00
|
|
|
info " - $RELEASE_DIR/$(basename "$WINDOWS_INSTALLER")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$WINDOWS_UPDATER")"
|
|
|
|
info " - $RELEASE_DIR/$(basename "$WINDOWS_UPDATER_SIG")"
|
2024-03-22 00:19:33 +03:00
|
|
|
else
|
|
|
|
error "unsupported os: $OS"
|
2023-07-31 17:13:28 +03:00
|
|
|
fi
|
2023-02-17 09:42:30 +03:00
|
|
|
|
|
|
|
info "done! bye!"
|