-
-
Notifications
You must be signed in to change notification settings - Fork 57
ci: fail closed if a pre-release tag would publish to Play production #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ErikBjare
merged 2 commits into
ActivityWatch:master
from
TimeToBuildBob:ci/assert-play-track
Aug 30, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| #!/usr/bin/env bash | ||
| # Resolve or assert the Play Store supply track for an aw-android release tag. | ||
| # | ||
| # Contract: | ||
| # X.Y.Z (no suffix) → production | ||
| # anything else → internal (0.14.0b2, 0.14.0devYYYYMMDD, 0.14.0-rc1, …) | ||
| # | ||
| # Fail closed: a pre-release tag must never publish to production, even if | ||
| # SUPPLY_TRACK is later hardcoded or the resolver regresses. Stable tags may | ||
| # still be sent to internal (staged rollout); that is not this guard. | ||
| # | ||
| # Usage: | ||
| # scripts/assert-play-track.sh resolve <tag> | ||
| # scripts/assert-play-track.sh assert <tag> <track> | ||
| # scripts/assert-play-track.sh --self-test | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<'EOF' >&2 | ||
| Usage: | ||
| scripts/assert-play-track.sh resolve <tag> | ||
| scripts/assert-play-track.sh assert <tag> <track> | ||
| scripts/assert-play-track.sh --self-test | ||
| EOF | ||
| exit 2 | ||
| } | ||
|
|
||
| is_stable_version() { | ||
| [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] | ||
| } | ||
|
|
||
| tag_to_version() { | ||
| local tag="$1" | ||
| if [[ -z "$tag" ]]; then | ||
| echo "error: empty tag" >&2 | ||
| return 1 | ||
| fi | ||
| echo "${tag#v}" | ||
| } | ||
|
|
||
| resolve_track() { | ||
| local version | ||
| version="$(tag_to_version "$1")" | ||
| if is_stable_version "$version"; then | ||
| echo production | ||
| else | ||
| echo internal | ||
| fi | ||
| } | ||
|
|
||
| assert_track() { | ||
| local tag="$1" | ||
| local track="$2" | ||
| local version | ||
| version="$(tag_to_version "$tag")" | ||
|
|
||
| if [[ -z "$track" ]]; then | ||
| echo "error: SUPPLY_TRACK is empty; refusing to publish ${tag}" >&2 | ||
| return 1 | ||
| fi | ||
| if [[ "$track" != production && "$track" != internal ]]; then | ||
| echo "error: unknown SUPPLY_TRACK=${track} for ${tag}" >&2 | ||
| return 1 | ||
| fi | ||
| if [[ "$track" == production ]] && ! is_stable_version "$version"; then | ||
| echo "error: refusing to publish pre-release tag ${tag} to production (SUPPLY_TRACK=${track})" >&2 | ||
| return 1 | ||
| fi | ||
| echo "ok: tag=${tag} version=${version} SUPPLY_TRACK=${track}" | ||
| } | ||
|
|
||
| self_test() { | ||
| local fail=0 | ||
| expect_resolve() { | ||
| local tag="$1" want="$2" got | ||
| got="$(resolve_track "$tag")" | ||
| if [[ "$got" != "$want" ]]; then | ||
| echo "FAIL resolve ${tag}: got ${got} want ${want}" >&2 | ||
| fail=1 | ||
| fi | ||
| } | ||
| expect_assert_ok() { | ||
| if ! assert_track "$1" "$2" >/dev/null; then | ||
| echo "FAIL assert should pass: tag=$1 track=$2" >&2 | ||
| fail=1 | ||
| fi | ||
| } | ||
| expect_assert_fail() { | ||
| if assert_track "$1" "$2" >/dev/null 2>&1; then | ||
| echo "FAIL assert should fail: tag=$1 track=$2" >&2 | ||
| fail=1 | ||
| fi | ||
| } | ||
|
|
||
| expect_resolve v0.14.0 production | ||
| expect_resolve 0.14.0 production | ||
| expect_resolve v1.0.0 production | ||
| expect_resolve v0.14.0b2 internal | ||
| expect_resolve v0.14.0beta2 internal | ||
| expect_resolve v0.14.0dev20260723 internal | ||
| expect_resolve v0.14.0-rc1 internal | ||
| expect_resolve v0.14.0rc1 internal | ||
| expect_resolve v0.14 internal | ||
|
|
||
| expect_assert_ok v0.14.0 production | ||
| expect_assert_ok v0.14.0 internal | ||
| expect_assert_ok v0.14.0b2 internal | ||
| expect_assert_fail v0.14.0b2 production | ||
| expect_assert_fail v0.14.0dev20260723 production | ||
| expect_assert_fail v0.14.0beta2 production | ||
| expect_assert_fail v0.14.0 "" | ||
| expect_assert_fail v0.14.0 alpha | ||
| expect_assert_fail "" production | ||
|
|
||
| if [[ "$fail" -ne 0 ]]; then | ||
| echo "assert-play-track self-test FAILED" >&2 | ||
| return 1 | ||
| fi | ||
| echo "assert-play-track self-test passed" | ||
| } | ||
|
|
||
| cmd="${1:-}" | ||
| case "$cmd" in | ||
| resolve) | ||
| [[ $# -eq 2 ]] || usage | ||
| resolve_track "$2" | ||
| ;; | ||
| assert) | ||
| [[ $# -eq 3 ]] || usage | ||
| assert_track "$2" "$3" | ||
| ;; | ||
| --self-test) | ||
| self_test | ||
| ;; | ||
| *) | ||
| usage | ||
| ;; | ||
| esac |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.