mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
Nightly release: the Android APKs and an unsigned iOS .ipa from main, each day
nightly.yml takes the artifacts of the newest commit on main that has a complete run of android.yml and apple.yml, and replaces the "nightly" pre-release with them. It stops when main has no new commits. A hung test does not stop it: the release APK comes from the release job, which runs no tests, and the release lists each file that is missing. apple.yml now also builds the iOS app for a device, not signed, on main (DModem-unsigned.ipa). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRR6tKgobV4RbMTv4eL
This commit is contained in:
5 files changed
+234
-1
No files matched your search
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# nightly-pick.sh WORKFLOW...
|
||||
#
|
||||
# Finds the newest commit on main that has a completed run of each
|
||||
# WORKFLOW (a file name in .github/workflows). It writes these lines to
|
||||
# $GITHUB_OUTPUT:
|
||||
#
|
||||
# sha=<the commit>
|
||||
# run_<workflow>=<the run ID> (for each WORKFLOW, "." and "-" as "_")
|
||||
# skip=true|false (true: the nightly release has this commit)
|
||||
#
|
||||
# A run that is not complete is not used. Thus a run that is in progress
|
||||
# does not stop the nightly release: the release uses the run before it.
|
||||
# Set FORCE=true to publish again when the commit did not change.
|
||||
#
|
||||
# It needs GH_TOKEN and GH_REPO.
|
||||
set -euo pipefail
|
||||
|
||||
[ $# -ge 1 ] || { echo "usage: $0 WORKFLOW..." >&2; exit 2; }
|
||||
out=${GITHUB_OUTPUT:-/dev/stdout}
|
||||
|
||||
# the completed runs of a workflow on main (pushes and manual runs), newest first: "sha id"
|
||||
runs() {
|
||||
gh run list --workflow "$1" --branch main --status completed --limit 50 \
|
||||
--json headSha,databaseId,event \
|
||||
--jq '.[] | select(.event == "push" or .event == "workflow_dispatch") | "\(.headSha) \(.databaseId)"'
|
||||
}
|
||||
|
||||
declare -A list
|
||||
for w in "$@"; do
|
||||
list[$w]=$(runs "$w")
|
||||
done
|
||||
|
||||
sha=
|
||||
while read -r s _; do
|
||||
[ -n "$s" ] || continue
|
||||
ok=1
|
||||
for w in "$@"; do
|
||||
grep -q "^$s " <<<"${list[$w]}" || { ok=0; break; }
|
||||
done
|
||||
if [ "$ok" = 1 ]; then sha=$s; break; fi
|
||||
done <<<"${list[$1]}"
|
||||
|
||||
if [ -z "$sha" ]; then
|
||||
echo "::error::No commit on main has a completed run of each of: $*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "sha=$sha" >> "$out"
|
||||
for w in "$@"; do
|
||||
id=$(grep -m1 "^$sha " <<<"${list[$w]}" | cut -d' ' -f2)
|
||||
echo "run_$(tr '.-' '__' <<<"$w")=$id" >> "$out"
|
||||
echo "$w: run $id"
|
||||
done
|
||||
|
||||
# (gh writes the error body of a 404 to stdout: no tag is no commit)
|
||||
old=$(gh api "repos/$GH_REPO/git/ref/tags/nightly" --jq .object.sha 2>/dev/null) || old=
|
||||
echo "Commit: $sha (the nightly release has: ${old:-none})"
|
||||
if [ "$sha" = "$old" ] && [ "${FORCE:-false}" != true ]; then
|
||||
echo "skip=true" >> "$out"
|
||||
echo "No new commits on main. The nightly release does not change."
|
||||
else
|
||||
echo "skip=false" >> "$out"
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# nightly-publish.sh SHA NOTES DIR
|
||||
#
|
||||
# Replaces the "nightly" pre-release with a new one: its tag at SHA, its
|
||||
# text from the file NOTES, its files all the files in DIR.
|
||||
#
|
||||
# It needs GH_TOKEN and GH_REPO.
|
||||
set -euo pipefail
|
||||
|
||||
sha=$1 notes=$2 dir=$3
|
||||
shopt -s nullglob
|
||||
files=("$dir"/*)
|
||||
[ ${#files[@]} -gt 0 ] || { echo "::error::No files to publish in $dir"; exit 1; }
|
||||
|
||||
gh release delete nightly --yes --cleanup-tag 2>/dev/null || true
|
||||
# (a tag that has no release)
|
||||
gh api -X DELETE "repos/$GH_REPO/git/refs/tags/nightly" 2>/dev/null || true
|
||||
|
||||
gh release create nightly "${files[@]}" \
|
||||
--prerelease --latest=false --target "$sha" \
|
||||
--title "Nightly build ($(date -u +%Y-%m-%d), ${sha:0:7})" \
|
||||
--notes-file "$notes"
|
||||
Reference in new issue
Block a user