Nightly Alpha Build #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Alpha Build | |
| on: | |
| schedule: | |
| - cron: '0 4 * * *' | |
| workflow_dispatch: # allow manual trigger for testing | |
| jobs: | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_changes: ${{ steps.check.outputs.has_changes }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # full history required for --since | |
| - name: Check for commits in the last 24h | |
| id: check | |
| run: | | |
| COUNT=$(git log origin/main --since="24 hours ago" --oneline | wc -l) | |
| echo "Commits on main in the last 24h: $COUNT" | |
| if [ "$COUNT" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| echo "No new commits — skipping alpha build." | |
| fi | |
| build-alpha: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.has_changes == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Compute alpha version | |
| id: version | |
| run: | | |
| DATE=$(date -u +"%Y%m%d") | |
| RAW_VERSION=$(grep 'versionName' app/build.gradle.kts | sed 's/.*"\(.*\)".*/\1/') | |
| MAJOR_MINOR=$(echo "$RAW_VERSION" | cut -d. -f1,2) | |
| ALPHA_NAME="${MAJOR_MINOR}-alpha-${DATE}" | |
| # Monotonic versionCode from epoch/10 (~625 years of headroom) | |
| ALPHA_CODE=$(./scripts/bump-version-code.sh --dry-run) | |
| echo "name=${ALPHA_NAME}" >> $GITHUB_OUTPUT | |
| echo "code=${ALPHA_CODE}" >> $GITHUB_OUTPUT | |
| echo "Alpha version: ${ALPHA_NAME} (code ${ALPHA_CODE})" | |
| - name: Patch build.gradle.kts for alpha build | |
| run: | | |
| sed -i "s|versionCode = [0-9]*|versionCode = ${{ steps.version.outputs.code }}|" app/build.gradle.kts | |
| sed -i 's|versionName = "[^"]*"|versionName = "${{ steps.version.outputs.name }}"|' app/build.gradle.kts | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Setup keystore | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| if [ -n "$KEYSTORE_BASE64" ]; then | |
| echo "Using release keystore from secrets" | |
| echo "$KEYSTORE_BASE64" | base64 -d > app/release.keystore | |
| else | |
| echo "No keystore secret found, creating debug keystore" | |
| mkdir -p ~/.android | |
| keytool -genkey -v -keystore ~/.android/debug.keystore \ | |
| -storepass android -alias androiddebugkey -keypass android \ | |
| -keyalg RSA -keysize 2048 -validity 10000 \ | |
| -dname "CN=Android Debug,O=Android,C=US" | |
| fi | |
| - name: Build Release AAB | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| run: ./gradlew bundleRelease | |
| - name: Create alpha changelog for all locales | |
| run: | | |
| VCODE=${{ steps.version.outputs.code }} | |
| COMMIT_MSG=$(git log -1 --format="%h %s") | |
| CHANGELOG="Nightly alpha build ${{ steps.version.outputs.name }}: ${COMMIT_MSG}" | |
| for locale in en-US it-IT es-ES ca-ES; do | |
| mkdir -p fastlane/metadata/android/${locale}/changelogs | |
| echo "$CHANGELOG" > fastlane/metadata/android/${locale}/changelogs/${VCODE}.txt | |
| done | |
| - name: Upload to Google Play (closed test / alpha track) | |
| id: play-upload | |
| continue-on-error: true | |
| env: | |
| GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} | |
| if: env.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON != '' | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} | |
| packageName: com.matedroid | |
| releaseFiles: app/build/outputs/bundle/release/app-release.aab | |
| track: alpha | |
| status: completed | |
| releaseName: ${{ steps.version.outputs.name }} | |
| whatsNewDirectory: fastlane/metadata/android |