mirror of
https://github.com/VibedByKaKi/swile-android.git
synced 2026-12-05 16:48:52 +01:00
Parallel runs raced in the publish step. An older commit could finish last and replace the release APK with an outdated build. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
61 lines
2 KiB
YAML
61 lines
2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
# Run builds one at a time so the release publish always ends with the newest commit.
|
|
concurrency:
|
|
group: build-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
apk:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
- name: Download Gradle (retry on server errors)
|
|
run: |
|
|
for i in 1 2 3 4 5; do
|
|
./gradlew --version && exit 0
|
|
sleep $((i * 15))
|
|
done
|
|
exit 1
|
|
- name: Build release APK
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
VERSION_CODE: ${{ github.run_number }}
|
|
VERSION_NAME: 1.0.${{ github.run_number }}
|
|
run: |
|
|
if [ -n "$KEYSTORE_BASE64" ]; then
|
|
echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.keystore"
|
|
export KEYSTORE_FILE="$RUNNER_TEMP/release.keystore"
|
|
fi
|
|
./gradlew --no-daemon assembleRelease
|
|
- name: Publish APK as the latest release
|
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
cp app/build/outputs/apk/release/app-release.apk swile.apk
|
|
ls -l swile.apk
|
|
if gh release view latest >/dev/null 2>&1; then
|
|
gh release upload latest swile.apk --clobber
|
|
gh release edit latest --title "1.0.${GITHUB_RUN_NUMBER}" \
|
|
--notes "APK built from $GITHUB_SHA." --prerelease
|
|
else
|
|
gh release create latest swile.apk --target "$GITHUB_SHA" \
|
|
--prerelease --title "1.0.${GITHUB_RUN_NUMBER}" --notes "APK built from $GITHUB_SHA."
|
|
fi
|