#!/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"