Merge pull request #54 from FarisZR/copilot/add-github-actions-pipeline #3
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: Release | ||
| on: | ||
| release: | ||
| types: [published] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Extract version info from tag | ||
| id: version | ||
| run: | | ||
| TAG="${{ github.event.release.tag_name }}" | ||
| # Strip leading 'v' | ||
| VERSION_NAME="${TAG#v}" | ||
| # Strip pre-release suffix (e.g. -beta) for version code calculation | ||
| BASE="${VERSION_NAME%%-*}" | ||
| IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE" | ||
| MAJOR="${MAJOR:-0}"; MINOR="${MINOR:-0}"; PATCH="${PATCH:-0}" | ||
| VERSION_CODE=$(( MAJOR * 10000 + MINOR * 100 + PATCH )) | ||
| echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "version_code=$VERSION_CODE" >> "$GITHUB_OUTPUT" | ||
| - name: Set up Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: '17' | ||
| - name: Set up Flutter | ||
| uses: subosito/flutter-action@v2 | ||
| with: | ||
| flutter-version: '3.38.0' | ||
| channel: stable | ||
| cache: true | ||
| - name: Decode keystore | ||
| if: ${{ secrets.KEYSTORE_BASE64 != '' }} | ||
| env: | ||
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | ||
| run: | | ||
| echo "$KEYSTORE_BASE64" | base64 --decode > android/app/release.keystore | ||
| cat > android/key.properties <<EOF | ||
| storeFile=release.keystore | ||
| storePassword=${{ secrets.STORE_PASSWORD }} | ||
| keyAlias=${{ secrets.KEY_ALIAS }} | ||
| keyPassword=${{ secrets.KEY_PASSWORD }} | ||
| EOF | ||
| - name: Get dependencies | ||
| run: flutter pub get | ||
| - name: Build arm64 APK | ||
| env: | ||
| VERSION_NAME: ${{ steps.version.outputs.version_name }} | ||
| VERSION_CODE: ${{ steps.version.outputs.version_code }} | ||
| run: | | ||
| perl -0pi -e "s/def flutterVersionCode = '[^']*'/def flutterVersionCode = '$ENV{VERSION_CODE}'/" android/app/build.gradle | ||
| perl -0pi -e "s/def flutterVersionName = '[^']*'/def flutterVersionName = '$ENV{VERSION_NAME}'/" android/app/build.gradle | ||
| flutter build apk \ | ||
| --target-platform android-arm64 \ | ||
| --split-per-abi | ||
| - name: Upload APK to release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk | ||