From f01e219ebef55cb23fc2d99fcee920da8df09ef4 Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Fri, 26 May 2023 02:28:11 +0200 Subject: [PATCH] Created GitHub actions workflow --- .github/workflows/release.yaml | 43 ++++++++++++++++++++++++++++++++++ android/app/build.gradle | 19 ++++++++++++--- pubspec.yaml | 2 +- 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d773e0e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +name: Release build + +on: + workflow_dispatch: + inputs: + version: + description: "Version number" + default: "1.0.0+1" +jobs: + build: + name: Build APK and Create release + needs: [version] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Update version in YAML + run: sed -i 's/99.99.99+99/${{ github.event.inputs.version }}/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@v1 + with: + java-version: "18.x" + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - run: flutter clean + - run: flutter pub get + - run: flutter build apk --release + - run: flutter build appbundle --release + - name: Create a Release in GitHub + uses: ncipollo/release-action@v1 + with: + artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab" + token: ${{ secrets.GH_TOKEN }} + tag: ${{ steps.version.outputs.content }} + commit: ${{ github.sha }} + - name: Upload app bundle + uses: actions/upload-artifact@v2 + with: + name: appbundle + path: build/app/outputs/bundle/release/app-release.aab \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index d93673c..099c059 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -25,6 +25,12 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + android { compileSdkVersion 33 ndkVersion flutter.ndkVersion @@ -53,11 +59,18 @@ android { versionName flutterVersionName } + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword keystoreProperties['storePassword'] + } + } + 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 + signingConfig signingConfigs.release } } } diff --git a/pubspec.yaml b/pubspec.yaml index 5f2b61d..6f3b2dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 2.3.2+61 +version: 99.99.99+99 environment: sdk: '>=2.18.1 <3.0.0'