blob: 56e9efe99d2b770c53380af4072ec7ddf8ac127d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/usr/bin/env bash
# This script downloads the current version (as defined by android-version-name.txt) from
# release.mullvad.net and verify that the signature.
# It then extract the changelog entries for that version and uploads it to github with the
# apk file and the signature.
set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
REPO_ROOT=../../../
PRODUCT_VERSION_PATH=$REPO_ROOT/dist-assets/android-version-name.txt
PRODUCT_VERSION=$(cat $PRODUCT_VERSION_PATH)
CHANGELOG_PATH=$REPO_ROOT/android/CHANGELOG.md
$REPO_ROOT/scripts/utils/gh-ready-check
$REPO_ROOT/scripts/utils/commit-verification
"$SCRIPT_DIR/verify-version-is-release"
# shellcheck source=desktop/scripts/release/release-config.sh
source "$SCRIPT_DIR/release-config.sh"
source $REPO_ROOT/scripts/utils/log
function cleanup {
log "Cleaning up temp artifact dir..."
rm -rf -- "$ARTIFACT_DIR"
}
function setup {
# We must provide a template for mktemp to work properly on macOS.
ARTIFACT_DIR=$(mktemp -d -t artifact-XXX)
export ARTIFACT_DIR
log_header "Artifact directory"
log_info "artifact dir: $ARTIFACT_DIR"
}
function publish_release {
log_header "Parse changelog"
# For stable versions, include all changelog entries for all beta versions since the last stable version.
changelog_end_version_pattern="android\/20[0-9]\{2\}\.[0-9]\{1,2\}"
if [[ $PRODUCT_VERSION == *-beta* ]]; then
changelog_end_version_pattern=".*"
fi
changelog_extract=$(sed -n "/^## \[android\/$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=(
--repo "git@github.com:mullvad/mullvadvpn-app"
--verify-tag
--notes-file -
--title "android/$PRODUCT_VERSION"
--draft
)
previous_release=$(echo "$changelog_extract" | tail -1 | awk -F'[][]' '/^## \[/{print $2}')
if [[ $PRODUCT_VERSION == *-beta* ]]; then
release_flags+=(--prerelease)
else
body+="Here 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 -cE '^## \[android\/[0-9]+\.[0-9]+(-beta[0-9]+)?\] - [0-9]{4}-[0-9]{2}-[0-9]{2}')
if [ "$version_count" -eq 1 ]; then
changelog=$(echo "$changelog" | tail -n +2)
fi
body+="\n$changelog"
read -rp "The suggested changelog will be opened in an editor, please finalize and save it before exiting. Press enter to open changelog..."
tmp_changelog_file=$(mktemp -t changelog-XXX)
{
printf "%b" "$body"
printf "%b" "\n\n<!--\nThe following artifacts will be included:\n"
# shellcheck disable=SC2012
ls -lh "$ARTIFACT_DIR" | tail -n +2 | awk '{print $9,"( Size:",$5,")"}'
echo "-->"
} > "$tmp_changelog_file"
"${EDITOR:-"vim"}" "$tmp_changelog_file"
log_header "Creating GitHub release"
# shellcheck disable=SC2046
gh release create "${release_flags[@]}" "android/$PRODUCT_VERSION" $(printf "%s " "$ARTIFACT_DIR"/*) < "$tmp_changelog_file"
rm tmp_changelog_file
}
trap cleanup EXIT
setup
echo "$PRODUCT_VERSION"
./download-release-artifacts "$PRODUCT_VERSION" "$ARTIFACT_DIR"
publish_release
|