feat: add Android release signing and user remapping
Lint / Lint (push) Successful in 1m2s
Security / Secrets (gitleaks) (push) Successful in 1m11s
Tests / Dashboard checks (push) Successful in 1m17s
Security / Dependencies (Trivy) (push) Successful in 1m20s
Security / Code (Semgrep) (push) Successful in 3m15s
Tests / Go backend (push) Successful in 3m29s
Docker / Docker Build & Push (push) Successful in 8m42s
Lint / Lint (push) Successful in 1m2s
Security / Secrets (gitleaks) (push) Successful in 1m11s
Tests / Dashboard checks (push) Successful in 1m17s
Security / Dependencies (Trivy) (push) Successful in 1m20s
Security / Code (Semgrep) (push) Successful in 3m15s
Tests / Go backend (push) Successful in 3m29s
Docker / Docker Build & Push (push) Successful in 8m42s
- Add release signing configuration and static debug-key workflow - Add a CLI to remap legacy users to AuthGuard accounts
This commit is contained in:
1 parent
817236f349
commit
7150ebd13e
8 files changed
+1553
-2
No files matched your search
@@ -0,0 +1,223 @@
|
||||
name: Android Release (static debug key)
|
||||
|
||||
# Same flow as android-release.yml, but the APK is signed with a static debug key instead of the
|
||||
# release keystore. The key is created on the first run, committed to CollabTableAndroid/signing/, and
|
||||
# reused by every later run, so builds from this workflow can update each other in place. It is for
|
||||
# test builds only: the release keystore is secret and this key is not.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump_type:
|
||||
description: 'Version bump type'
|
||||
required: true
|
||||
default: 'patch'
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
changelog:
|
||||
description: 'Changelog for this release (leave blank to auto-generate from commits)'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
# The first run creates the key and pushes it. Queue runs so that a later run sees the key instead of
|
||||
# creating a second one.
|
||||
concurrency:
|
||||
group: android-release-static-debug
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Bump version, build & release (static debug key)
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
# Android debug keystore conventions (password "android", alias "androiddebugkey").
|
||||
STATIC_KEYSTORE: CollabTableAndroid/signing/static-debug.jks
|
||||
STATIC_STORE_PASSWORD: android
|
||||
STATIC_KEY_ALIAS: androiddebugkey
|
||||
STATIC_KEY_PASSWORD: android
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
fetch-depth: 0
|
||||
|
||||
# Java comes first: the key is checked with keytool before anything is pushed.
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
# A key is generated only when the repository has never held one. If the file was committed
|
||||
# before but is now missing, the run stops: a new key would change the certificate and break
|
||||
# in-place updates for every installed copy.
|
||||
- name: Prepare static debug key
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -f "$STATIC_KEYSTORE" ]; then
|
||||
echo "Reusing the static debug key in $STATIC_KEYSTORE"
|
||||
elif [ -n "$(git log --all --format=%H -- "$STATIC_KEYSTORE")" ]; then
|
||||
echo "::error::$STATIC_KEYSTORE exists in the repository history but not on this branch. Restore it (merge or cherry-pick) instead of generating a new key."
|
||||
exit 1
|
||||
else
|
||||
mkdir -p "$(dirname "$STATIC_KEYSTORE")"
|
||||
keytool -genkeypair -noprompt \
|
||||
-keystore "$STATIC_KEYSTORE" \
|
||||
-storetype PKCS12 \
|
||||
-storepass:env STATIC_STORE_PASSWORD \
|
||||
-keypass:env STATIC_KEY_PASSWORD \
|
||||
-alias "$STATIC_KEY_ALIAS" \
|
||||
-keyalg RSA -keysize 2048 -validity 10000 \
|
||||
-dname "CN=Android Debug,O=Android,C=US"
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add "$STATIC_KEYSTORE"
|
||||
git commit -m "chore(android): add static debug signing key"
|
||||
git push
|
||||
echo "Created the static debug key and pushed it to the repository."
|
||||
fi
|
||||
FINGERPRINT=$(keytool -list -v -keystore "$STATIC_KEYSTORE" -storepass:env STATIC_STORE_PASSWORD \
|
||||
-alias "$STATIC_KEY_ALIAS" | sed -n 's/^[[:space:]]*SHA256: //p')
|
||||
echo "::notice::Static debug certificate SHA-256: $FINGERPRINT"
|
||||
|
||||
- name: Bump version in build.gradle.kts
|
||||
id: version
|
||||
shell: bash
|
||||
env:
|
||||
BUMP_TYPE: ${{ inputs.bump_type }}
|
||||
run: |
|
||||
GRADLE_FILE="CollabTableAndroid/app/build.gradle"
|
||||
|
||||
CURRENT_CODE=$(grep -oP 'versionCode\s*=\s*\K[0-9]+' "$GRADLE_FILE")
|
||||
CURRENT_NAME=$(grep -oP 'versionName\s*=\s*"\K[^"]+' "$GRADLE_FILE")
|
||||
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_NAME"
|
||||
|
||||
case "$BUMP_TYPE" in
|
||||
major) MAJOR=$((MAJOR+1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR+1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH+1)) ;;
|
||||
esac
|
||||
|
||||
NEW_CODE=$((CURRENT_CODE+1))
|
||||
NEW_NAME="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
sed -i "s/versionCode = ${CURRENT_CODE}/versionCode = ${NEW_CODE}/" "$GRADLE_FILE"
|
||||
sed -i "s/versionName = \"${CURRENT_NAME}\"/versionName = \"${NEW_NAME}\"/" "$GRADLE_FILE"
|
||||
|
||||
{
|
||||
echo "new_code=${NEW_CODE}"
|
||||
echo "new_name=${NEW_NAME}"
|
||||
echo "tag=v${NEW_NAME}-debug"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Commit version bump
|
||||
shell: bash
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add CollabTableAndroid/app/build.gradle
|
||||
git commit -m "chore(android): bump version to ${{ steps.version.outputs.new_name }} (code ${{ steps.version.outputs.new_code }})"
|
||||
git push
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Install Android SDK
|
||||
uses: android-actions/setup-android@v4
|
||||
|
||||
- name: Accept SDK licenses
|
||||
shell: bash
|
||||
run: yes | sdkmanager --licenses || true
|
||||
|
||||
- name: Install Android SDK packages
|
||||
shell: bash
|
||||
run: |
|
||||
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
|
||||
|
||||
- name: Run lint and ktlint
|
||||
working-directory: CollabTableAndroid
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew --no-daemon lintDebug ktlintCheck
|
||||
|
||||
# The release build type picks up the signing config from these variables, so the static key
|
||||
# is used without any change to the Gradle build.
|
||||
- name: Build release APK signed with the static debug key
|
||||
working-directory: CollabTableAndroid
|
||||
shell: bash
|
||||
env:
|
||||
OGS_KEYSTORE_FILE: ${{ github.workspace }}/${{ env.STATIC_KEYSTORE }}
|
||||
OGS_KEYSTORE_PASSWORD: ${{ env.STATIC_STORE_PASSWORD }}
|
||||
OGS_KEY_ALIAS: ${{ env.STATIC_KEY_ALIAS }}
|
||||
OGS_KEY_PASSWORD: ${{ env.STATIC_KEY_PASSWORD }}
|
||||
run: ./gradlew --no-daemon assembleRelease
|
||||
|
||||
- name: Verify APK is signed with the static debug key
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
APK="CollabTableAndroid/app/build/outputs/apk/release/app-release.apk"
|
||||
APKSIGNER="$ANDROID_HOME/build-tools/36.0.0/apksigner"
|
||||
CERTS=$("$APKSIGNER" verify --print-certs "$APK")
|
||||
ACTUAL=$(printf '%s\n' "$CERTS" | sed -n 's/^Signer #1 certificate SHA-256 digest: //p')
|
||||
EXPECTED=$(keytool -list -v -keystore "$STATIC_KEYSTORE" -storepass:env STATIC_STORE_PASSWORD \
|
||||
-alias "$STATIC_KEY_ALIAS" | sed -n 's/^[[:space:]]*SHA256: //p' | tr -d ':' | tr 'A-F' 'a-f')
|
||||
if [ "$ACTUAL" != "$EXPECTED" ]; then
|
||||
echo "::error::APK is signed with $ACTUAL, expected the static debug key $EXPECTED."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Rename APK with version
|
||||
shell: bash
|
||||
run: |
|
||||
SRC="CollabTableAndroid/app/build/outputs/apk/release/app-release.apk"
|
||||
cp "$SRC" "CollabTable-${{ steps.version.outputs.tag }}.apk"
|
||||
|
||||
- name: Generate changelog
|
||||
shell: bash
|
||||
env:
|
||||
CHANGELOG_INPUT: ${{ inputs.changelog }}
|
||||
run: |
|
||||
if [ -n "$CHANGELOG_INPUT" ]; then
|
||||
printf '%s' "$CHANGELOG_INPUT" > release-notes.md
|
||||
else
|
||||
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||
if [ -n "$LAST_TAG" ]; then
|
||||
RANGE="${LAST_TAG}..HEAD"
|
||||
else
|
||||
RANGE="HEAD"
|
||||
fi
|
||||
COMMITS=$(git log "$RANGE" --pretty=format:"%s" | grep -vE "^chore\(android\): (bump version|add static debug signing key)" || true)
|
||||
FEATURES=$(echo "$COMMITS" | grep -E "^feat(\\(.+\\))?:" | sed 's/^feat[^:]*: /- /' || true)
|
||||
FIXES=$(echo "$COMMITS" | grep -E "^fix(\\(.+\\))?:" | sed 's/^fix[^:]*: /- /' || true)
|
||||
OTHERS=$(echo "$COMMITS" | grep -vE "^(feat|fix)(\\(.+\\))?:" | grep -v '^$' | sed 's/^/- /' || true)
|
||||
{
|
||||
if [ -n "$FEATURES" ]; then printf '### Features\n%s\n\n' "$FEATURES"; fi
|
||||
if [ -n "$FIXES" ]; then printf '### Bug Fixes\n%s\n\n' "$FIXES"; fi
|
||||
if [ -n "$OTHERS" ]; then printf '### Other Changes\n%s\n\n' "$OTHERS"; fi
|
||||
} > release-notes.md
|
||||
if [ ! -s release-notes.md ]; then echo 'No changes recorded.' > release-notes.md; fi
|
||||
fi
|
||||
|
||||
# Marked as a pre-release so it never takes the "Latest" badge from the real release.
|
||||
- name: Create GitHub pre-release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.tag }}
|
||||
name: ${{ steps.version.outputs.tag }} (static debug key)
|
||||
body_path: release-notes.md
|
||||
files: CollabTable-${{ steps.version.outputs.tag }}.apk
|
||||
prerelease: true
|
||||
fail_on_unmatched_files: true
|
||||
@@ -0,0 +1,208 @@
|
||||
name: Android Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump_type:
|
||||
description: 'Version bump type'
|
||||
required: true
|
||||
default: 'patch'
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
changelog:
|
||||
description: 'Changelog for this release (leave blank to auto-generate from commits)'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Bump version, build & release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
fetch-depth: 0
|
||||
|
||||
# Java comes first: the signing key is checked with keytool before anything is pushed.
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Prepare release signing key
|
||||
shell: bash
|
||||
env:
|
||||
OGS_KEYSTORE_BASE64: ${{ secrets.OGS_KEYSTORE_BASE64 }}
|
||||
OGS_KEYSTORE_PASSWORD: ${{ secrets.OGS_KEYSTORE_PASSWORD }}
|
||||
OGS_KEY_ALIAS: ${{ secrets.OGS_KEY_ALIAS }}
|
||||
OGS_KEY_PASSWORD: ${{ secrets.OGS_KEY_PASSWORD }}
|
||||
OGS_RELEASE_CERT_SHA256: ${{ vars.OGS_RELEASE_CERT_SHA256 }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
for name in OGS_KEYSTORE_BASE64 OGS_KEYSTORE_PASSWORD OGS_KEY_ALIAS OGS_KEY_PASSWORD; do
|
||||
if [ -z "${!name}" ]; then
|
||||
echo "::error::Secret $name is not set. Releases must be signed with the release key."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
KEYSTORE="$RUNNER_TEMP/ogs-release.jks"
|
||||
printf '%s' "$OGS_KEYSTORE_BASE64" | base64 -d > "$KEYSTORE"
|
||||
|
||||
# Fail before the version bump is pushed if the keystore is not the pinned release key.
|
||||
ACTUAL=$(keytool -list -v -keystore "$KEYSTORE" -storepass:env OGS_KEYSTORE_PASSWORD \
|
||||
-alias "$OGS_KEY_ALIAS" | sed -n 's/^[[:space:]]*SHA256: //p' | tr -d ':' | tr 'A-F' 'a-f')
|
||||
EXPECTED=$(printf '%s' "$OGS_RELEASE_CERT_SHA256" | tr -d ':' | tr 'A-F' 'a-f')
|
||||
if [ -z "$EXPECTED" ]; then
|
||||
echo "::error::Variable OGS_RELEASE_CERT_SHA256 is not set. Set it to $ACTUAL."
|
||||
exit 1
|
||||
fi
|
||||
if [ "$ACTUAL" != "$EXPECTED" ]; then
|
||||
echo "::error::Release keystore certificate is $ACTUAL, expected $EXPECTED."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Bump version in build.gradle.kts
|
||||
id: version
|
||||
shell: bash
|
||||
env:
|
||||
BUMP_TYPE: ${{ inputs.bump_type }}
|
||||
run: |
|
||||
GRADLE_FILE="CollabTableAndroid/app/build.gradle"
|
||||
|
||||
CURRENT_CODE=$(grep -oP 'versionCode\s*=\s*\K[0-9]+' "$GRADLE_FILE")
|
||||
CURRENT_NAME=$(grep -oP 'versionName\s*=\s*"\K[^"]+' "$GRADLE_FILE")
|
||||
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_NAME"
|
||||
|
||||
case "$BUMP_TYPE" in
|
||||
major) MAJOR=$((MAJOR+1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR+1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH+1)) ;;
|
||||
esac
|
||||
|
||||
NEW_CODE=$((CURRENT_CODE+1))
|
||||
NEW_NAME="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
sed -i "s/versionCode = ${CURRENT_CODE}/versionCode = ${NEW_CODE}/" "$GRADLE_FILE"
|
||||
sed -i "s/versionName = \"${CURRENT_NAME}\"/versionName = \"${NEW_NAME}\"/" "$GRADLE_FILE"
|
||||
|
||||
{
|
||||
echo "new_code=${NEW_CODE}"
|
||||
echo "new_name=${NEW_NAME}"
|
||||
echo "tag=v${NEW_NAME}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Commit version bump
|
||||
shell: bash
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add CollabTableAndroid/app/build.gradle
|
||||
git commit -m "chore(android): bump version to ${{ steps.version.outputs.new_name }} (code ${{ steps.version.outputs.new_code }})"
|
||||
git push
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Install Android SDK
|
||||
uses: android-actions/setup-android@v4
|
||||
|
||||
- name: Accept SDK licenses
|
||||
shell: bash
|
||||
run: yes | sdkmanager --licenses || true
|
||||
|
||||
- name: Install Android SDK packages
|
||||
shell: bash
|
||||
run: |
|
||||
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
|
||||
|
||||
- name: Run lint and ktlint
|
||||
working-directory: CollabTableAndroid
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew --no-daemon lintDebug ktlintCheck
|
||||
|
||||
- name: Build signed release APK
|
||||
working-directory: CollabTableAndroid
|
||||
shell: bash
|
||||
env:
|
||||
OGS_KEYSTORE_FILE: ${{ runner.temp }}/ogs-release.jks
|
||||
OGS_KEYSTORE_PASSWORD: ${{ secrets.OGS_KEYSTORE_PASSWORD }}
|
||||
OGS_KEY_ALIAS: ${{ secrets.OGS_KEY_ALIAS }}
|
||||
OGS_KEY_PASSWORD: ${{ secrets.OGS_KEY_PASSWORD }}
|
||||
run: ./gradlew --no-daemon assembleRelease
|
||||
|
||||
- name: Verify APK is signed with the release key
|
||||
shell: bash
|
||||
env:
|
||||
OGS_RELEASE_CERT_SHA256: ${{ vars.OGS_RELEASE_CERT_SHA256 }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
APK="CollabTableAndroid/app/build/outputs/apk/release/app-release.apk"
|
||||
APKSIGNER="$ANDROID_HOME/build-tools/36.0.0/apksigner"
|
||||
CERTS=$("$APKSIGNER" verify --print-certs "$APK")
|
||||
ACTUAL=$(printf '%s\n' "$CERTS" | sed -n 's/^Signer #1 certificate SHA-256 digest: //p')
|
||||
EXPECTED=$(printf '%s' "$OGS_RELEASE_CERT_SHA256" | tr -d ':' | tr 'A-F' 'a-f')
|
||||
if [ "$ACTUAL" != "$EXPECTED" ]; then
|
||||
echo "::error::APK is signed with $ACTUAL, expected $EXPECTED."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Rename APK with version
|
||||
shell: bash
|
||||
run: |
|
||||
SRC="CollabTableAndroid/app/build/outputs/apk/release/app-release.apk"
|
||||
cp "$SRC" "CollabTable-${{ steps.version.outputs.tag }}.apk"
|
||||
|
||||
- name: Generate changelog
|
||||
shell: bash
|
||||
env:
|
||||
CHANGELOG_INPUT: ${{ inputs.changelog }}
|
||||
run: |
|
||||
if [ -n "$CHANGELOG_INPUT" ]; then
|
||||
printf '%s' "$CHANGELOG_INPUT" > release-notes.md
|
||||
else
|
||||
# Skip the static debug pre-releases, so the notes cover everything since the last public release.
|
||||
LAST_TAG=$(git describe --tags --abbrev=0 --exclude '*-debug' 2>/dev/null || echo "")
|
||||
if [ -n "$LAST_TAG" ]; then
|
||||
RANGE="${LAST_TAG}..HEAD"
|
||||
else
|
||||
RANGE="HEAD"
|
||||
fi
|
||||
COMMITS=$(git log "$RANGE" --pretty=format:"%s" | grep -vE "^chore\(android\): (bump version|add static debug signing key)" || true)
|
||||
FEATURES=$(echo "$COMMITS" | grep -E "^feat(\\(.+\\))?:" | sed 's/^feat[^:]*: /- /' || true)
|
||||
FIXES=$(echo "$COMMITS" | grep -E "^fix(\\(.+\\))?:" | sed 's/^fix[^:]*: /- /' || true)
|
||||
OTHERS=$(echo "$COMMITS" | grep -vE "^(feat|fix)(\\(.+\\))?:" | grep -v '^$' | sed 's/^/- /' || true)
|
||||
{
|
||||
if [ -n "$FEATURES" ]; then printf '### Features\n%s\n\n' "$FEATURES"; fi
|
||||
if [ -n "$FIXES" ]; then printf '### Bug Fixes\n%s\n\n' "$FIXES"; fi
|
||||
if [ -n "$OTHERS" ]; then printf '### Other Changes\n%s\n\n' "$OTHERS"; fi
|
||||
} > release-notes.md
|
||||
if [ ! -s release-notes.md ]; then echo 'No changes recorded.' > release-notes.md; fi
|
||||
fi
|
||||
|
||||
- name: Create GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.version.outputs.tag }}
|
||||
name: ${{ steps.version.outputs.tag }}
|
||||
body_path: release-notes.md
|
||||
files: CollabTable-${{ steps.version.outputs.tag }}.apk
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
- name: Remove release keystore
|
||||
if: always()
|
||||
shell: bash
|
||||
run: rm -f "$RUNNER_TEMP/ogs-release.jks"
|
||||
Reference in new issue
Block a user