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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/.."
source scripts/release-tags.sh
source scripts/release-version.sh
repository=knotless://geesawra.industries/old-fella
commit=${1:?Pass the commit that started the GitHub Actions run.}
if [[ "$commit" != "$(git rev-parse --verify HEAD)" ]]; then
echo "The GitHub Actions commit does not match the checkout." >&2
exit 1
fi
release_refs() {
local object ref tag
while IFS=$'\t' read -r object ref; do
tag=${ref#refs/tags/}
if [[ "$tag" =~ $app_store_tag_pattern || "$tag" =~ $testflight_tag_pattern ]]; then
printf '%s\t%s\n' "$object" "$ref"
fi
done | LC_ALL=C sort
}
for attempt in {1..6}; do
knotless_refs=$(knotless repo refs "$repository" | release_refs)
git fetch --quiet --no-tags --prune origin \
'refs/tags/v*:refs/tags/v*' 'refs/tags/testflight/v*:refs/tags/testflight/v*'
mirror_refs=$(git for-each-ref --format='%(objectname)%09%(refname)' refs/tags | release_refs)
if [[ "$knotless_refs" == "$mirror_refs" ]]; then
break
fi
if [[ "$attempt" == 6 ]]; then
echo "The GitHub mirror still differs from the release tags on Knotless." >&2
exit 1
fi
echo "Waiting for the GitHub mirror to receive the release tags."
sleep 5
done
existing_betas=$(git tag --list --contains "$commit" 'testflight/v*')
if grep -Eq "$testflight_tag_pattern" <<< "$existing_betas"; then
echo "A TestFlight tag already includes $commit."
exit 0
fi
newer_releases=$(git tag --list --no-merged "$commit" 'v*')
if grep -Eq "$app_store_tag_pattern" <<< "$newer_releases"; then
echo "An App Store tag is outside the history of $commit. Skip this snapshot."
exit 0
fi
git branch nightly-testflight "$commit"
version=$(next_app_version nightly-testflight)
tag=$(next_testflight_tag "$version")
current_refs=$(knotless repo refs "$repository" | release_refs)
if [[ "$current_refs" != "$mirror_refs" ]]; then
echo "The release tags changed on Knotless. Run the workflow again." >&2
exit 1
fi
knotless tag create "$repository" "$tag" "$commit"