Files
ProLibertateGames/.github/workflows/release.yml
T
Claude 80ff178437 Pin OTA releases to main and stop dev builds outranking them
Two ways the updater could have served or blocked the wrong build:

- release.yml also triggers on workflow_dispatch, which can be aimed at
  any branch from the Actions UI. That would have built dev code and
  published it as a real Release, which every install would then offer to
  download. The job now refuses to run off anything but main.

- versionCode came from GITHUB_RUN_NUMBER, but that counter is per
  workflow, so the dev pipeline had its own independent sequence. A debug
  APK installed from a CI artifact already carried a higher versionCode
  than the first several releases would, and the updater's check is
  latest <= installed, so those users would have been told they were up
  to date indefinitely. Only release.yml now sets PLG_RELEASE, and only
  that stamps a real version; everything else stays at 1.0.0-dev.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015qjfMiPUDshdKEUa6vxqzN
2026-08-05 23:47:20 +00:00

80 lines
2.7 KiB
YAML

name: Build and Release APK
# Build an APK and publish it as a GitHub Release whenever commits land on main
# (for example when a pull request is merged). Can also be run manually.
on:
push:
branches: [ main ]
workflow_dispatch:
# Allow the built-in token to create releases and upload the APK.
permissions:
contents: write
# Don't let two pushes to main race on the same release.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build APK and publish release
# workflow_dispatch can be aimed at any branch from the Actions UI. Releases
# are what the in-app updater installs, so only main may produce one —
# anything else is a no-op rather than shipping unreviewed code to everyone.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
# Tells the build this is a real release, so the APK is stamped with the
# run number that matches the tag below. Absent everywhere else, which
# keeps dev and local builds at 1.0.0-dev.
PLG_RELEASE: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: gradle
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Build debug APK
run: ./gradlew assembleDebug --no-daemon --stacktrace
- name: Stage APK for release
id: stage
run: |
set -euo pipefail
version="v1.0.${{ github.run_number }}"
src="app/build/outputs/apk/debug/app-debug.apk"
dest="ProLibertateGames-${version}.apk"
cp "$src" "$dest"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "apk=$dest" >> "$GITHUB_OUTPUT"
- name: Upload APK as workflow artifact
uses: actions/upload-artifact@v4
with:
name: ProLibertateGames-apk
path: ${{ steps.stage.outputs.apk }}
if-no-files-found: error
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh release create "${{ steps.stage.outputs.version }}" \
"${{ steps.stage.outputs.apk }}" \
--repo "${{ github.repository }}" \
--target "${{ github.sha }}" \
--title "ProLibertateGames ${{ steps.stage.outputs.version }}" \
--notes "Automated release built from \`${{ github.sha }}\` on push to \`main\`.
Download **${{ steps.stage.outputs.apk }}** below and install it on an Android device (you may need to allow *Install unknown apps*). This is a debug-signed build."