Skip to content

Commit

Permalink
Sign App & Better Workflow
Browse files Browse the repository at this point in the history
Credits to @janw4ld for the workflow file.
  • Loading branch information
MoazSalem committed Apr 11, 2023
1 parent b075b51 commit 605d71e
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 31 deletions.
111 changes: 84 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,94 @@
name: build & release
on:
pull_request:
branches:
- Release
push:
branches:
- Release
branches: [Release, Dev]
tags:
- "*"
env:
app_ver: v1.1.9
name: "Build & Release"
# A-SDK_PATH: /opt/android-sdk-linux
flutter-version: "3.7.10"
FLUTTER_CACHE: |
.pub-cache
/opt/hostedtoolcache/flutter/stable-3.7.10-x64/packages/flutter_tools
BUILD_CACHE: |
build
.dart_tool
jobs:
build:
name: Build & Release
runs-on: macos-latest
build-release:
runs-on: ubuntu-22.04
# container:
# image: cirrusci/flutter:3.7.10
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
distribution: "temurin"
java-version: "11"
cache: "gradle"
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.10'
- run: flutter pub get
flutter-version: ${{ env.flutter-version }}
- name: pub+fluttertools cache
uses: actions/cache@v3
with:
path: ${{ env.FLUTTER_CACHE }}
key: pub-cache
- name: build cache
uses: actions/cache@v3
with:
path: ${{ env.BUILD_CACHE }}
key: build-cache
- run: |
flutter build apk --release
mv ./build/app/outputs/apk/release/app-release.apk ./Colorful_Notes_$app_ver.apk
flutter build apk --release --split-per-abi
mv ./build/app/outputs/apk/release/app-arm64-v8a-release.apk ./build/app/outputs/apk/release/Colorful_Notes_$app_ver-arm64-v8a.apk
mv ./build/app/outputs/apk/release/app-armeabi-v7a-release.apk ./build/app/outputs/apk/release/Colorful_Notes_$app_ver-armeabi-v7a.apk
mv ./build/app/outputs/apk/release/app-x86_64-release.apk ./build/app/outputs/apk/release/Colorful_Notes_$app_ver-x86_64.apk
mv ./Colorful_Notes_$app_ver.apk ./build/app/outputs/apk/release/Colorful_Notes_$app_ver.apk
- name: Push to Releases
# build release apks
## environment setup
app_ver=$(grep 'version:' pubspec.yaml)
app_ver=$(echo "${app_ver/'version:'/}" | xargs)
echo "$app_ver"
echo "app_ver=$app_ver" >>$GITHUB_ENV
export PUB_CACHE=$GITHUB_WORKSPACE/.pub-cache
export PATH="$PATH":"$PUB_CACHE/bin"
mkdir artifacts && {
ARTIFACTS_PATH="$GITHUB_WORKSPACE/artifacts"
echo "ARTIFACTS_PATH=$ARTIFACTS_PATH" >>$GITHUB_ENV
}
echo "$JAVA_KEYSTORE" | base64 -d >keystore.jks
## build
flutter pub get
flutter build apk --release --split-per-abi
(cd ./build/app/outputs/flutter-apk/ && {
mv ./app-arm64-v8a-release.apk "$ARTIFACTS_PATH/Colorful_Notes-$app_ver-arm64-v8a.apk"
mv ./app-armeabi-v7a-release.apk "$ARTIFACTS_PATH/Colorful_Notes-$app_ver-armeabi-v7a.apk"
mv ./app-x86_64-release.apk "$ARTIFACTS_PATH/Colorful_Notes-$app_ver-x86_64.apk"
})
flutter build apk --release
(cd ./build/app/outputs/flutter-apk/ &&
mv ./app-release.apk "$ARTIFACTS_PATH/Colorful_Notes-$app_ver-universal.apk"
)
rm -rf ./build/app/outputs/apk # remove dupe apk dir
shell: bash
env:
JAVA_KEYSTORE: ${{ secrets.JAVA_KEYSTORE }}
JAVA_KEYPASS: ${{ secrets.JAVA_KEYPASS }}
- name: Upload build artifacts to release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/*"
tag: ${{ env.app_ver }}
token: ${{ secrets.TOKEN }}
artifacts: ${{ env.ARTIFACTS_PATH }}/*.apk
token: ${{ secrets.TOKEN }}

- name: Upload build artifacts to workflow
uses: actions/upload-artifact@v3
with:
name: v${{ env.app_ver }}
path: ${{ env.ARTIFACTS_PATH }}/*.apk
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/android/app/keystore.properties
/keystore.properties
/keystore.jks
10 changes: 8 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ android {

signingConfigs {
release {
storeFile file("../../keystore.jks")
storePassword = "$System.env.JAVA_KEYPASS"
keyAlias = "upload"
keyPassword = "$System.env.JAVA_KEYPASS"
}
release2 {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
Expand All @@ -61,8 +67,8 @@ android {
}
buildTypes {
release {
//signingConfig signingConfigs.release
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
//signingConfig signingConfigs.debug
// Enables code shrinking, obfuscation, and optimization for release builds.
minifyEnabled true
// Unused resources will be removed.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.9+4
version: 1.1.10+4

environment:
sdk: ">=2.18.1 <3.0.0"
Expand Down

0 comments on commit 605d71e

Please sign in to comment.