From 48e139a7264af55555499fd1e95004e8a96041bb Mon Sep 17 00:00:00 2001 From: PiotrFLEURY Date: Fri, 16 Jul 2021 17:48:09 +0200 Subject: [PATCH] feat(release): create release workflow --- .github/workflows/main.yml | 2 +- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ .gitignore | 1 + android/app/build.gradle | 19 ++++++++++++--- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 808c35b..027d3ea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: flutter format --set-exit-if-changed . flutter analyze flutter test - flutter build apk + flutter build apk --debug - name: Run Flutter test run: flutter test build-web: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..798ed01 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: RELEASE +on: + workflow_dispatch: + branches: + - main + +jobs: + # This workflow contains a single job called "build" + release: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: Configure signature + run: | + echo "${{secrets.KEY_PROPERTIES}}" > android/key.properties + echo "${{secrets.RELEASE_KEYSTORE}}" > upload-keystore.encoded + base64 -d -i upload-keystore.encoded > ./android/app/upload-keystore.jks + - uses: actions/setup-java@v1 + with: + java-version: '12.x' + - uses: subosito/flutter-action@v1 + with: + flutter-version: '2.0.5' + - name: Build apk + run: | + flutter pub get + flutter format --set-exit-if-changed . + flutter analyze + flutter test + flutter build apk + - name: Retrieve Release Version + id: versionstep + run: | + VERSION=$(more pubspec.yaml | grep version: | cut -d ' ' -f2) + echo "::set-output name=VERSION::$VERSION" + - name: Upload the APK onto Github + uses: ncipollo/release-action@v1 + with: + artifacts: 'build/app/outputs/flutter-apk/*.apk' + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.versionstep.outputs.VERSION }} + diff --git a/.gitignore b/.gitignore index 0fa6b67..a5886fa 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +/android/key.properties \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 8564c27..f992bbb 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 30 @@ -41,13 +47,20 @@ 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 } } + } flutter {