Files
Haven/_HavenAndroid/.github/workflows/extract-secrets.yml
T

75 lines
2.8 KiB
YAML

name: Extract release-signing secrets (one-shot)
# Manual-only workflow that bundles the release keystore + signing passwords
# into a passphrase-encrypted tarball, uploads it as a 1-day artifact, then
# discards the cleartext. The encryption passphrase is the BUNDLE_PASSPHRASE
# repo secret (NOT a workflow_dispatch input — dispatch inputs are recorded in
# run metadata, which is public on a public repo). Decrypt locally with the
# same secret value:
#
# openssl enc -aes-256-cbc -pbkdf2 -iter 200000 -d \
# -pass pass:"$BUNDLE_PASSPHRASE" \
# -in bundle.tar.gz.enc -out bundle.tar.gz
# tar -xzf bundle.tar.gz
#
# The `haven-release.env` file inside is `source`-able and sets the same env
# vars the release workflow consumes.
on:
workflow_dispatch:
permissions:
contents: read
jobs:
extract:
runs-on: ubuntu-latest
# Reviewer-gated via the `signing` Environment so exporting the signing
# identity can't happen without an approval.
environment: signing
steps:
- name: Sanity-check passphrase is set and long enough
env:
PASSPHRASE: ${{ secrets.BUNDLE_PASSPHRASE }}
run: |
if [ "${#PASSPHRASE}" -lt 16 ]; then
echo "BUNDLE_PASSPHRASE secret is unset or shorter than 16 characters." >&2
exit 1
fi
- name: Bundle keystore + passwords (encrypted in-place)
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
PASSPHRASE: ${{ secrets.BUNDLE_PASSPHRASE }}
run: |
umask 077
# Reconstruct the keystore from base64.
printf '%s' "$KEYSTORE_BASE64" | base64 -d > haven-release.jks
# Write a source-able env file. printf %q shell-escapes each value
# so passwords containing $, !, ', etc. round-trip correctly.
{
printf 'export KEYSTORE_PASSWORD=%q\n' "$KEYSTORE_PASSWORD"
printf 'export KEY_ALIAS=%q\n' "$KEY_ALIAS"
printf 'export KEY_PASSWORD=%q\n' "$KEY_PASSWORD"
} > haven-release.env
tar -czf bundle.tar.gz haven-release.jks haven-release.env
openssl enc -aes-256-cbc -pbkdf2 -iter 200000 \
-pass env:PASSPHRASE \
-in bundle.tar.gz -out bundle.tar.gz.enc
# Wipe cleartext.
shred -u haven-release.jks haven-release.env bundle.tar.gz
- name: Upload encrypted bundle
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: signing-bundle
path: bundle.tar.gz.enc
retention-days: 1
if-no-files-found: error