Skip to content

ci: publish rolling nightly release #10708

ci: publish rolling nightly release

ci: publish rolling nightly release #10708

Workflow file for this run

name: Build APKs
on:
workflow_dispatch:
push:
# Feature branches are covered by "Build PR". Building them here too added
# four more APK builds on top of it for every push. Use workflow_dispatch
# when a branch needs nightly artifacts.
branches: ["main"]
paths-ignore:
- "README.md"
- "fastlane/**"
- "assets/**"
- ".github/**/*.md"
- ".github/FUNDING.yml"
- ".github/ISSUE_TEMPLATE/**"
permissions:
contents: write
discussions: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_release:
name: Build Release (${{ matrix.variant }})
if: github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
strategy:
matrix:
include:
# FOSS and Izzy differ from GMS only by ~80 lines of Cast stubs,
# plus the updater flag for Izzy (GMS and FOSS enable the updater,
# Izzy disables it). Both are still built by the release workflow,
# so building them nightly too doubled this workflow for almost no
# extra coverage.
- variant: gms
variantName: Gms
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: "21"
distribution: "temurin"
- name: Set Up Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_KEY }}
cache-cleanup: on-success
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Release APK
run: ./gradlew --console=plain assemble${{ matrix.variantName }}Release --warning-mode summary
env:
METROLIST_APPLICATION_ID: com.metrolist.music
METROLIST_APP_NAME: Metrolist Nightly
METROLIST_BUILD_COMMIT: ${{ github.sha }}
PULL_REQUEST: "false"
GITHUB_EVENT_NAME: ${{ github.event_name }}
LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
LASTFM_SECRET: ${{ secrets.LASTFM_SECRET }}
- name: Sign APK
uses: ilharp/sign-android-release@v2.0.0
with:
releaseDir: app/build/outputs/apk/${{ matrix.variant }}/release/
signingKey: ${{ secrets.KEYSTORE }}
keyAlias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
buildToolsVersion: 35.0.0
- name: Move signed APK
run: |
OUTPUT_DIR="app/build/outputs/apk/${{ matrix.variant }}/release"
mkdir -p "$OUTPUT_DIR/out"
if [ "${{ matrix.variant }}" = "gms" ]; then
TARGET_NAME="app-universal-with-Google-Cast.apk"
else
TARGET_NAME="app-universal-release.apk"
fi
find "$OUTPUT_DIR" -name "*-signed.apk" -o -name "*-unsigned-signed.apk" | xargs -I{} mv {} "$OUTPUT_DIR/out/$TARGET_NAME"
- name: Upload Signed APK
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.variant == 'gms' && 'app-with-Google-Cast' || 'app-release' }}
path: app/build/outputs/apk/${{ matrix.variant }}/release/out/*
build_debug:
name: Build Debug (${{ matrix.variant }})
if: github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
strategy:
matrix:
include:
# FOSS and Izzy differ from GMS only by ~80 lines of Cast stubs,
# plus the updater flag for Izzy (GMS and FOSS enable the updater,
# Izzy disables it). Both are still built by the release workflow,
# so building them nightly too doubled this workflow for almost no
# extra coverage.
- variant: gms
variantName: Gms
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: "21"
distribution: "temurin"
- name: Set Up Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-encryption-key: ${{ secrets.GRADLE_CACHE_KEY }}
cache-cleanup: on-success
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Restore Persistent Keystore
run: |
echo "${{ secrets.DEBUG_KEYSTORE }}" | base64 -d > ./app/persistent-debug.keystore
# Lint is intentionally not run in CI: it never gated a merge and added
# several minutes to every build. Run :app:lintGmsRelease locally.
- name: Build Debug APK
run: ./gradlew --console=plain assemble${{ matrix.variantName }}Debug --warning-mode summary
env:
METROLIST_APPLICATION_ID: com.metrolist.music
METROLIST_APP_NAME: Metrolist Nightly
METROLIST_BUILD_COMMIT: ${{ github.sha }}
PULL_REQUEST: "false"
GITHUB_EVENT_NAME: ${{ github.event_name }}
LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
LASTFM_SECRET: ${{ secrets.LASTFM_SECRET }}
- name: Upload Debug APK
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.variant == 'gms' && 'app-debug-gms' || 'app-debug' }}
path: app/build/outputs/apk/${{ matrix.variant }}/debug/*.apk
publish_nightly:
name: Publish Nightly Release
if: github.event_name == 'push'
needs: [build_release, build_debug]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Download Signed APK
uses: actions/download-artifact@v7
with:
name: app-with-Google-Cast
path: nightly
- name: Publish Nightly Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
mv nightly/app-universal-with-Google-Cast.apk nightly/Metrolist-with-Google-Cast.apk
if gh release view nightly > /dev/null 2>&1; then
gh release delete nightly --yes --cleanup-tag
elif gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/nightly" > /dev/null 2>&1; then
gh api --method DELETE "repos/$GITHUB_REPOSITORY/git/refs/tags/nightly"
fi
gh release create nightly \
nightly/Metrolist-with-Google-Cast.apk \
--target "$GITHUB_SHA" \
--title "Metrolist Nightly" \
--notes "Automated prerelease built from main at commit $GITHUB_SHA. It may be unstable." \
--generate-notes \
--prerelease \
--latest=false