From e4dd4fbc8f588f2473619cf5f879f56d6fb875f4 Mon Sep 17 00:00:00 2001 From: teyyow Date: Wed, 20 Nov 2024 13:30:29 +0700 Subject: [PATCH] add CI/CD script --- .github/workflows/pre-release.yml | 48 +++++++++++++++++++++++ .github/workflows/release.yml | 61 ++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 37 ++++++++++++++++++ release-keystore.jks | Bin 0 -> 2251 bytes 4 files changed, 146 insertions(+) create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/staging.yml create mode 100644 release-keystore.jks diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..3e2a0f6 --- /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: "17" + + - 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..12ecd13 --- /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: "17" + + - 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..cda8b4b --- /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: "17" + + - 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/release-keystore.jks b/release-keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..73f89b06a8bec992217a480b666609715b96abd3 GIT binary patch literal 2251 zcmchY={wX58^>qH7)zG1hRYz?6~CE`jAagqhD2hB5NhmWmylw@L}SZ-qLN7=#A7WZ z`<^A)HI|rS%u!Kxj?Q(S>*+6eUVLBNpX>YLzP|T;-S<9gp9KPeAcq3~BaT3V55Xmf za9F3|PQP;kf!IL+3AzjLz_?XmU?^AxA^-+MNzmoy1xW`N$- zAmbw0mHZYz426r&>u27QiG7}TMcSw`*gE&XcJ!OATvl@~NMcTuCWhy~zxv}8i_XMJ*iX$JSpVgx zZw09_JXY78bn6m9Sbp>qxhBj$(=dUN{77uidykeI-@vbEvYfLp;&Z*K1iuc7yT#>eSxmZ;QD>~w`;9E&on%xYJmjSkHS^Es?$dNl zs68sx1+Co&{#d=+I{4~-eaqbj$}_9PoaLAv8^uJoRL@}e>h-Ih4lG+OhVZNU2MvSn zTkf@sd*5ouBuk9nT{RNOJFybn*@*~6#mc?$SfKTzGA5<;XbbeDW1QujWh{%elA)sy zFK-Ui7mmcgk`(r6stL#N7t}J{-rqBfkn#;BEZ=YljxvULKmK#}+gBBl{m&IInI5(- z&prrS)U=Sw`@$V1?sI&VH|hb$2OadOlc)d?mD(v~tFF%akEL0{ zot3JiZ`_FDgMD7wLYY$wDJ@ZA>aFK-4{NHU|56B8J&I04Qzr!pJJY~DJKW8}ds(fj zwb#OStmhd1W$c+|C(CO^=jY+AqkDOG>V7~#GAc3V`-}O87adxH`4YxWD2ie>yyH1p zE>qKC`^2=Oeow>VdXF-r&RBy*w$qwgWvyG6u~%g6MOjY^Ev;HFoy7go^Y;w9t)Hp4aW>vzm90yP|+xOxsB0*ooX^5T~0n~MYurXwDF~HrBhR%Vqjq2s!3v}G<&(9)!`0Ih zD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