mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
The keystore used to be decoded into the environment of steps that run repository code (scripts/gen-strings.mjs, the Gradle build), and the workflow triggers on any android-v* tag, which can point at a commit that was never reviewed. Split it the way linux.yml already splits build and publish: - apk: builds the unsigned APK from the repo, contents: read, no secrets - sign: zipalign + apksigner over the artifact, keystore only, no repo code - publish: gh release from the signed artifact, contents: write, no checkout workflow_dispatch still yields the signed APK artifact without publishing; an android-v* tag publishes the release as before.
147 lines
5.9 KiB
YAML
147 lines
5.9 KiB
YAML
name: Android release
|
|
|
|
# A signed APK of Coucou for Android, built here so a release never depends on one machine.
|
|
#
|
|
# - Run it by hand (Actions → Android release → Run workflow) to get the signed APK as an artifact, without publishing.
|
|
# - Push an `android-v*` tag (for example android-v0.1.0) to publish it in a GitHub release.
|
|
#
|
|
# The release key lives only in two repository secrets: ANDROID_KEYSTORE_BASE64 (the .jks file, base64) and
|
|
# ANDROID_KEYSTORE_PASSWORD. Keep a backup of the .jks and its password outside GitHub: an app signed with a lost key can never
|
|
# be updated in place.
|
|
#
|
|
# The key never meets repository code, the same split as the Linux workflow: the apk job builds the unsigned APK
|
|
# from the repo with no secrets at all; the sign job runs nothing but the runner's own build-tools binaries with
|
|
# the keystore; the publish job carries the release token and runs nothing from the repo either.
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'android-v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
apk:
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
defaults: { run: { working-directory: android } }
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with: { persist-credentials: false }
|
|
- uses: actions/setup-java@v6
|
|
with: { distribution: temurin, java-version: '17' }
|
|
- uses: actions/setup-node@v7
|
|
with: { node-version: '22' }
|
|
- uses: gradle/actions/setup-gradle@v5
|
|
|
|
- name: Version
|
|
id: version
|
|
run: |
|
|
v=$(sed -nE 's/^[[:space:]]*versionName = "([^"]+)".*/\1/p' app/build.gradle.kts)
|
|
test -n "$v" || { echo "no versionName in app/build.gradle.kts"; exit 1; }
|
|
echo "version=$v" >> "$GITHUB_OUTPUT"
|
|
if [[ "$GITHUB_REF" == refs/tags/android-v* ]]; then
|
|
tag="${GITHUB_REF_NAME#android-v}"
|
|
test "$tag" = "$v" || { echo "the tag says $tag but versionName is $v"; exit 1; }
|
|
fi
|
|
|
|
- name: Unsigned release APK
|
|
run: |
|
|
node scripts/gen-strings.mjs --check
|
|
./gradlew assembleRelease --console=plain
|
|
apk=app/build/outputs/apk/release/app-release-unsigned.apk
|
|
test -f "$apk" || { echo "no unsigned release APK at $apk"; ls app/build/outputs/apk/release/; exit 1; }
|
|
mkdir -p ../release-unsigned
|
|
cp "$apk" ../release-unsigned/
|
|
cp app/build/outputs/mapping/release/mapping.txt ../release-unsigned/
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: unsigned-apk
|
|
path: release-unsigned/
|
|
retention-days: 3
|
|
|
|
sign:
|
|
needs: apk
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: unsigned-apk
|
|
|
|
- name: The release key
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
|
run: |
|
|
test -n "$KEYSTORE_BASE64" || { echo "ANDROID_KEYSTORE_BASE64 is not set: refusing to build an unsigned release"; exit 1; }
|
|
echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.jks"
|
|
|
|
- name: Signed release APK
|
|
env:
|
|
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
|
VERSION: ${{ needs.apk.outputs.version }}
|
|
run: |
|
|
test -n "$KEYSTORE_PASSWORD" || { echo "ANDROID_KEYSTORE_PASSWORD is not set: refusing to build an unsigned release"; exit 1; }
|
|
bt="$(find "$ANDROID_HOME"/build-tools -mindepth 1 -maxdepth 1 | sort -V | tail -1)"
|
|
v="$VERSION"
|
|
# Nothing from the repository runs in this job: only the runner's own
|
|
# zipalign and apksigner, over the artifact built by the apk job.
|
|
"$bt/zipalign" -p -f 4 app-release-unsigned.apk aligned.apk
|
|
"$bt/apksigner" sign \
|
|
--ks "$RUNNER_TEMP/release.jks" \
|
|
--ks-key-alias coucou \
|
|
--ks-pass env:KEYSTORE_PASSWORD \
|
|
--key-pass env:KEYSTORE_PASSWORD \
|
|
--out "Coucou-Android-$v.apk" \
|
|
aligned.apk
|
|
rm -f "$RUNNER_TEMP/release.jks" aligned.apk
|
|
"$bt/apksigner" verify --print-certs "Coucou-Android-$v.apk"
|
|
sha256sum "Coucou-Android-$v.apk" > SHA256SUMS
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: Coucou-Android-${{ needs.apk.outputs.version }}
|
|
path: |
|
|
Coucou-Android-*.apk
|
|
SHA256SUMS
|
|
mapping.txt
|
|
|
|
publish:
|
|
needs: [apk, sign]
|
|
if: startsWith(github.ref, 'refs/tags/android-v')
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: Coucou-Android-${{ needs.apk.outputs.version }}
|
|
|
|
- name: Publish the release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
VERSION: ${{ needs.apk.outputs.version }}
|
|
run: |
|
|
v="$VERSION"
|
|
notes="Coucou for Android $v, by Rhytam Biswas (@Rhytam23): your coding agents on your Android phone.
|
|
|
|
1. Download \`Coucou-Android-$v.apk\` on your phone (Android 11 or later) and open it. Android asks once to allow installs from your browser or file manager.
|
|
2. On your computer, Coucou 0.4.0 or later for Windows or Linux: Settings → Android phone, turn on Phone link, then Show pairing code.
|
|
3. Scan the code with the app. The phone and the computer must be on the same Wi-Fi.
|
|
|
|
Check the download with \`sha256sum -c SHA256SUMS\`. Guide and troubleshooting: https://github.com/Louis-CFM/coucou/blob/main/android/README.md"
|
|
# --latest=false: the macOS v* releases own the Latest slot, which the site's Download for Mac button points at.
|
|
gh release create "$GITHUB_REF_NAME" \
|
|
"Coucou-Android-$v.apk" \
|
|
"SHA256SUMS" \
|
|
--repo "$GITHUB_REPOSITORY" \
|
|
--title "Coucou for Android $v" \
|
|
--notes "$notes" \
|
|
--latest=false
|