diff options
| author | Oskar <oskar@mullvad.net> | 2025-01-31 21:01:36 +0100 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2025-02-04 17:11:03 +0100 |
| commit | 60bb8a64ec9dbc9714043c4578e33e108e5dca84 (patch) | |
| tree | be3c31fd91af294d85cd7f948ecc663c1d4c98cb /desktop | |
| parent | c17bff376ff341b948d44f09d72e7750b27b11c7 (diff) | |
| download | mullvadvpn-60bb8a64ec9dbc9714043c4578e33e108e5dca84.tar.xz mullvadvpn-60bb8a64ec9dbc9714043c4578e33e108e5dca84.zip | |
Add make-release script
Diffstat (limited to 'desktop')
| -rwxr-xr-x | desktop/scripts/make-release | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/desktop/scripts/make-release b/desktop/scripts/make-release new file mode 100755 index 0000000000..8af3a94119 --- /dev/null +++ b/desktop/scripts/make-release @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -eu + +if ! command -v gh > /dev/null; then + echo >&2 "gh (GitHub CLI) is required to run this script" + exit 1 +fi + +if ! gh auth status > /dev/null; then + echo >&2 "Authentication through gh (GitHub CLI) is required to run this script" + exit 1 +fi + +if [[ $# != 1 ]]; then + echo "!!! Please pass the app version as the first and only argument" + exit 1 +fi + +PRODUCT_VERSION=$1 +REPO_URL="git@github.com:mullvad/mullvadvpn-app" +ARTIFACT_DIR=$(mktemp -d) +REPO_DIR=$(mktemp -d) +CHANGELOG_PATH="$REPO_DIR/CHANGELOG.md" +URL_BASE="https://releases.mullvad.net/desktop/releases" + +function download_and_verify { + # Find GnuPG command to use. Prefer gpg2 + gpg_cmd=$(command -v gpg2 || command -v gpg) + + for ext in .exe _arm64.exe _x64.exe _amd64.deb _arm64.deb _x86_64.rpm _aarch64.rpm .pkg; do + pkg_filename="MullvadVPN-${PRODUCT_VERSION}${ext}" + pkg_path="$ARTIFACT_DIR/$pkg_filename" + url="$URL_BASE/$PRODUCT_VERSION/$pkg_filename" + echo ">>> Downloading $pkg_filename - $url" + curl -o "$pkg_path" --progress-bar --fail "$url" + curl -o "$pkg_path.asc" --progress-bar --fail "$url.asc" + + echo "" + echo ">>> Verifying integrity of $pkg_filename" + if ! $gpg_cmd --verify "$pkg_path.asc" "$pkg_path"; then + echo "" + echo "!!! INTEGRITY CHECKING FAILED !!!" + rm "$pkg_path" "$pkg_path.asc" + exit 1 + fi + echo "" + echo "GOOD SIGNATURE IN $pkg_filename" + echo "" + done +} + +function publish_release { + echo ">>> Cloning repository to extract changelog" + git clone --depth 1 --branch "$PRODUCT_VERSION" $REPO_URL "$REPO_DIR" 2> /dev/null > /dev/null + (cd "$REPO_DIR" && git verify-tag "$PRODUCT_VERSION") + echo "" + + changelog_end_version_pattern="20[0-9]\{2\}\.[0-9]\{1,2\}" + if [[ $PRODUCT_VERSION == *-beta* ]]; then + changelog_end_version_pattern=".*" + fi + + changelog_extract=$(sed -n "/^## \[$PRODUCT_VERSION\]/,/^## \[$changelog_end_version_pattern\]/p" "$CHANGELOG_PATH") + + changelog=$(echo "$changelog_extract" | sed '$d' | \ + awk 'NF { last = last ? last ORS $0 : $0 } END { print last }') + + release_flags=( --draft --verify-tag --notes-file - --title "$PRODUCT_VERSION" ) + + previous_release=$(echo "$changelog_extract" | tail -1 | grep -oP '## \[\K[^\]]+') + + body="This release is for desktop only." + if [[ $PRODUCT_VERSION == *-beta* ]]; then + body+="\n\nHere is a list of all changes since last release [$previous_release](https://github.com/mullvad/mullvadvpn-app/releases/tag/$previous_release):" + release_flags+=(--prerelease) + else + body+="\n\nHere is a list of all changes since last stable release [$previous_release](https://github.com/mullvad/mullvadvpn-app/releases/tag/$previous_release):" + release_flags+=(--latest) + fi + + version_count=$(echo "$changelog" | grep -c "^## ") + if [ "$version_count" -eq 1 ]; then + changelog=$(echo "$changelog" | tail -n +2) + fi + + body+="\n$changelog" + + echo ">>> Creating GitHub release" + # shellcheck disable=SC2059 + # shellcheck disable=SC2046 + printf "$body" | gh release create "${release_flags[@]}" "$PRODUCT_VERSION" $(printf "%s " "$ARTIFACT_DIR"/*) +} + +download_and_verify +publish_release |
