From bbfd6e89d77cbb35188d2f1d7136ffdf603af494 Mon Sep 17 00:00:00 2001 From: Kevin I Date: Wed, 22 Nov 2023 13:35:46 +0700 Subject: [PATCH] +finishing tutorial 9\ --- .github/workflows/pre-release.yml | 48 ++++++++++++++++++++++++ .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 37 +++++++++++++++++++ .gitignore | 5 +++ android/app/build.gradle | 16 +++++--- 5 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/staging.yml diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..3396cbc --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,48 @@ +name: Pre-Release + +# Controls when the workflow will run +on: + # Triggers the workflow on pull request events but only for the main branch + pull_request: + branches: [main] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "Build and Pre-Release APK" + releases: + name: Build and Pre-Release APK + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Get packages + run: flutter pub get + + - name: Generate Java keystore + env: + KEY_JKS: ${{ secrets.KEY_JKS }} + run: echo "$KEY_JKS" | base64 --decode > release-keystore.jks + + - name: Build APK + env: + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + run: flutter build apk --split-per-abi + + - name: Pre-release APK by uploading it to Artifacts + uses: actions/upload-artifact@v3 + with: + name: APKS + path: build/app/outputs/flutter-apk/*.apk \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..920e66b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +# This is a basic workflow to help you get started with Actions +name: Release + +# Controls when the workflow will run +on: + # Triggers the workflow on push events but only for the main branch + push: + branches: [main] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "Build and Release APK" + releases: + name: Build and Release APK + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Get version from pubspec.yaml + id: version + run: echo "::set-output name=version::$(grep "version:" pubspec.yaml | cut -c10-)" + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Get packages + run: flutter pub get + + - name: Generate Java keystore + env: + KEY_JKS: ${{ secrets.KEY_JKS }} + run: echo "$KEY_JKS" | base64 --decode > release-keystore.jks + + - name: Build APK + env: + KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + run: flutter build apk --split-per-abi + + - name: Get current date + id: date + run: echo "::set-output name=date::$(TZ='Asia/Jakarta' date +'%A %d-%m-%Y %T WIB')" + + - name: Release APK + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: "build/app/outputs/flutter-apk/*.apk" + body: "Published at ${{ steps.date.outputs.date }}" + name: "v${{ steps.version.outputs.version }}" + token: ${{ secrets.GH_TOKEN }} + tag: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..4205bb0 --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,37 @@ +name: Staging + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the develop branch + push: + branches: [staging] + pull_request: + branches: [staging] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + name: Analyze + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Get packages + run: flutter pub get + + - name: Analyze + run: flutter analyze \ No newline at end of file diff --git a/.gitignore b/.gitignore index 24476c5..9b6c052 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,11 @@ migrate_working_dir/ .pub/ /build/ +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +*.keystore +*.jks + # Symbolication related app.*.symbols diff --git a/android/app/build.gradle b/android/app/build.gradle index b87c89b..c143452 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -51,13 +51,19 @@ android { versionName flutterVersionName } - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfigs { + release { + storeFile file("../../release-keystore.jks") + storePassword = "$System.env.KEY_PASSWORD" + keyAlias = "release" + keyPassword = "$System.env.KEY_PASSWORD" } } + buildTypes { + release { + signingConfig signingConfigs.release + } +} } flutter {