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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
source scripts/release-tags.sh
source scripts/release-version.sh
fail() {
printf '%s\n' "$1" >&2
exit 1
}
channel=${1:-}
case "$channel" in
testflight)
tag_glob='testflight/v*'
tag_pattern=$testflight_tag_pattern
;;
app-store)
tag_glob='v*'
tag_pattern=$app_store_tag_pattern
;;
*) fail "Run just testflight or just release." ;;
esac
git fetch --tags origin refs/heads/main
commit=$(git rev-parse --verify refs/heads/main)
if [[ "$commit" != "$(git rev-parse --verify FETCH_HEAD)" ]]; then
fail "Local main differs from main on Knotless. Sync main before tagging a release."
fi
existing_tags=$(git tag --list --points-at "$commit" --sort=-version:refname "$tag_glob")
while IFS= read -r tag; do
if [[ "$tag" =~ $tag_pattern ]]; then
exec git push --no-follow-tags origin "refs/tags/$tag"
fi
done <<< "$existing_tags"
version=$(next_app_version main)
[[ "$commit" == "$(git rev-parse --verify refs/heads/main)" ]] || fail "Local main changed during version calculation. Run the command again."
tag="v$version"
if [[ "$channel" == testflight ]]; then
tag=$(next_testflight_tag "$version")
fi
git tag -a "$tag" "$commit" -m "$tag"
printf 'Pushing %s to Knotless.\n' "$tag"
git push --no-follow-tags origin "refs/tags/$tag"