Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,42 +65,27 @@ jobs:
exit 1
fi

- name: Prepare release signing
- name: Restore release signing bundle
shell: bash
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_SIGNING_BUNDLE_BASE64: ${{ secrets.ANDROID_SIGNING_BUNDLE_BASE64 }}
run: |
missing=0
for name in ANDROID_KEYSTORE_BASE64 ANDROID_KEYSTORE_PASSWORD ANDROID_KEY_ALIAS ANDROID_KEY_PASSWORD
do
if [[ -z "${!name}" ]]; then
echo "::error::Missing GitHub Actions secret: $name"
missing=1
fi
done

if [[ "$missing" -ne 0 ]]; then
echo "::error::Add the four Android signing secrets in Settings → Secrets and variables → Actions."
if [[ -z "$ANDROID_SIGNING_BUNDLE_BASE64" ]]; then
echo "::error::Missing GitHub Actions secret: ANDROID_SIGNING_BUNDLE_BASE64"
echo "::error::Add the signing bundle under Settings → Secrets and variables → Actions."
exit 1
fi

mkdir -p keystore
printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > keystore/livetube.jks
printf '%s' "$ANDROID_SIGNING_BUNDLE_BASE64" |
base64 --decode |
tar -xzf -

# Escape backslashes so Java's .properties parser preserves passwords exactly.
escape_properties() {
printf '%s' "$1" | sed 's/\\/\\\\/g'
}
if [[ ! -f keystore.properties || ! -f keystore/livetube.jks ]]; then
echo "::error::Signing bundle must contain keystore.properties and keystore/livetube.jks."
exit 1
fi

{
printf 'storeFile=keystore/livetube.jks\n'
printf 'storePassword=%s\n' "$(escape_properties "$ANDROID_KEYSTORE_PASSWORD")"
printf 'keyAlias=%s\n' "$(escape_properties "$ANDROID_KEY_ALIAS")"
printf 'keyPassword=%s\n' "$(escape_properties "$ANDROID_KEY_PASSWORD")"
} > keystore.properties
chmod 600 keystore.properties keystore/livetube.jks

- name: Build release APK
shell: bash
Expand All @@ -126,13 +111,35 @@ jobs:

"$APKSIGNER" verify --verbose "$SOURCE_APK"

EXPECTED_CERT_SHA256="e886ffeda178fc4e92bcc741f7966c659466c0a6363988c6f1ea027021afc95a"
ACTUAL_CERT_SHA256="$(
"$APKSIGNER" verify --print-certs "$SOURCE_APK" |
sed -nE 's/^Signer #1 certificate SHA-256 digest: ([0-9a-fA-F]+)$/\1/p' |
head -n 1 |
tr '[:upper:]' '[:lower:]'
)"

if [[ "$ACTUAL_CERT_SHA256" != "$EXPECTED_CERT_SHA256" ]]; then
echo "::error::Release APK was signed with the wrong certificate."
echo "::error::Expected SHA-256: $EXPECTED_CERT_SHA256"
echo "::error::Actual SHA-256: $ACTUAL_CERT_SHA256"
exit 1
fi

RELEASE_APK="LiveTube-${{ steps.version.outputs.tag }}.apk"
cp "$SOURCE_APK" "$RELEASE_APK"
sha256sum "$RELEASE_APK" > "$RELEASE_APK.sha256"

echo "apk=$RELEASE_APK" >> "$GITHUB_OUTPUT"
echo "checksum=$RELEASE_APK.sha256" >> "$GITHUB_OUTPUT"

- name: Remove signing material
if: always()
shell: bash
run: |
rm -f keystore.properties
rm -rf keystore

- name: Publish GitHub Release
shell: bash
env:
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ The repository includes a **Build and Release APK** GitHub Action that you can s

### One-time signing setup

Add these repository secrets under **Settings → Secrets and variables → Actions**:
The release action uses a single repository secret named `ANDROID_SIGNING_BUNDLE_BASE64`. It contains both `keystore.properties` and `keystore/livetube.jks`, so there is only one value to configure.

- `ANDROID_KEYSTORE_BASE64` — the release keystore encoded as one-line Base64
- `ANDROID_KEYSTORE_PASSWORD`
- `ANDROID_KEY_ALIAS`
- `ANDROID_KEY_PASSWORD`

On Linux, encode the same keystore you use for local releases with:
Create the bundle on Linux:

```bash
base64 -w 0 keystore/livetube.jks
mkdir -p /tmp/livetube-signing/keystore
cp keystore.properties /tmp/livetube-signing/
cp keystore/livetube.jks /tmp/livetube-signing/keystore/
tar -C /tmp/livetube-signing -czf - keystore.properties keystore/livetube.jks | base64 -w 0
```

Copy that output into the `ANDROID_KEYSTORE_BASE64` secret. Never commit the keystore or any of these values to the repository.
Add the resulting one-line value under **Settings → Secrets and variables → Actions** as `ANDROID_SIGNING_BUNDLE_BASE64`.

The workflow also verifies the release APK against LiveTube's expected signing-certificate SHA-256 fingerprint before publishing. Never commit the keystore, signing bundle, or passwords to the repository.

### Publishing a release

Expand Down
Loading