Files
foxhole-guard/.github/workflows/release.yml
dependabot[bot] 84a78ce32c Bump the github-actions group across 1 directory with 5 updates
Bumps the github-actions group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `5.1.0` | `7.0.1` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `6.0.0` | `7.0.1` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `7.0.0` | `8.0.1` |
| [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner) | `2.36.0` | `2.38.0` |
| [android-actions/setup-android](https://github.com/android-actions/setup-android) | `4.0.1` | `4.0.4` |



Updates `actions/checkout` from 5.1.0 to 7.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09...3d3c42e5aac5ba805825da76410c181273ba90b1)

Updates `actions/upload-artifact` from 6.0.0 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/b7c566a772e6b6bfb58ed0dc250532a479d7789f...043fb46d1a93c77aae656e7c1c64a875d1fc6a0a)

Updates `actions/download-artifact` from 7.0.0 to 8.0.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/37930b1c2abaa49bbe596cd826c3c89aef350131...3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c)

Updates `reactivecircus/android-emulator-runner` from 2.36.0 to 2.38.0
- [Release notes](https://github.com/reactivecircus/android-emulator-runner/releases)
- [Changelog](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/CHANGELOG.md)
- [Commits](https://github.com/reactivecircus/android-emulator-runner/compare/5d6e86df22ab11632167a1a6b0c9ab0dc3469586...a421e43855164a8197daf9d8d40fe71c6996bb0d)

Updates `android-actions/setup-android` from 4.0.1 to 4.0.4
- [Release notes](https://github.com/android-actions/setup-android/releases)
- [Commits](https://github.com/android-actions/setup-android/compare/40fd30fb8d7440372e1316f5d1809ec01dcd3699...be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: reactivecircus/android-emulator-runner
  dependency-version: 2.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: android-actions/setup-android
  dependency-version: 4.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-21 05:44:18 +00:00

349 lines
14 KiB
YAML

name: release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
actions: read
attestations: write
contents: write
id-token: write
concurrency:
group: release-main
cancel-in-progress: false
jobs:
release:
name: build and publish verified main commit
if: github.repository == 'foxhole-team/foxhole-guard'
runs-on: ubuntu-24.04
timeout-minutes: 90
steps:
- name: checkout release source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
submodules: recursive
persist-credentials: false
- name: verify public signed main authority
id: authority
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
[[ "$GITHUB_REF" == "refs/heads/main" ]] || {
echo "Release must run from refs/heads/main." >&2
exit 1
}
visibility="$(gh api "repos/$GITHUB_REPOSITORY" --jq '.visibility')"
[[ "$visibility" == "public" ]] || {
echo "Refusing to publish while $GITHUB_REPOSITORY is not public." >&2
exit 1
}
python3 scripts/verify-release-signature.py "$GITHUB_SHA"
main_tree="$(git rev-parse 'HEAD^{tree}')"
[[ "$main_tree" =~ ^[0-9a-f]{40}$ ]] || {
echo "Could not resolve the main Git tree." >&2
exit 1
}
echo "main_tree=$main_tree" >> "$GITHUB_OUTPUT"
# A successful signed dev candidate approves the source tree; release APKs must embed the main commit that will be tagged.
- name: find matching successful dev candidate
id: candidate
shell: bash
env:
GH_TOKEN: ${{ github.token }}
MAIN_TREE: ${{ steps.authority.outputs.main_tree }}
run: |
set -euo pipefail
runs_json="$RUNNER_TEMP/dev-runs.json"
gh api \
-X GET \
"repos/$GITHUB_REPOSITORY/actions/workflows/android.yml/runs" \
-f branch=dev \
-f event=push \
-f status=success \
-f per_page=100 \
> "$runs_json"
selected_run=""
selected_sha=""
selected_artifact=""
while IFS=$'\t' read -r run_id dev_sha; do
[[ "$run_id" =~ ^[1-9][0-9]*$ ]] || continue
[[ "$dev_sha" =~ ^[0-9a-f]{40}$ ]] || continue
dev_tree="$(gh api "repos/$GITHUB_REPOSITORY/git/commits/$dev_sha" --jq '.tree.sha')"
[[ "$dev_tree" == "$MAIN_TREE" ]] || continue
artifact_name="foxhole-app-$dev_sha"
artifacts_json="$RUNNER_TEMP/dev-artifacts-$run_id.json"
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$run_id/artifacts" > "$artifacts_json"
artifact_count="$(
jq \
--arg name "$artifact_name" '
[.artifacts[] | select(.name == $name and .expired == false)] | length
' \
"$artifacts_json"
)"
[[ "$artifact_count" == "1" ]] || continue
selected_run="$run_id"
selected_sha="$dev_sha"
selected_artifact="$artifact_name"
break
done < <(jq -r '.workflow_runs[] | select((.updated_at | fromdateiso8601) > now - 86400) | [.id, .head_sha] | @tsv' "$runs_json")
[[ -n "$selected_run" ]] || {
echo "No successful dev candidate from the last 24 hours has the same Git tree as main." >&2
exit 1
}
{
echo "run_id=$selected_run"
echo "dev_sha=$selected_sha"
echo "artifact_name=$selected_artifact"
} >> "$GITHUB_OUTPUT"
- name: install APK verification tools
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4
with:
packages: platform-tools
- name: install pinned Android build tools
shell: bash
run: sdkmanager "build-tools;37.0.0"
- name: download exact dev candidate
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ steps.candidate.outputs.artifact_name }}
path: ${{ runner.temp }}/foxhole-dev-candidate
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ steps.candidate.outputs.run_id }}
- name: verify candidate bytes and release policy
id: policy
shell: bash
env:
GH_TOKEN: ${{ github.token }}
DEV_SHA: ${{ steps.candidate.outputs.dev_sha }}
MAIN_TREE: ${{ steps.authority.outputs.main_tree }}
run: |
set -euo pipefail
candidate_dir="$RUNNER_TEMP/foxhole-dev-candidate"
scripts/package-release-candidate.sh verify "$candidate_dir" "$DEV_SHA" "$MAIN_TREE"
metadata="$candidate_dir/CANDIDATE.json"
tag="$(jq -er '.tag' "$metadata")"
version_name="$(jq -er '.versionName' "$metadata")"
version_code="$(jq -er '.versionCode' "$metadata")"
[[ "$tag" == "v$version_name" ]] || {
echo "Candidate tag/version mismatch." >&2
exit 1
}
published_code="$(scripts/package-release-candidate.sh published-code "$GITHUB_REPOSITORY")"
(( version_code > published_code )) || {
echo "versionCode $version_code is not newer than published $published_code." >&2
exit 1
}
if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" >/dev/null 2>&1; then
echo "Tag $tag already exists; release is intentionally non-overwriting." >&2
exit 1
fi
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists; release is intentionally non-overwriting." >&2
exit 1
fi
{
echo "tag=$tag"
echo "version_name=$version_name"
echo "published_code=$published_code"
} >> "$GITHUB_OUTPUT"
- name: setup Android and FoxHole Core build
if: steps.candidate.outputs.dev_sha != github.sha
uses: ./.github/actions/setup-foxcore
with:
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
- name: prepare release signing inputs
if: steps.candidate.outputs.dev_sha != github.sha
shell: bash
env:
FOXHOLE_RELEASE_STORE_FILE_B64: ${{ secrets.FOXHOLE_RELEASE_STORE_FILE_B64 }}
FOXHOLE_RELEASE_STORE_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_STORE_PASSWORD }}
FOXHOLE_RELEASE_KEY_ALIAS: ${{ secrets.FOXHOLE_RELEASE_KEY_ALIAS }}
FOXHOLE_RELEASE_KEY_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_KEY_PASSWORD }}
FOXHOLE_RELEASE_STORE_TYPE: ${{ secrets.FOXHOLE_RELEASE_STORE_TYPE }}
run: |
set -euo pipefail
missing=()
for secret_name in \
FOXHOLE_RELEASE_STORE_FILE_B64 \
FOXHOLE_RELEASE_STORE_PASSWORD \
FOXHOLE_RELEASE_KEY_ALIAS \
FOXHOLE_RELEASE_KEY_PASSWORD
do
if [[ -z "${!secret_name:-}" ]]; then
missing+=("$secret_name")
fi
done
if (( ${#missing[@]} > 0 )); then
printf 'Release signing secrets are required. Missing: %s\n' "${missing[*]}" >&2
exit 1
fi
keystore_path="$RUNNER_TEMP/foxhole-release.p12"
if ! printf '%s' "$FOXHOLE_RELEASE_STORE_FILE_B64" | base64 --decode > "$keystore_path"; then
echo "FOXHOLE_RELEASE_STORE_FILE_B64 is not valid base64" >&2
exit 1
fi
chmod 600 "$keystore_path"
{
echo "FOXHOLE_RELEASE_STORE_FILE=$keystore_path"
echo "FOXHOLE_RELEASE_STORE_PASSWORD=$FOXHOLE_RELEASE_STORE_PASSWORD"
echo "FOXHOLE_RELEASE_KEY_ALIAS=$FOXHOLE_RELEASE_KEY_ALIAS"
echo "FOXHOLE_RELEASE_KEY_PASSWORD=$FOXHOLE_RELEASE_KEY_PASSWORD"
echo "FOXHOLE_RELEASE_STORE_TYPE=${FOXHOLE_RELEASE_STORE_TYPE:-PKCS12}"
} >> "$GITHUB_ENV"
- name: build and verify signed GitHub and F-Droid releases from main
if: steps.candidate.outputs.dev_sha != github.sha
run: scripts/build-release-variants.sh "${{ steps.policy.outputs.published_code }}"
- name: package release with exact source provenance
if: steps.candidate.outputs.dev_sha != github.sha
shell: bash
run: |
set -euo pipefail
candidate_dir="$RUNNER_TEMP/foxhole-release-candidate"
source_tree="$(git rev-parse 'HEAD^{tree}')"
FOXHOLE_SBOM_PATH=build/reports/cyclonedx/bom.json \
scripts/package-release-candidate.sh \
prepare \
"$candidate_dir" \
"$GITHUB_SHA" \
"$source_tree"
- name: promote the exact already verified dev commit
if: steps.candidate.outputs.dev_sha == github.sha
shell: bash
run: |
set -euo pipefail
cp -a "$RUNNER_TEMP/foxhole-dev-candidate" "$RUNNER_TEMP/foxhole-release-candidate"
scripts/package-release-candidate.sh verify "$RUNNER_TEMP/foxhole-release-candidate" "$GITHUB_SHA" "$(git rev-parse 'HEAD^{tree}')"
# Mapping and native symbols stay authenticated Actions artifacts, never attached to the public release.
- name: retain private diagnostics
if: steps.candidate.outputs.dev_sha != github.sha
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: foxhole-release-private-diagnostics-${{ github.sha }}
path: |
build/release-variants/*/mapping.txt
app/build/outputs/mapping/publicRelease/mapping.txt
app/build/outputs/native-debug-symbols/publicRelease/publicRelease-native-symbols.zip
if-no-files-found: error
retention-days: 3
- name: attest exact release files
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4
with:
subject-path: ${{ runner.temp }}/foxhole-release-candidate/*
# Create as a draft first so a failed upload/byte comparison never exposes a partial release.
- name: create and verify draft release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.policy.outputs.tag }}
VERSION_NAME: ${{ steps.policy.outputs.version_name }}
run: |
set -euo pipefail
candidate_dir="$RUNNER_TEMP/foxhole-release-candidate"
assets=()
while IFS= read -r asset; do
assets+=("$asset")
done < <(find "$candidate_dir" -mindepth 1 -maxdepth 1 -type f | LC_ALL=C sort)
[[ ${#assets[@]} -eq 9 ]] || {
echo "Expected exactly nine verified release files." >&2
exit 1
}
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \
-f "ref=refs/tags/$RELEASE_TAG" -f "sha=$GITHUB_SHA" >/dev/null
tag_type="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_TAG" --jq '.object.type')"
tag_sha="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_TAG" --jq '.object.sha')"
[[ "$tag_type" == "commit" && "$tag_sha" == "$GITHUB_SHA" ]] || {
echo "Release tag does not point directly at the verified main commit." >&2
exit 1
}
gh release create "$RELEASE_TAG" \
"${assets[@]}" \
--draft \
--verify-tag \
--generate-notes \
--target "$GITHUB_SHA" \
--title "FoxHole Guard $VERSION_NAME"
releases_json="$RUNNER_TEMP/draft-releases.json"
gh api -X GET "repos/$GITHUB_REPOSITORY/releases" -f per_page=100 > "$releases_json"
release_id="$(
jq -er \
--arg tag "$RELEASE_TAG" '
[.[] | select(.tag_name == $tag and .draft == true)] |
if length == 1 then .[0].id else error("expected exactly one draft release") end
' \
"$releases_json"
)"
release_json="$RUNNER_TEMP/draft-release.json"
gh api "repos/$GITHUB_REPOSITORY/releases/$release_id" > "$release_json"
published_dir="$RUNNER_TEMP/published-release"
mkdir -p "$published_dir"
for source in "${assets[@]}"; do
published="$published_dir/$(basename "$source")"
asset_id="$(
jq -er \
--arg name "$(basename "$source")" '
[.assets[] | select(.name == $name)] |
if length == 1 then .[0].id else error("expected exactly one release asset") end
' \
"$release_json"
)"
gh api -H 'Accept: application/octet-stream' \
"repos/$GITHUB_REPOSITORY/releases/assets/$asset_id" > "$published"
[[ -f "$published" ]] || {
echo "Draft release is missing $(basename "$source")." >&2
exit 1
}
cmp --silent "$source" "$published" || {
echo "Published bytes differ for $(basename "$source")." >&2
exit 1
}
done
tag_type="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_TAG" --jq '.object.type')"
tag_sha="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_TAG" --jq '.object.sha')"
[[ "$tag_type" == "commit" && "$tag_sha" == "$GITHUB_SHA" ]] || {
echo "Release tag does not point directly at the verified main commit." >&2
exit 1
}
gh api --method PATCH \
"repos/$GITHUB_REPOSITORY/releases/$release_id" \
-F draft=false >/dev/null
gh release edit "$RELEASE_TAG" --draft=false --latest
is_draft="$(gh release view "$RELEASE_TAG" --json isDraft --jq '.isDraft')"
[[ "$is_draft" == "false" ]] || {
echo "Release was not published after byte verification." >&2
exit 1
}