commit
Delete .github directory
diff --git a/.github/apps.json b/.github/apps.json
deleted file mode 100644
index f77d836..0000000
--- a/.github/apps.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "_comment": "What the Manager shows for each app, and the certificate each published APK must be signed with (docs/releasing.md). CI fails rather than publish an APK whose certificate isn't the one pinned here. Keyed by the APK's file name in the release.",
- "system.apk": {
- "id": "system",
- "name": "System",
- "summary": "The plural system: members, fronting and relationships.",
- "dir": "plural",
- "signingCertSha256": "F1:0D:90:FE:C9:0C:97:18:C0:06:8B:70:5A:55:92:62:05:DF:11:74:95:62:A2:7D:30:B5:16:70:40:3E:1D:C1"
- },
- "inbox.apk": {
- "id": "inbox",
- "name": "Inbox",
- "summary": "Mail for every Doughmination domain.",
- "dir": "email",
- "signingCertSha256": "79:7D:66:1F:F5:EE:00:FD:DB:E3:E0:7F:FF:07:C5:EF:AC:C3:50:8F:18:65:0F:60:F5:A6:A6:4B:95:30:A8:DD"
- },
- "device-reporter.apk": {
- "id": "device-reporter",
- "name": "Device Reporter",
- "summary": "Reports this phone's battery and state to the Doughmination API.",
- "dir": "api-helper",
- "signingCertSha256": "D1:D0:FB:74:BA:38:5E:69:55:BF:58:97:FD:E7:18:4F:4F:2F:1B:91:FD:0E:FA:2D:9E:A8:FF:C0:59:B8:CF:D5"
- },
- "doughmination-manager.apk": {
- "id": "manager",
- "name": "Doughmination Manager",
- "summary": "Installs and updates the Doughmination apps.",
- "dir": "doughmination-manager",
- "signingCertSha256": "22:8D:A3:BC:CF:8B:ED:60:21:B8:E6:E0:17:C2:FE:62:F1:EC:52:9C:8C:D4:2C:8D:41:A1:35:FA:62:7B:E8:AA"
- }
-}
diff --git a/.github/scripts/build-apps.sh b/.github/scripts/build-apps.sh
deleted file mode 100644
index 413404a..0000000
--- a/.github/scripts/build-apps.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env bash
-# Builds every app's release APK, each signed with its own key, into <out>
-# under a fixed name (system.apk, inbox.apk, ...), and writes <out>/versions.json
-# describing them. VERSION_NAME and VERSION_CODE come from the environment and
-# are the same for every app.
-#
-# build-apps.sh <out>
-#
-# Everything in versions.json is read back from the built APK itself (aapt2
-# for the package and versions, apksigner for the certificate), and the build
-# fails if the APK doesn't carry the version it was asked to build. So the
-# version an APK reports, the one Gradle was given and the one published are
-# always the same.
-#
-# Keys are read from $KEYS/<app>.p12 with their passwords in the environment
-# (see apps.yml). Without a key an app builds with the debug key (Inbox:
-# unsigned), which is fine for pull requests and never published. With
-# REQUIRE_PINNED_CERT=true, an APK whose certificate isn't the one pinned in
-# .github/apps.json fails the build.
-set -euo pipefail
-
-out=$1
-keys=${KEYS:-${RUNNER_TEMP:-/tmp}/keys}
-mkdir -p "$out"
-manifest="[]"
-
-tools=$(ls -d "$ANDROID_HOME"/build-tools/*/ | sort -V | tail -1)
-aapt2="${tools}aapt2"
-apksigner="${tools}apksigner"
-pins=.github/apps.json
-
-# build <file name> <gradle module> <module dir> <package> <key name> <password> <alias>
-build() {
- local file=$1 module=$2 dir=$3 package=$4 key=$5 password=$6 alias=$7
- echo "::group::$file ($module)"
- if [ -n "$password" ] && [ -f "$keys/$key.p12" ]; then
- SIGNING_STORE_FILE="$keys/$key.p12" \
- SIGNING_STORE_PASSWORD="$password" \
- SIGNING_KEY_ALIAS="$alias" \
- SIGNING_KEY_PASSWORD="$password" \
- ./gradlew "$module:assembleRelease" --console=plain
- else
- ./gradlew "$module:assembleRelease" --console=plain
- fi
- local apk
- apk=$(ls "$dir"/build/outputs/apk/release/*.apk | head -1)
- cp "$apk" "$out/$file"
-
- # What the APK really is.
- local badging pkg code name minsdk cert
- badging=$("$aapt2" dump badging "$out/$file")
- pkg=$(sed -n "s/^package: name='\([^']*\)'.*/\1/p" <<< "$badging")
- code=$(sed -n "s/^package: .* versionCode='\([^']*\)'.*/\1/p" <<< "$badging")
- name=$(sed -n "s/^package: .* versionName='\([^']*\)'.*/\1/p" <<< "$badging")
- minsdk=$(sed -n "s/^\(minSdkVersion\|sdkVersion\):'\([0-9]*\)'.*/\2/p" <<< "$badging" | head -1)
- # "Signer #1 certificate SHA-256 digest: …" or, newer, "V2 Signer: certificate SHA-256 digest: …"
- cert=$("$apksigner" verify --print-certs "$out/$file" 2>/dev/null \
- | sed -n 's/^.*[Ss]igner.*certificate SHA-256 digest: *//p' | head -1 || true)
-
- local expected_code=${VERSION_CODE:-1} expected_name=${VERSION_NAME:-}
- if [ "$pkg" != "$package" ]; then
- echo "::error::$file is package '$pkg', expected '$package'"; exit 1
- fi
- if [ "$code" != "$expected_code" ] || { [ -n "$expected_name" ] && [ "$name" != "$expected_name" ]; }; then
- echo "::error::$file reports $name ($code), but this build is ${expected_name:-?} ($expected_code)"; exit 1
- fi
- if [ "${REQUIRE_PINNED_CERT:-false}" = true ]; then
- local pinned
- pinned=$(jq -r --arg f "$file" '.[$f].signingCertSha256 // ""' "$pins" | tr -d ':' | tr 'A-F' 'a-f')
- if [ -z "$cert" ] || [ "$cert" != "$pinned" ]; then
- echo "::error::$file is signed by ${cert:-nothing}, not the key pinned in $pins ($pinned)"; exit 1
- fi
- fi
- echo "$file: $pkg $name ($code), minSdk $minsdk, certificate ${cert:-none}"
-
- manifest=$(jq \
- --arg file "$file" \
- --arg packageName "$pkg" \
- --argjson versionCode "$code" \
- --arg versionName "$name" \
- --argjson minSdk "${minsdk:-1}" \
- --arg signingCertSha256 "$cert" \
- --arg sha256 "$(sha256sum "$out/$file" | cut -d' ' -f1)" \
- --argjson sizeBytes "$(stat -c %s "$out/$file")" \
- '. + [{$file, $packageName, $versionCode, $versionName, $minSdk, $signingCertSha256, $sha256, $sizeBytes}]' <<< "$manifest")
- echo "::endgroup::"
-}
-
-# Inbox reads email/keystore.properties (written by apps.yml), not SIGNING_*.
-build system.apk ":plural:app" plural/app gay.doughmination.plural plural "${PLURAL_PASSWORD:-}" plural
-build inbox.apk ":email:app" email/app gay.doughmination.mail inbox "${INBOX_PASSWORD:-}" inbox
-build device-reporter.apk ":api-helper:app" api-helper/app uk.doughmination.devicereporter device-reporter "${DEVICE_REPORTER_PASSWORD:-}" "${DEVICE_REPORTER_ALIAS:-device-reporter}"
-build doughmination-manager.apk ":doughmination-manager:app" doughmination-manager/app gay.doughmination.manager manager "${MANAGER_PASSWORD:-}" manager
-
-jq -n \
- --arg version "${VERSION_NAME:-dev}" \
- --arg commit "${GITHUB_SHA:-}" \
- --argjson apps "$manifest" \
- '{$version, $commit, $apps}' > "$out/versions.json"
-cat "$out/versions.json"
diff --git a/.github/scripts/make-manifest.sh b/.github/scripts/make-manifest.sh
deleted file mode 100644
index 97ed9e5..0000000
--- a/.github/scripts/make-manifest.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env bash
-# Writes <dist>/manifest.json, the document Doughmination Manager reads
-# (docs/manifest.md), and <dist>/publish.txt, the APKs that need uploading.
-#
-# make-manifest.sh <dist> [previous manifest.json]
-#
-# Inputs: <dist>/versions.json (what build-apps.sh read back from each APK),
-# .github/apps.json (names, summaries, pinned certificates), git history, and
-# the manifest that's published now.
-#
-# Each app gets a new version only when its sources changed. An app's
-# fingerprint covers its own directory and the shared build files; when it
-# matches the published one, the app keeps its published entry and APK, so the
-# Manager offers no update for it. Otherwise the freshly built APK is
-# published, and:
-# - its release notes are the commits that touched its directory since its
-# own last release;
-# - its versionCode must be higher than the published one, or the script
-# fails and nothing is published.
-set -euo pipefail
-
-dist=$1
-previous=${2:-}
-[ -n "$previous" ] && [ -s "$previous" ] || previous=""
-repo=${GITHUB_REPOSITORY:-doughmination/apps}
-download="https://github.com/$repo/releases/latest/download"
-release_url="https://github.com/$repo/releases/tag/latest"
-now=$(date -u +%Y-%m-%dT%H:%M:%SZ)
-head_commit=$(git rev-parse HEAD)
-
-# Files every app's build depends on. Changing any of them rebuilds every app.
-shared="design gradle build.gradle.kts settings.gradle.kts gradle.properties gradlew"
-
-fingerprint() {
- local paths="$1 $shared" p
- for p in $paths; do echo "$p $(git rev-parse "HEAD:$p")"; done | sha256sum | cut -d' ' -f1
-}
-
-apps="[]"
-: > "$dist/publish.txt"
-for file in $(jq -r '.apps[].file' "$dist/versions.json"); do
- built=$(jq --arg f "$file" '.apps[] | select(.file == $f)' "$dist/versions.json")
- meta=$(jq --arg f "$file" '.[$f]' .github/apps.json)
- if [ "$meta" = null ]; then
- echo "::error::$file has no entry in .github/apps.json"; exit 1
- fi
- dir=$(jq -r '.dir' <<< "$meta")
- package=$(jq -r '.packageName' <<< "$built")
- code=$(jq -r '.versionCode' <<< "$built")
- source_hash=$(fingerprint "$dir")
-
- published="null"
- if [ -n "$previous" ]; then
- published=$(jq --arg p "$package" '[.apps[] | select(.packageName == $p)][0] // null' "$previous")
- fi
-
- if [ "$published" != null ] && [ "$(jq -r '.sourceHash // ""' <<< "$published")" = "$source_hash" ]; then
- echo "$file: unchanged, keeping $(jq -r '.latest.versionName' <<< "$published")"
- apps=$(jq --argjson app "$published" --argjson meta "$meta" \
- '. + [$app + {id: $meta.id, name: $meta.name, summary: $meta.summary}]' <<< "$apps")
- continue
- fi
-
- if [ "$published" != null ]; then
- old=$(jq -r '.latest.versionCode' <<< "$published")
- if [ "$code" -le "$old" ]; then
- echo "::error::$file would be version code $code, but $old is already published. Version codes must only go up (docs/releasing.md)."
- exit 1
- fi
- fi
-
- # What changed in this app since its own last release.
- since=$(jq -r '.sourceCommit // ""' <<< "$published")
- if [ -n "$since" ] && git cat-file -e "$since^{commit}" 2>/dev/null; then
- notes=$(git log --no-merges --format='- %s' "$since..$head_commit" -- "$dir" | head -40)
- [ -n "$notes" ] || notes="- Rebuilt for a change to the shared build setup."
- else
- notes=$(git log --no-merges --format='- %s' -10 -- "$dir")
- fi
-
- echo "$file: changed, publishing $(jq -r '.versionName' <<< "$built")"
- echo "$file" >> "$dist/publish.txt"
- apps=$(jq \
- --argjson built "$built" \
- --argjson meta "$meta" \
- --arg url "$download/$file" \
- --arg notes "$notes" \
- --arg now "$now" \
- --arg releaseUrl "$release_url" \
- --arg sourceHash "$source_hash" \
- --arg sourceCommit "$head_commit" \
- '. + [{
- id: $meta.id,
- packageName: $built.packageName,
- name: $meta.name,
- summary: $meta.summary,
- signingCertSha256: [$meta.signingCertSha256],
- sourceHash: $sourceHash,
- sourceCommit: $sourceCommit,
- latest: {
- versionCode: $built.versionCode,
- versionName: $built.versionName,
- apkUrl: $url,
- sha256: $built.sha256,
- sizeBytes: $built.sizeBytes,
- minSdk: $built.minSdk,
- releasedAt: $now,
- releaseNotes: $notes,
- releaseUrl: $releaseUrl
- }
- }]' <<< "$apps")
-done
-
-jq -n --arg now "$now" --arg commit "$head_commit" --argjson apps "$apps" \
- '{schemaVersion: 1, generatedAt: $now, commit: $commit, apps: $apps}' > "$dist/manifest.json"
-cat "$dist/manifest.json"
-echo "To publish: $(tr '\n' ' ' < "$dist/publish.txt")"
diff --git a/.github/scripts/manager-e2e.sh b/.github/scripts/manager-e2e.sh
deleted file mode 100644
index 7f9ddf4..0000000
--- a/.github/scripts/manager-e2e.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env bash
-# The whole update path, on the running emulator: install Doughmination
-# Manager, let it read the published manifest, then have it download, verify
-# and install Inbox from the rolling release, confirming Android's own install
-# prompt the way a person would. Fails unless Inbox ends up installed at
-# exactly the version the manifest lists.
-#
-# manager-e2e.sh <manager apk> <output dir>
-set -euo pipefail
-
-apk=$1
-out=$2
-pkg=gay.doughmination.manager
-target=gay.doughmination.mail
-manifest_url="https://github.com/${GITHUB_REPOSITORY:-doughmination/apps}/releases/latest/download/manifest.json"
-mkdir -p "$out"
-
-if ! curl -fsSL "$manifest_url" -o "$out/manifest.json"; then
- echo "::warning::No published manifest yet; skipping the Manager test."
- exit 0
-fi
-want_code=$(jq -r --arg p "$target" '.apps[] | select(.packageName == $p) | .latest.versionCode' "$out/manifest.json")
-echo "The manifest lists $target at version code $want_code"
-
-ui() { adb exec-out uiautomator dump /dev/tty 2>/dev/null | sed 's/UI hierch*ary dumped to.*//' || true; }
-
-shot() {
- sleep "${2:-2}"
- adb exec-out screencap -p > "$out/$1.png"
- ui > "$out/$1.xml"
- echo "saved $1"
-}
-
-# Taps the first element whose text or description matches the regex $1 exactly.
-tap() {
- local bounds
- bounds=$(ui | grep -oE "(text|content-desc)=\"$1\"[^>]*bounds=\"\[[0-9]+,[0-9]+\]\[[0-9]+,[0-9]+\]\"" | head -1 \
- | grep -oE 'bounds="[^"]+"' | grep -oE '[0-9]+' | tr '\n' ' ' || true)
- if [ -z "$bounds" ]; then
- echo "::error::Couldn't find \"$1\" on screen"
- return 1
- fi
- set -- $bounds
- adb shell input tap $(( ($1 + $3) / 2 )) $(( ($2 + $4) / 2 ))
-}
-
-expect() {
- if ! ui | grep -qE "text=\"$1"; then
- echo "::error::Expected \"$1\" on screen at step $2"
- exit 1
- fi
- echo "found \"$1\""
-}
-
-adb uninstall "$target" > /dev/null 2>&1 || true
-adb install -r "$apk"
-# What a person does once in Settings: allow the Manager to install apps.
-adb shell appops set "$pkg" REQUEST_INSTALL_PACKAGES allow
-
-adb shell am start -W -n "$pkg/.MainActivity"
-shot 01-list 10
-expect "Doughmination Manager" "launch"
-expect "Inbox" "the app list"
-expect "Not installed" "the app list"
-
-tap "Inbox"
-shot 02-detail 2
-expect "What's new" "Inbox's page"
-tap "Install [^\"]*"
-echo "Downloading and verifying..."
-
-# Android's confirmation prompt appears once the APK is downloaded and checked.
-for i in $(seq 1 60); do
- if ui | grep -qiE 'text="(Install|INSTALL|Update|UPDATE)"[^>]*package="com\.(google\.)?android\.packageinstaller"'; then
- break
- fi
- if ui | grep -qE "doesn't match its SHA-256|isn't signed with|was interrupted|download failed|Couldn't install"; then
- shot 03-failed 0
- echo "::error::The Manager reported a failure"
- exit 1
- fi
- sleep 2
-done
-shot 03-confirm 0
-tap "(Install|INSTALL|Update|UPDATE)"
-
-for i in $(seq 1 30); do
- if adb shell pm list packages "$target" | grep -q "$target"; then break; fi
- sleep 2
-done
-shot 04-installed 3
-
-got_code=$(adb shell dumpsys package "$target" | grep -oE 'versionCode=[0-9]+' | head -1 | cut -d= -f2)
-if [ "$got_code" != "$want_code" ]; then
- echo "::error::Inbox installed at version code ${got_code:-none}, but the manifest says $want_code"
- exit 1
-fi
-expect "Up to date" "after installing"
-echo "Manager installed Inbox $got_code, matching the manifest"
-
-adb logcat -d > "$out/logcat.txt"
-if grep -q "FATAL EXCEPTION" "$out/logcat.txt"; then
- echo "::error::An app crashed"
- grep -A 30 "FATAL EXCEPTION" "$out/logcat.txt"
- exit 1
-fi
diff --git a/.github/scripts/plural-smoke.sh b/.github/scripts/plural-smoke.sh
deleted file mode 100644
index c68e722..0000000
--- a/.github/scripts/plural-smoke.sh
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/usr/bin/env bash
-# Installs the Plural APK on the running emulator, walks through the app the
-# way a person would, and saves a screenshot (plus the UI tree) of each step.
-# Fails if the APK won't install, the app won't launch, or it crashes.
-#
-# plural-smoke.sh <apk> <output dir>
-set -euo pipefail
-
-apk=$1
-out=$2
-pkg=gay.doughmination.plural
-mkdir -p "$out"
-
-ui() { adb exec-out uiautomator dump /dev/tty 2>/dev/null | sed 's/UI hierch*ary dumped to.*//' || true; }
-
-shot() {
- sleep "${2:-2}"
- adb exec-out screencap -p > "$out/$1.png"
- ui > "$out/$1.xml"
- echo "saved $1"
-}
-
-# Emulators on CI sometimes show "<app> isn't responding" for their own
-# launcher or System UI while booting; that dialog would swallow our taps.
-dismiss_system_dialogs() {
- local tries=0
- while ui | grep -q "isn't responding" && [ $tries -lt 6 ]; do
- echo "Dismissing a system \"isn't responding\" dialog"
- tap_raw "Close app" || adb shell input keyevent 4
- tries=$((tries + 1))
- sleep 2
- done
-}
-
-# Taps the middle of the first element whose text (or description) is exactly $1.
-tap_raw() {
- local bounds
- bounds=$(ui | grep -oE "(text|content-desc)=\"$1\"[^>]*bounds=\"\[[0-9]+,[0-9]+\]\[[0-9]+,[0-9]+\]\"" | head -1 \
- | grep -oE 'bounds="[^"]+"' | grep -oE '[0-9]+' | tr '\n' ' ' || true)
- if [ -z "$bounds" ]; then
- echo "::warning::Couldn't find \"$1\" on screen"
- return 1
- fi
- set -- $bounds
- adb shell input tap $(( ($1 + $3) / 2 )) $(( ($2 + $4) / 2 ))
-}
-
-tap_text() {
- dismiss_system_dialogs
- tap_raw "$1"
-}
-
-# Fails unless the screen shows text containing $1.
-expect() {
- dismiss_system_dialogs
- if ! ui | grep -qF "text=\"$1"; then
- echo "::error::Expected \"$1\" on screen at step $2"
- exit 1
- fi
- echo "found \"$1\""
-}
-
-alive() {
- if ! adb shell pidof "$pkg" > /dev/null; then
- echo "::error::$pkg isn't running after: $1"
- adb logcat -d -b crash > "$out/crash.txt" || true
- cat "$out/crash.txt"
- exit 1
- fi
-}
-
-adb logcat -c
-sleep 20
-dismiss_system_dialogs
-adb install -r "$apk"
-adb shell dumpsys package "$pkg" | grep -E "versionCode|versionName" | head -2
-
-adb shell am start -W -n "$pkg/.MainActivity"
-# The first load fetches members, fronters, the system and relationships.
-shot 01-members 10
-alive "launch"
-dismiss_system_dialogs
-expect "System Members" "launch"
-expect "Search members" "launch"
-
-size=$(adb shell wm size | grep -oE '[0-9]+x[0-9]+' | tail -1)
-width=${size%x*}
-height=${size#*x}
-
-adb shell input swipe $(( width / 2 )) $(( height * 3 / 4 )) $(( width / 2 )) $(( height / 4 )) 400
-shot 02-members-scrolled 2
-alive "scrolling the members"
-
-# Open whichever member card is in the middle of the screen.
-adb shell input tap $(( width / 4 )) $(( height / 2 ))
-shot 03-member 4
-alive "opening a member"
-adb shell input keyevent 4
-
-tap_text "Filters" && shot 04-filters 2 && adb shell input keyevent 4 || true
-alive "the filters"
-
-tap_text "Relationships" || exit 1
-shot 05-relationships 5
-alive "relationships"
-expect "Relationship Map" "relationships"
-adb shell input swipe $(( width / 2 )) $(( height * 3 / 4 )) $(( width / 2 )) $(( height / 4 )) 400
-shot 06-relationships-pairs 2
-
-tap_text "Metrics" || exit 1
-shot 07-metrics 8
-alive "metrics"
-expect "Fronting time distribution" "metrics"
-adb shell input swipe $(( width / 2 )) $(( height * 3 / 4 )) $(( width / 2 )) $(( height / 4 )) 400
-shot 08-metrics-scrolled 2
-
-tap_text "Account" || exit 1
-shot 09-account 2
-alive "account"
-expect "Sign in with SSO" "account"
-
-# Background and foreground again: the socket reconnects and data refreshes.
-adb shell input keyevent 3
-sleep 3
-adb shell am start -W -n "$pkg/.MainActivity"
-shot 10-resumed 5
-alive "coming back from the background"
-
-adb logcat -d > "$out/logcat.txt"
-if grep -q "FATAL EXCEPTION" "$out/logcat.txt"; then
- echo "::error::The app crashed"
- grep -A 30 "FATAL EXCEPTION" "$out/logcat.txt"
- exit 1
-fi
-echo "Smoke test passed"
diff --git a/.github/workflows/apps.yml b/.github/workflows/apps.yml
deleted file mode 100644
index 2af9fd6..0000000
--- a/.github/workflows/apps.yml
+++ /dev/null
@@ -1,212 +0,0 @@
-# The one workflow for every app. Each push to main builds all four, signed
-# with their own keys and sharing one version (appVersion in gradle.properties,
-# plus the build number), and replaces the single rolling `latest` release with
-# them. Pull requests only build and test. See docs/releasing.md.
-name: Apps
-
-on:
- push:
- branches: [main]
- pull_request:
- workflow_dispatch:
-
-# Builds from main replace the same release, so let them finish in order.
-concurrency:
- group: apps-${{ github.ref }}
- cancel-in-progress: false
-
-jobs:
- build:
- runs-on: ubuntu-latest
- permissions:
- contents: write
- env:
- PUBLISH: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
- KEYS: ${{ github.workspace }}/../keys
- steps:
- # Full history: the release notes are the commits since the last release.
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - uses: actions/setup-java@v4
- with:
- distribution: temurin
- java-version: 17
-
- - uses: gradle/actions/setup-gradle@v4
-
- # This build's version: appVersion.<build number>. Only apps whose sources
- # changed are published with it (make-manifest.sh). Version
- # codes start at 1000, above anything released before the apps shared one.
- - name: Version
- run: |
- base=$(grep '^appVersion=' gradle.properties | cut -d= -f2 | tr -d '[:space:]')
- echo "VERSION_NAME=$base.$GITHUB_RUN_NUMBER" >> "$GITHUB_ENV"
- echo "VERSION_CODE=$((1000 + GITHUB_RUN_NUMBER))" >> "$GITHUB_ENV"
- echo "Version $base.$GITHUB_RUN_NUMBER ($((1000 + GITHUB_RUN_NUMBER)))"
-
- - name: Restore signing keys
- env:
- PLURAL_KEYSTORE_BASE64: ${{ secrets.PLURAL_KEYSTORE_BASE64 }}
- INBOX_KEYSTORE_BASE64: ${{ secrets.INBOX_KEYSTORE_BASE64 }}
- INBOX_PASSWORD: ${{ secrets.INBOX_KEYSTORE_PASSWORD }}
- DEVICE_REPORTER_KEYSTORE_BASE64: ${{ secrets.DEVICE_REPORTER_KEYSTORE_BASE64 }}
- MANAGER_KEYSTORE_BASE64: ${{ secrets.MANAGER_KEYSTORE_BASE64 }}
- INBOX_GOOGLE_SERVICES_JSON: ${{ secrets.INBOX_GOOGLE_SERVICES_JSON }}
- run: |
- mkdir -p "$KEYS"
- missing=""
- restore() {
- if [ -n "$2" ]; then echo "$2" | base64 -d > "$KEYS/$1.p12"; else missing="$missing $1"; fi
- }
- restore plural "$PLURAL_KEYSTORE_BASE64"
- restore inbox "$INBOX_KEYSTORE_BASE64"
- restore device-reporter "$DEVICE_REPORTER_KEYSTORE_BASE64"
- restore manager "$MANAGER_KEYSTORE_BASE64"
- # Inbox reads its key through email/keystore.properties.
- if [ -f "$KEYS/inbox.p12" ]; then
- umask 077
- printf 'storeFile=%s\nstorePassword=%s\nkeyAlias=inbox\nkeyPassword=%s\n' \
- "$KEYS/inbox.p12" "$INBOX_PASSWORD" "$INBOX_PASSWORD" > email/keystore.properties
- fi
- if [ -n "$INBOX_GOOGLE_SERVICES_JSON" ]; then
- echo "$INBOX_GOOGLE_SERVICES_JSON" | base64 -d > email/app/google-services.json
- fi
- # A published APK must carry its app's own key, or it won't install
- # over earlier builds; say so rather than ship the debug key.
- if [ "$PUBLISH" = true ] && [ -n "$missing" ]; then
- echo "::error::Signing secrets are missing for:$missing. See docs/releasing.md."
- exit 1
- fi
-
- - name: Unit tests
- run: ./gradlew testDebugUnitTest --console=plain
-
- - name: Build
- env:
- # A published APK must carry the certificate pinned in .github/apps.json.
- REQUIRE_PINNED_CERT: ${{ env.PUBLISH }}
- PLURAL_PASSWORD: ${{ secrets.PLURAL_STORE_PASSWORD }}
- INBOX_PASSWORD: ${{ secrets.INBOX_KEYSTORE_PASSWORD }}
- DEVICE_REPORTER_PASSWORD: ${{ secrets.DEVICE_REPORTER_STORE_PASSWORD }}
- DEVICE_REPORTER_ALIAS: ${{ secrets.DEVICE_REPORTER_KEY_ALIAS }}
- MANAGER_PASSWORD: ${{ secrets.MANAGER_STORE_PASSWORD }}
- run: bash .github/scripts/build-apps.sh dist
-
- # Fails on a badly signed APK, and prints each certificate so it can be
- # checked against docs/releasing.md.
- - name: Verify signatures
- if: env.PUBLISH == 'true'
- run: |
- apksigner=$(ls -d "$ANDROID_HOME"/build-tools/*/ | sort -V | tail -1)apksigner
- for apk in dist/*.apk; do
- echo "$apk"
- "$apksigner" verify --print-certs "$apk" | grep "certificate SHA-256"
- done
-
- # The Manager's manifest. Against the published one, so release notes
- # cover what changed since then and no app's version code goes backwards.
- - name: Manifest
- env:
- GH_TOKEN: ${{ github.token }}
- run: |
- gh release download latest -p manifest.json -O "$RUNNER_TEMP/previous-manifest.json" 2>/dev/null \
- || echo "No published manifest yet."
- bash .github/scripts/make-manifest.sh dist "$RUNNER_TEMP/previous-manifest.json"
-
- - uses: actions/upload-artifact@v4
- with:
- name: apps
- path: dist/
- if-no-files-found: error
-
- # One release, `latest`, always holding every app's newest build.
- - name: Publish the rolling release
- if: env.PUBLISH == 'true'
- env:
- GH_TOKEN: ${{ github.token }}
- run: |
- base="https://github.com/$GITHUB_REPOSITORY/releases/latest/download"
- # Each app's newest build, from the manifest: apps that didn't change
- # keep the version they had.
- {
- echo "The newest build of every app, as of ${GITHUB_SHA::7} on main."
- echo
- echo "| App | Version | Install | Changed in this build |"
- echo "|---|---|---|---|"
- jq -r --arg base "$base" --rawfile changed dist/publish.txt '.apps[] |
- (.latest.apkUrl | split("/") | last) as $f |
- "| \(.name) | \(.latest.versionName) | [\($f)](\($base)/\($f)) | \(if ($changed | split("\n") | index($f)) then "yes" else "" end) |"' \
- dist/manifest.json
- echo
- echo "These links always point at the newest build. Each installs over any earlier build of that app."
- echo "Doughmination Manager reads [manifest.json]($base/manifest.json) to find and verify them."
- } > notes.md
- cat notes.md
- mapfile -t changed < dist/publish.txt
- # Updated in place rather than deleted and recreated, so the links
- # never 404 between builds. Only changed apps' APKs are replaced.
- # manifest.json goes up last: until it does, the Manager still sees
- # the previous build, and a download that catches an APK mid-swap
- # fails its checksum and is retried.
- if gh release view latest > /dev/null 2>&1; then
- if [ ${#changed[@]} -gt 0 ]; then
- gh release upload latest "${changed[@]/#/dist/}" --clobber
- fi
- gh release upload latest dist/manifest.json --clobber
- # Raw build facts; the manifest replaced it.
- gh release delete-asset latest versions.json --yes 2>/dev/null || true
- git tag -f latest "$GITHUB_SHA"
- git push -f origin refs/tags/latest
- gh release edit latest --title "Doughmination apps" --notes-file notes.md --latest
- else
- gh release create latest dist/*.apk dist/manifest.json \
- --target "$GITHUB_SHA" \
- --title "Doughmination apps" \
- --notes-file notes.md \
- --latest
- fi
-
- # On an emulator: installs the System app and walks its screens, then has the
- # Manager download, verify and install an app from the rolling release.
- # Screenshots of each step are attached to the run.
- smoke:
- needs: build
- runs-on: ubuntu-latest
- timeout-minutes: 40
- steps:
- - uses: actions/checkout@v4
-
- - uses: actions/download-artifact@v4
- with:
- name: apps
- path: dist
-
- - name: Enable KVM
- run: |
- echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
- sudo udevadm control --reload-rules
- sudo udevadm trigger --name-match=kvm
-
- - name: Run on an emulator
- uses: reactivecircus/android-emulator-runner@v2
- with:
- api-level: 34
- target: default
- arch: x86_64
- profile: pixel_6
- disable-animations: true
- emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
- # System app first (its own build), then the Manager installing Inbox
- # from the published release.
- script: |
- bash .github/scripts/plural-smoke.sh dist/system.apk smoke/system
- bash .github/scripts/manager-e2e.sh dist/doughmination-manager.apk smoke/manager
-
- - uses: actions/upload-artifact@v4
- if: always()
- with:
- name: smoke-screenshots
- path: smoke/
- if-no-files-found: warn