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
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Android release

on:
push:
tags: ['v*']

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: '17'
- uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
with:
packages: 'platform-tools platforms;android-36 build-tools;36.0.0'
- name: Read the version from the tag
id: version
run: |
version="${GITHUB_REF_NAME#v}"
if [[ ! "$version" =~ ^([0-9]+)\.([0-9]{1,2})\.([0-9]{1,2})$ ]]; then
echo "::error::Tag $GITHUB_REF_NAME must be vMAJOR.MINOR.PATCH with MINOR and PATCH below 100"
exit 1
fi
echo "name=$version" >> "$GITHUB_OUTPUT"
echo "code=$((BASH_REMATCH[1] * 10000 + 10#${BASH_REMATCH[2]} * 100 + 10#${BASH_REMATCH[3]}))" >> "$GITHUB_OUTPUT"
- name: Restore the signing key and Firebase config
env:
KEYSTORE: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
run: |
echo "$KEYSTORE" | base64 --decode > "$RUNNER_TEMP/release.jks"
echo "$GOOGLE_SERVICES" | base64 --decode > app/google-services.json
- name: Build the signed APK
env:
CRUMBLE_KEYSTORE_PATH: ${{ runner.temp }}/release.jks
CRUMBLE_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
run: >-
./gradlew assembleRelease
-Pcrumble.versionName=${{ steps.version.outputs.name }}
-Pcrumble.versionCode=${{ steps.version.outputs.code }}
- name: Publish the GitHub release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.name }}
run: |
apk="crumble-$VERSION.apk"
cp app/build/outputs/apk/release/app-release.apk "$apk"
gh release create "$GITHUB_REF_NAME" "$apk" --repo "$GITHUB_REPOSITORY" --title "Crumble $VERSION" --generate-notes
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Publish signed release APKs: a `vX.Y.Z` tag builds one with FCM and attaches it to a GitHub release. Release builds are signed when `CRUMBLE_KEYSTORE_PATH` and `CRUMBLE_KEYSTORE_PASSWORD` are set, and take their version from `crumble.versionName` and `crumble.versionCode`.
- The bot form shows the portrait with a pencil, and the avatar editor opens in a dialog instead of filling the form, as on the web.
- Pin the bot's `6.0.0` contract as a local export and bump the generator to `1.1.0`, adding closed objects with declared properties, nullable named schemas and `allOf` parts, and `*/*` binary responses.
- Sign in with account email and password. The server token is gone; the app stores the returned session.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ python3 scripts/contract.py update --release contract-vX.Y.Z # Update to a publi
python3 scripts/contract.py update --local EXPORT_DIR # Update from a local bot bundle
```

## Release

Pushing a `vMAJOR.MINOR.PATCH` tag runs `.github/workflows/release.yml`, which builds a signed release APK with FCM and attaches it to a GitHub release. The version code is `MAJOR * 10000 + MINOR * 100 + PATCH`, so minor and patch stay below 100.

The workflow reads three repository secrets: `ANDROID_KEYSTORE_BASE64` (the base64 of the release keystore), `ANDROID_KEYSTORE_PASSWORD`, and `GOOGLE_SERVICES_JSON_BASE64`. Every update must be signed with the same keystore, alias `crumble`, so keep a backup of it.

To sign a release build locally:

```bash
CRUMBLE_KEYSTORE_PATH=~/crumble-release.jks CRUMBLE_KEYSTORE_PASSWORD=... ./gradlew assembleRelease
```

## Push notifications (optional)

Without `app/google-services.json`, the app builds cleanly and posts local notifications while connected to `/v1/events`. To enable background delivery via Firebase Cloud Messaging (FCM), place `google-services.json` registering `ng.crumbli.android` and `ng.crumbli.android.dev` in `app/` and set `CRUMBLE_FCM_SERVICE_ACCOUNT_PATH` on the server (see `bot/docs/native-push.md`).
18 changes: 16 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ android {
applicationId = "ng.crumbli.android"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "1.0"
versionCode = providers.gradleProperty("crumble.versionCode").orNull?.toInt() ?: 1
versionName = providers.gradleProperty("crumble.versionName").orNull ?: "1.0"
}

// Release signing needs the key, which only CI and the maintainer have; without it, release builds stay unsigned.
val releaseKeystore = providers.environmentVariable("CRUMBLE_KEYSTORE_PATH").orNull
signingConfigs {
if (releaseKeystore != null) {
create("release") {
storeFile = file(releaseKeystore)
storePassword = providers.environmentVariable("CRUMBLE_KEYSTORE_PASSWORD").get()
keyAlias = "crumble"
keyPassword = storePassword
}
}
}

buildTypes {
Expand All @@ -27,6 +40,7 @@ android {
applicationIdSuffix = ".dev"
}
release {
signingConfig = signingConfigs.findByName("release")
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
Expand Down
Loading