Skip to content

Nightly Snapshot

Nightly Snapshot #306

Workflow file for this run

name: Nightly Snapshot
on:
schedule:
- cron: "0 0 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
# The name of the main module repository
main_project_module: app
# The name of the App
app_name: Valolink
# The name of the android app package
package_name: dev.bittim.valolink
jobs:
CheckNewCommits:
runs-on: ubuntu-latest
outputs:
doRebuild: ${{ steps.decideRebuild.outputs.doRebuild }}
steps:
- name: Checking out branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest commit SHA
id: latestsha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Previous tag
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: Get commit SHA of latest Tag
id: tagsha
run: echo "sha=$(git rev-list -n 1 ${{ steps.previoustag.outputs.tag }})" >> $GITHUB_OUTPUT
- name: Decide rebuild
id: decideRebuild
env:
LATEST_SHA: ${{ steps.latestsha.outputs.sha }}
TAG_SHA: ${{ steps.tagsha.outputs.sha }}
run: |
if [[ $LATEST_SHA == $TAG_SHA ]]; then
echo "doRebuild=false" >> $GITHUB_OUTPUT
else
echo "doRebuild=true" >> $GITHUB_OUTPUT
fi
Build:
needs: [ CheckNewCommits ]
if: needs.CheckNewCommits.outputs.doRebuild == 'true'
runs-on: ubuntu-latest
outputs:
apkName: ${{ steps.apkName.outputs.apkName }}
aabName: ${{ steps.aabName.outputs.aabName }}
steps:
- name: Checking out branch
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@main
with:
distribution: 'temurin'
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Making gradlew executable
run: chmod +x ./gradlew
# Run Tests Build
- name: Run gradle test
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew test
# This will decode the keystore from base 64 text representation that we have stored in secrets
# and generates and keystore file and gets stored in /android-app path
- name: Decode Keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE_64 }}
run: |
echo $KEYSTORE_BASE64 | base64 -di > keystore.jks
- name: Build Release apk
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew assembleRelease --stacktrace
- name: Build Release bundle
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew bundleRelease --stacktrace
- name: Get APK file path
id: apkFile
run: echo "apkFile=$(find app/build/outputs/apk/release/*.apk)" >> $GITHUB_OUTPUT
- name: Get AAB file path
id: aabFile
run: echo "aabFile=$(find app/build/outputs/bundle/release/*.aab)" >> $GITHUB_OUTPUT
- name: Get APK file name
id: apkName
run: echo "apkName=$(basename ${{ steps.apkFile.outputs.apkFile }})" >> $GITHUB_OUTPUT
- name: Get AAB file name
id: aabName
run: echo "aabName=$(basename ${{ steps.aabFile.outputs.aabFile }})" >> $GITHUB_OUTPUT
- name: Upload Release Build APK to Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.apkName.outputs.apkName }}
path: ${{ steps.apkFile.outputs.apkFile }}
- name: Upload Release Build AAB to Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.aabName.outputs.aabName }}
path: ${{ steps.aabFile.outputs.aabFile }}
- name: Store reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: reports
path: |
**/build/reports/
**/build/test-results/
CreateNewTag:
needs: [ Build ]
runs-on: ubuntu-latest
outputs:
date: ${{ steps.date.outputs.date }}
versionName: ${{ steps.versionName.outputs.versionName }}
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current date
id: date
run: echo "date=$(date +'%d-%m-%Y_%H-%M')" >> $GITHUB_OUTPUT
- name: Read all values from version.properties
uses: BrycensRanch/read-properties-action@v1
id: versionProperties
with:
file: app/version.properties
all: true
- name: Get current version name
id: versionName
run: echo "versionName=$(echo v${{ steps.versionProperties.outputs.MAJOR }}.${{ steps.versionProperties.outputs.MINOR }}.${{ steps.versionProperties.outputs.PATCH }}-${{ steps.versionProperties.outputs.BUILD }})" >> $GITHUB_OUTPUT
- name: Generate tag name
id: tag
run: echo "tag=$(echo ${{ steps.versionName.outputs.versionName }}_${{ steps.date.outputs.date }})" >> $GITHUB_OUTPUT
- name: Create Tag
uses: ydataai/create-tag@v1
with:
tag: ${{ steps.tag.outputs.tag }}
message: ${{ env.app_name }} Nightly ${{ steps.versionName.outputs.versionName }} (${{ steps.date.outputs.date }})
Deploy:
needs: [ Build, CreateNewTag ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.CreateNewTag.outputs.tag }}
- name: Truncate Changelog length (Max 500)
id: truncate-changelog
env:
CHANGES: ${{ steps.changelog.outputs.changes }}
run:
echo "length=$(echo $CHANGES | sed 's/\(.\{500\}\).*/\1/')"
- name: Create whatsnew directory and file
env:
TRUNC_CHANGES: ${{ steps.truncate-changelog.outputs.changes }}
run: |
mkdir whatsnew
echo "$TRUNC_CHANGES" > whatsnew/whatsnew-en-US
- name: Download artifact of release AAB
uses: actions/download-artifact@master
with:
name: ${{ needs.Build.outputs.aabName }}
- name: Upload artifact to Google Play Internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: ${{ env.package_name }}
releaseFiles: ${{ needs.Build.outputs.aabName }}
status: draft
track: internal
whatsNewDirectory: whatsnew