Files
DroidDeck/tools/release/publish-ci.sh
T
Kurt Himebauch 87c571f443 feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds (#2624)
* feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds

* fix(updates): address review of the Updates tab history and test-build watch

* fix(updates): notify on switch to a followed PR, keep higher-version rebuilds installable

* fix(ci): let full reruns replace every artifact, note only expired PR builds

* fix(ci): leave the rebuild note only when the PR build is too old to rerun

* fix(ci): poll unfinished PR builds together and queue version-bump runs

* fix(ci): also rebuild PR builds that were running when the versionCode changed

* fix(ci): rebuild fork and just-finished PR builds, recheck the PR head before a rerun

* fix(ci): fail the rebuild sweep when finding candidates fails

* fix(ci): time the bump from the rebuild run's creation and scan unfinished builds of any age

* fix(ci): check the latest build of every open PR instead of scanning run history

* fix(ci): count PR builds that finish between the version push and the rebuild run

* fix(ci): use the push time from the event as the rebuild boundary
2026-11-14 16:20:29 -05:00

41 lines
1.9 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
tag=main-${GITHUB_SHA::7}
cat signed/SHA256SUMS-*.txt > signed/SHA256SUMS.txt
rm signed/SHA256SUMS-*.txt
notes="$(cat notes-head.md)
Signed build of $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA - in main, not yet in a DroidDeck release; for testing.
Commit: $GITHUB_SHA
VersionCode: $(sed -n 's/^ *versionCode \([0-9][0-9]*\)$/\1/p' app/build.gradle)
Each apk installs over a DroidDeck release and keeps its data. \`standard\` is the normal app; the others are the same app under another package name, installed beside it.
SHA-256:
\`\`\`
$(cat signed/SHA256SUMS.txt)
\`\`\`"
gh release delete "$tag" -R "$CI_REPO" --yes --cleanup-tag 2>/dev/null || true
gh release create "$tag" -R "$CI_REPO" --target main --prerelease \
--title "main ${GITHUB_SHA::7}" --notes "$notes" signed/*
cutoff=$(date -u -d "-${KEEP_DAYS} days" +%Y-%m-%dT%H:%M:%SZ)
gh release list -R "$CI_REPO" -L 1000 --exclude-drafts --json tagName,publishedAt \
--jq '.[] | select((.tagName | startswith("main-")) and .publishedAt < "'"$cutoff"'") | .tagName' |
while IFS= read -r old; do
if [ "$old" = "$tag" ]; then
continue
fi
if ! gh release delete "$old" -R "$CI_REPO" --yes --cleanup-tag 2>/dev/null; then
if gh release view "$old" -R "$CI_REPO" >/dev/null 2>&1; then
echo "::error::Could not delete old release $old"
exit 1
fi
fi
done
published=$(gh release view "$tag" -R "$CI_REPO" --json tagName,assets)
jq -e --arg tag "$tag" '.tagName == $tag and (.assets | length) > 0' <<< "$published" >/dev/null
url="$GITHUB_SERVER_URL/$CI_REPO/releases/tag/$tag"
apk=$(cd signed && ls DroidDeck-*.apk | awk 'length(a) == 0 || length($0) < length(a) { a = $0 } END { print a }')
echo "release=$url" >> "$GITHUB_OUTPUT"
echo "apk=$GITHUB_SERVER_URL/$CI_REPO/releases/download/$tag/$apk" >> "$GITHUB_OUTPUT"
echo "Published $url"