Build and Release Qama #16
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: Build and Release | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| beta: | |
| type: boolean | |
| description: "Is this a beta release?" | |
| default: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| cache: true | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Extract Version | |
| id: extract_version | |
| run: | | |
| VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | cut -d '+' -f 1) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "beta=${{ github.event.inputs.beta }}" >> $GITHUB_OUTPUT | |
| - name: Decode Keystore | |
| run: | | |
| # We place the keystore inside android/app/ so Gradle's file() finds it easily | |
| mkdir -p android/app | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/upload-keystore.jks | |
| - name: Create key.properties | |
| run: | | |
| # We place key.properties in the root as your build.gradle.kts expects | |
| # But for the storeFile path, we use a relative path from the app's perspective | |
| echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> key.properties | |
| echo "keyAlias=upload" >> key.properties | |
| echo "storeFile=upload-keystore.jks" >> key.properties | |
| - name: Build APKs | |
| run: | | |
| # Adding a small fix to ensure the environment is clean | |
| flutter build apk --flavor normal --release --obfuscate --split-debug-info=build/debug-info | |
| flutter build apk --flavor fdroid -t lib/main_fdroid.dart --release --obfuscate --split-debug-info=build/debug-info | |
| - name: Save APKs as Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-apks | |
| path: build/app/outputs/flutter-apk/*.apk | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ steps.extract_version.outputs.tag }} | |
| prerelease: ${{ github.event.inputs.beta == true }} | |
| draft: true | |
| files: build/app/outputs/flutter-apk/*.apk | |
| generate_release_notes: true |