myPlanet release #1012
Workflow file for this run
This file contains 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: myPlanet release | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
jobs: | |
release: | |
name: myPlanet release | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [default, lite] | |
env: | |
FILES: | | |
app/src/main/AndroidManifest.xml | |
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt | |
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt | |
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt | |
steps: | |
- name: checkout repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: setup JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: setup gradle | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
gradle-version: 8.7 | |
cache-disabled: false | |
cache-read-only: false | |
cache-write-only: false | |
- name: diff the code to get lite | |
if: matrix.build == 'lite' | |
run: | | |
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do | |
ls -al $file* | |
cp "${file}.lite" "$file" | |
done | |
ls -al app/build.gradle | |
echo "ANDROID_VERSION_LITE=$(grep -oP 'versionName "\K[^\"]+' build.gradle)" >> $GITHUB_ENV | |
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle | |
- name: build release APK and AAB | |
run: | | |
echo "ANDROID_VERSION_NAME=$(grep -oP 'versionName "\K[^\"]+' build.gradle)" >> $GITHUB_ENV | |
echo "ANDROID_VERSION_CODE=$(grep versionCode app/build.gradle | sed 's/[^0-9]//g')" >> $GITHUB_ENV | |
./gradlew assembleRelease bundleRelease | |
ls -alR app/build/outputs | |
mkdir -p sign | |
cp app/build/outputs/bundle/release/app-release.aab sign/. | |
cp app/build/outputs/apk/release/app-release-unsigned.apk sign/. | |
- name: sign release APK and AAB | |
uses: dogi/[email protected] | |
with: | |
releaseDirectory: sign | |
signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
alias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
- name: copy builds to output and generate sha256 | |
run: | | |
mkdir -p output | |
cp sign/app-release-unsigned-signed.apk output/myPlanet.apk | |
cp sign/app-release.aab output/myPlanet.aab | |
sha256sum output/myPlanet.apk > output/myPlanet.apk.sha256 | |
sha256sum output/myPlanet.aab > output/myPlanet.aab.sha256 | |
ls -alR output | |
- name: publish AAB to playstore | |
id: playstore | |
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite' | |
continue-on-error: true | |
uses: dogi/[email protected] | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
packageName: org.ole.planet.myplanet | |
releaseFiles: output/myPlanet.aab | |
track: internal | |
releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})" | |
status: completed | |
- name: publish AAB to playstore fallback | |
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite' && steps.playstore.outcome == 'failure' | |
uses: dogi/[email protected] | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
packageName: org.ole.planet.myplanet | |
releaseFiles: output/myPlanet.aab | |
track: internal | |
releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})" | |
status: completed | |
changesNotSentForReview: true | |
- name: rename APK and AAB with version and branch for artifact | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "BRANCHNAME=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
mv output/myPlanet.apk output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk | |
mv output/myPlanet.apk.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk.sha256 | |
mv output/myPlanet.aab output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab | |
mv output/myPlanet.aab.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab.sha256 | |
ls -alR output | |
- name: upload APK and AAB as build artifact | |
if: github.event_name == 'workflow_dispatch' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }} | |
path: output/* | |
retention-days: 9 | |
- name: pre-process files and tag for lite version | |
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite' | |
run: | | |
mv output/myPlanet.apk output/myPlanet-lite.apk | |
mv output/myPlanet.apk.sha256 output/myPlanet-lite.apk.sha256 | |
mv output/myPlanet.aab output/myPlanet-lite.aab | |
mv output/myPlanet.aab.sha256 output/myPlanet-lite.aab.sha256 | |
echo "ANDROID_VERSION_NAME=${ANDROID_VERSION_LITE}" >> $GITHUB_ENV | |
- name: release APK and AAB on GitHub | |
if: github.event_name != 'workflow_dispatch' | |
uses: dogi/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: output/* | |
tag: v${{ env.ANDROID_VERSION_NAME }} | |
overwrite: 'true' | |
file_glob: 'true' | |
- name: send success message to discord | |
if: github.event_name != 'workflow_dispatch' && matrix.build != 'lite' | |
run: | | |
sudo npm install -g @treehouses/cli | |
export discord_channel="${{ secrets.CHANNEL }}" #remote | |
echo "https://github.com/open-learning-exchange/myplanet/releases/tag/v${{ env.ANDROID_VERSION_NAME }}" | |
treehouses feedback "new myplanet app: https://github.com/open-learning-exchange/myplanet/releases/tag/v${{ env.ANDROID_VERSION_NAME }}" |