diff options
| author | Oskar <oskar@mullvad.net> | 2025-02-04 13:06:49 +0100 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2025-02-04 13:06:49 +0100 |
| commit | b9b74b3bef5d47f526fbe0bd13b34e2c28bd66a2 (patch) | |
| tree | 0b58f520464a4779a051d38ec2377c85ac504a5d | |
| parent | b11bdc69ab935264a729a7a24376d56f2eda44e5 (diff) | |
| parent | 3e788fcb7190a560dfc5935a1ce2800b8846aa40 (diff) | |
| download | mullvadvpn-b9b74b3bef5d47f526fbe0bd13b34e2c28bd66a2.tar.xz mullvadvpn-b9b74b3bef5d47f526fbe0bd13b34e2c28bd66a2.zip | |
Merge branch 'improve-prepare-release-script'
| -rwxr-xr-x | android/scripts/prepare-release.sh | 65 | ||||
| -rwxr-xr-x | desktop/scripts/prepare-release.sh | 131 | ||||
| -rwxr-xr-x | prepare-release.sh | 113 |
3 files changed, 196 insertions, 113 deletions
diff --git a/android/scripts/prepare-release.sh b/android/scripts/prepare-release.sh new file mode 100755 index 0000000000..00dc1b81ef --- /dev/null +++ b/android/scripts/prepare-release.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# This script prepares for a release. Run it with the release version as the first argument and it +# will update version numbers, commit and add a signed tag. + +set -eu + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR/../.." + +for argument in "$@"; do + case "$argument" in + -*) + echo "Unknown option \"$argument\"" + exit 1 + ;; + *) + PRODUCT_VERSION="$argument" + ;; + esac +done + +if [[ -z ${PRODUCT_VERSION+x} ]]; then + echo "Please give the release version as an argument to this script." + echo "For example: '2018.1-beta3' for a beta release, or '2018.6' for a stable one." + exit 1 +fi + +if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then + echo "Dirty working directory! Will not accept that for an official release." + exit 1 +fi + +if [[ $PRODUCT_VERSION != *"alpha"* && + $(grep "^## \\[android/$PRODUCT_VERSION\\] - " android/CHANGELOG.md) == "" ]]; then + + echo "It looks like you did not add $PRODUCT_VERSION to the changelog?" + echo "Please make sure the changelog is up to date and correct before you proceed." + exit 1 +fi + +echo "Generate relays.json" +mkdir dist-assets/relays +cargo run -q -p mullvad-api --bin relay_list > dist-assets/relays/relays.json + +git commit -S -m "Add relay list to bundle with $PRODUCT_VERSION" \ + dist-assets/relays/relays.json + +echo "$PRODUCT_VERSION" > dist-assets/android-version-name.txt +ANDROID_VERSION="$PRODUCT_VERSION" cargo run -q --bin mullvad-version versionCode > \ + dist-assets/android-version-code.txt +git commit -S -m "Update android app version to $PRODUCT_VERSION" \ + dist-assets/android-version-name.txt \ + dist-assets/android-version-code.txt + + +echo "Tagging current git commit with release tag android/$PRODUCT_VERSION..." +git tag -s "android/$PRODUCT_VERSION" -m "android/$PRODUCT_VERSION" + +echo "=================================================" +echo "| DONE preparing for a release! |" +echo "| Now push the tag created by this script |" +echo "| after you have verified it is correct: |" +echo "| $ git push origin $PRODUCT_VERSION" +echo "=================================================" diff --git a/desktop/scripts/prepare-release.sh b/desktop/scripts/prepare-release.sh new file mode 100755 index 0000000000..3ea8788c8f --- /dev/null +++ b/desktop/scripts/prepare-release.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash + +# This script prepares for a release. Run it with the release version as the first argument and it +# will update version numbers, commit and add a signed tag. + +set -eu + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR" + +REPO_ROOT=../../ + +source $REPO_ROOT/scripts/utils/log + +PUSH_TAG="false" + +for argument in "$@"; do + case "$argument" in + --push-tag) PUSH_TAG="true" ;; + -*) + log_error "Unknown option \"$argument\"" + exit 1 + ;; + *) + PRODUCT_VERSION="$argument" + ;; + esac +done + +changes_path=../packages/mullvad-vpn/changes.txt +changelog_path=$REPO_ROOT/CHANGELOG.md +product_version_path=$REPO_ROOT/dist-assets/desktop-product-version.txt + +function print_and_run { + echo "+ $*" + "$@" +} + +function checks { + if [[ -z ${PRODUCT_VERSION+x} ]]; then + log_error "Please give the release version as an argument to this script." + log_error "For example: '2018.1-beta3' for a beta release, or '2018.6' for a stable one." + exit 1 + fi + + if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then + log_error "Dirty working directory! Will not accept that for an official release." + exit 1 + fi + + if [[ $(grep "CHANGE THIS BEFORE A RELEASE" $changes_path) != "" ]]; then + log_error "It looks like you did not update $changes_path" + exit 1 + fi +} + +function check_commit_signature { + if ! git verify-commit HEAD; then + log_error \ + "Current commit lacks valid signature. Releases can only be made from signed commits." + exit 1 + fi + echo "" +} + +function check_changelog { + previous_version=$(grep -oP '## \[\K[^\]]+' $changelog_path | head -2 | tail -1) + + log_header "Changelog since previous release" + git --no-pager diff -U10 "$previous_version"..HEAD -- $changelog_path + + log_info "\nThe changelog should only contain changes in the \"Unreleased\" section, unless it's a correction of a previous message." + read -r -n 1 -p "Does this look good? (y: yes, q: abort, r: reload): " response + echo "" + + if [[ "$response" =~ ^[Yy]$ ]]; then + return + elif [[ "$response" =~ ^[QqAa]$ ]]; then + log_info "Aborting" + exit 1 + elif [[ "$response" =~ ^[Rr]$ ]]; then + check_changelog + else + log_error "Invalid response" + check_changelog + fi +} + +function update_changelog { + sed -i -e "/^## \[Unreleased\]/a \\\n\\n## \[$PRODUCT_VERSION\] - $(date +%F)" $changelog_path + + log_info "\nPaused after editing changelog. Make potential edits, then press any key to continue..." + read -r -s -n 1 + + print_and_run git commit -S -m "Update desktop app changelog with $PRODUCT_VERSION section" \ + $changelog_path +} + +function update_product_version { + echo "$PRODUCT_VERSION" > $product_version_path + print_and_run git commit -S -m "Update desktop app version to $PRODUCT_VERSION" \ + $product_version_path +} + +function push_tag { + product_version=$(echo -n "$(cat $product_version_path)") + echo "Tagging current git commit with release tag $product_version..." + print_and_run git tag -s "$product_version" -m "$product_version" + print_and_run git push origin "$product_version" + log_success "\nTag pushed!" +} + +if [[ $PUSH_TAG == "true" ]]; then + check_commit_signature + push_tag +else + checks + check_commit_signature + check_changelog + update_changelog + update_product_version + + log_success "\n=================================================" + log_success "| DONE preparing for a release! |" + log_success "| Now verify that everything looks correct |" + log_success "| and then create and push the tag by |" + log_success "| running: |" + log_success "| $ $0 \\ " + log_success "| --push-tag |" + log_success "=================================================" +fi diff --git a/prepare-release.sh b/prepare-release.sh deleted file mode 100755 index 4170b0fbe9..0000000000 --- a/prepare-release.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -# This script prepares for a release. Run it with the release version as the first argument and it -# will update version numbers, commit and add a signed tag. - -set -eu - -ANDROID="false" -DESKTOP="false" -VERSION_METADATA_ARGS="" - -for argument in "$@"; do - case "$argument" in - "--android") - ANDROID="true" - ;; - "--desktop") - DESKTOP="true" - VERSION_METADATA_ARGS+="--desktop " - ;; - -*) - echo "Unknown option \"$argument\"" - exit 1 - ;; - *) - PRODUCT_VERSION="$argument" - ;; - esac -done - -if [[ -z ${PRODUCT_VERSION+x} ]]; then - echo "Please give the release version as an argument to this script." - echo "For example: '2018.1-beta3' for a beta release, or '2018.6' for a stable one." - exit 1 -fi - -if [[ "$ANDROID" != "true" && "$DESKTOP" != "true" ]]; then - echo "Please specify if the release is for the desktop app and/or for Android app." - echo "For example: --android --desktop" - exit 1 -fi - -if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then - echo "Dirty working directory! Will not accept that for an official release." - exit 1 -fi - -desktop_changes_path=desktop/packages/mullvad-vpn/changes.txt -if [[ $DESKTOP == "true" && $(grep "CHANGE THIS BEFORE A RELEASE" $desktop_changes_path) != "" ]]; then - echo "It looks like you did not update $desktop_changes_path" - exit 1 -fi - -if [[ "$DESKTOP" == "true" && $(grep "^## \\[$PRODUCT_VERSION\\] - " CHANGELOG.md) == "" ]]; then - echo "It looks like you did not add $PRODUCT_VERSION to the changelog?" - echo "Please make sure the changelog is up to date and correct before you proceed." - exit 1 -fi - -if [[ "$ANDROID" == "true" && - $PRODUCT_VERSION != *"alpha"* && - $(grep "^## \\[android/$PRODUCT_VERSION\\] - " android/CHANGELOG.md) == "" ]]; then - - echo "It looks like you did not add $PRODUCT_VERSION to the changelog?" - echo "Please make sure the changelog is up to date and correct before you proceed." - exit 1 -fi - -if [[ "$ANDROID" == "true" ]]; then - echo "Generate relays.json" - mkdir dist-assets/relays - cargo run -q -p mullvad-api --bin relay_list > dist-assets/relays/relays.json - - git commit -S -m "Add relay list to bundle with $PRODUCT_VERSION" \ - dist-assets/relays/relays.json -fi - -if [[ "$DESKTOP" == "true" ]]; then - echo "$PRODUCT_VERSION" > dist-assets/desktop-product-version.txt - git commit -S -m "Update desktop app version to $PRODUCT_VERSION" \ - dist-assets/desktop-product-version.txt -fi - -if [[ "$ANDROID" == "true" ]]; then - echo "$PRODUCT_VERSION" > dist-assets/android-version-name.txt - ANDROID_VERSION="$PRODUCT_VERSION" cargo run -q --bin mullvad-version versionCode > \ - dist-assets/android-version-code.txt - git commit -S -m "Update android app version to $PRODUCT_VERSION" \ - dist-assets/android-version-name.txt \ - dist-assets/android-version-code.txt -fi - -NEW_TAGS="" - -if [[ "$ANDROID" == "true" ]]; then - echo "Tagging current git commit with release tag android/$PRODUCT_VERSION..." - - git tag -s "android/$PRODUCT_VERSION" -m "android/$PRODUCT_VERSION" - NEW_TAGS+=" android/$PRODUCT_VERSION" -fi -if [[ "$DESKTOP" == "true" ]]; then - echo "Tagging current git commit with release tag $PRODUCT_VERSION..." - - git tag -s "$PRODUCT_VERSION" -m "$PRODUCT_VERSION" - NEW_TAGS+=" $PRODUCT_VERSION" -fi - -echo "=================================================" -echo "| DONE preparing for a release! |" -echo "| Now push the tag created by this script |" -echo "| after you have verified it is correct: |" -echo "| $ git push origin$NEW_TAGS" -echo "=================================================" |
