Compile and release production build #9
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: Compile and release production build | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Version" | |
required: true | |
default: "1.0.0" | |
number: | |
description: "Build number" | |
required: true | |
default: "1" | |
jobs: | |
build-android: | |
name: Build Android .apk and .aab | |
runs-on: ubuntu-latest | |
env: | |
ANDROID_AAB_RELEASE_PATH: build/app/outputs/bundle/release | |
ANDROID_APK_RELEASE_PATH: build/app/outputs/apk/release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Decode android/app/keystore.jks | |
run: echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > android/app/keystore.jks | |
- name: Decode android/key.properties | |
run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties | |
- name: Decode .env | |
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | |
- name: Update version in YAML | |
run: sed -i 's/99.99.99+99/${{ github.event.inputs.version }}+${{ github.event.inputs.number }}/g' pubspec.yaml | |
- name: Update KeyStore password in gradle properties | |
run: sed -i 's/#{KEYSTORE_PASS}#/${{ secrets.KEYSTORE_PASS }}/g' android/key.properties | |
- name: Update KeyStore key password in gradle properties | |
run: sed -i 's/#{KEYSTORE_KEY_PASS}#/${{ secrets.KEYSTORE_KEY_PASS }}/g' android/key.properties | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '18.x' | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter clean | |
- run: flutter pub get | |
- run: flutter build apk --release | |
- run: flutter build appbundle --release | |
- name: Rename apk | |
run: mv $ANDROID_APK_RELEASE_PATH/app-release.apk $ANDROID_APK_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_Android.apk | |
- name: Rename aab | |
run: mv $ANDROID_AAB_RELEASE_PATH/app-release.aab $ANDROID_AAB_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_Android.aab | |
- name: Copy apk to project root | |
run: cp $ANDROID_APK_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_Android.apk DroidHole_${{ github.event.inputs.version }}_Android.apk | |
- name: Copy aab to project root | |
run: cp $ANDROID_AAB_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_Android.aab DroidHole_${{ github.event.inputs.version }}_Android.aab | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: android | |
path: | | |
DroidHole_${{ github.event.inputs.version }}_Android.aab | |
DroidHole_${{ github.event.inputs.version }}_Android.apk | |
build-macos: | |
name: Build macOS .dmg | |
runs-on: macos-latest | |
env: | |
MACOS_APP_RELEASE_PATH: build/macos/Build/Products/Release | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Decode .env | |
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | |
- name: Update version in YAML | |
run: sed -i '' 's/99.99.99+99/${{ github.event.inputs.version }}+${{ github.event.inputs.number }}/g' pubspec.yaml | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter clean | |
- run: flutter pub get | |
- run: flutter build macos --release | |
- name: Create folder to build dmg | |
run: mkdir $MACOS_APP_RELEASE_PATH/DroidHole | |
- name: Copy app into folder | |
run: cp -r $MACOS_APP_RELEASE_PATH/DroidHole.app $MACOS_APP_RELEASE_PATH/DroidHole/DroidHole.app | |
- name: Generate symbolic link to Applications dir | |
run: ln -s /Applications $MACOS_APP_RELEASE_PATH/DroidHole | |
- name: Generate dmg | |
run: hdiutil create -srcfolder $MACOS_APP_RELEASE_PATH/DroidHole $MACOS_APP_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_macOS_Universal.dmg | |
- name: Copy dmg to project root | |
run: cp $MACOS_APP_RELEASE_PATH/DroidHole_${{ github.event.inputs.version }}_macOS_Universal.dmg DroidHole_${{ github.event.inputs.version }}_macOS_Universal.dmg | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos | |
path: DroidHole_${{ github.event.inputs.version }}_macOS_Universal.dmg | |
build-linux: | |
name: Build Linux .tar.gz and .deb | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Decode .env | |
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | |
- name: Update version in pubspec.yaml | |
run: sed -i 's/99.99.99+99/${{ github.event.inputs.version }}+${{ github.event.inputs.number }}/g' pubspec.yaml | |
- name: Update version in debian.yaml | |
run: sed -i 's/<REPLACE_VERSION_NUMBER_ACTIONS>/${{ github.event.inputs.version }}/g' debian/debian.yaml | |
- name: Install dependencies | |
run: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter clean | |
- run: flutter pub get | |
- run: flutter build linux --release | |
- name: Install flutter_to_debian | |
run: dart pub global activate flutter_to_debian | |
- name: Generate .deb package | |
run: flutter_to_debian | |
- name: Move .deb package to project root | |
run: mv debian/packages/DroidHole_${{ github.event.inputs.version }}_amd64.deb DroidHole_${{ github.event.inputs.version }}_Linux_amd64.deb | |
- name: Generate .tar.gz package | |
uses: a7ul/[email protected] | |
id: compress | |
with: | |
command: c | |
cwd: build/linux/x64/release/bundle | |
files: | | |
./data | |
./lib | |
./DroidHole | |
outPath: DroidHole_${{ github.event.inputs.version }}_Linux.tar.gz | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux | |
path: | | |
DroidHole_${{ github.event.inputs.version }}_Linux_amd64.deb | |
DroidHole_${{ github.event.inputs.version }}_Linux.tar.gz | |
build-windows: | |
name: Build Windows installer | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Decode .env | |
shell: pwsh | |
run: | | |
[IO.File]::WriteAllBytes('.env', [Convert]::FromBase64String('${{ secrets.ENV }}')) | |
- name: Update version in pubspec.yaml | |
shell: bash | |
run: sed -i 's/99.99.99+99/${{ github.event.inputs.version }}+${{ github.event.inputs.number }}/g' pubspec.yaml | |
- name: Update version in innosetup config file | |
shell: pwsh | |
run: | | |
(Get-Content windows/innosetup_installer_builder.iss) -replace '<REPLACE_VERSION_ACTIONS>', '${{ github.event.inputs.version }}' | Out-File -encoding ASCII windows/innosetup_installer_builder.iss | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter clean | |
- run: flutter pub get | |
- run: flutter build windows --release | |
- name: Build installer witn innosetup | |
run: iscc /Q windows/innosetup_installer_builder.iss | |
- name: Move installer file to root directory | |
run: move build/windows/droidhole_installer.exe DroidHole_${{ github.event.inputs.version }}_Windows_x64.exe | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: windows | |
path: DroidHole_${{ github.event.inputs.version }}_Windows_x64.exe | |
release-builds-github: | |
name: Release builds to GitHub | |
runs-on: ubuntu-latest | |
needs: [build-android, build-macos, build-linux, build-windows] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create builds directory | |
run: mkdir releases | |
- name: Download Android artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: android | |
path: releases/ | |
- name: Download macOS artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: macos | |
path: releases/ | |
- name: Download Linux artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux | |
path: releases/ | |
- name: Download Windows artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: windows | |
path: releases/ | |
- name: Release to GitHub | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "releases/*" | |
token: ${{ secrets.GH_TOKEN }} | |
tag: '${{ github.event.inputs.version }}_(${{ github.event.inputs.number }})' | |
name: v${{ github.event.inputs.version }} | |
draft: true | |
prerelease: false | |
commit: ${{ github.sha }} | |
release-build-google-play: | |
name: Release Android build to the Google Play Store | |
runs-on: ubuntu-latest | |
needs: [build-android, build-macos, build-linux, build-windows] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download Android artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: android | |
- name: Release app to Google Play | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }} | |
packageName: com.jgeek00.droid_hole | |
releaseFiles: DroidHole_${{ github.event.inputs.version }}_Android.aab | |
track: production | |
status: draft | |
releaseName: ${{ github.event.inputs.version }} |