From 3346b190a5d268c8dfeb969221fc971719708e7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AD=99=E5=A8=87?=
Date: Wed, 28 Feb 2024 23:09:47 +0800
Subject: [PATCH] add android and ios build to github actions
---
.github/workflows/main.yml | 29 +++++++++++++++++++++++++++++
android/app/build.gradle | 26 +++++++++++++++++---------
2 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index aed5e5a..965335a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -38,6 +38,25 @@ jobs:
with:
name: Renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-appimage
path: Renamer-x86_64.AppImage
+ - uses: actions/setup-java@v1
+ with:
+ java-version: '12.x'
+ - name: decode key base64
+ run: echo $KEYSTORE_BASE64 | base64 -di > ./android/app/renamer.jks
+ env:
+ KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
+ - run: flutter build apk --release
+ env:
+ KEYSTORE: renamer.jks
+ KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
+ KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
+ KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}}
+ - name: Android Release
+ uses: actions/upload-artifact@v1
+ with:
+ name: renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-release-apk
+ path: build/app/outputs/apk/release/app-release.apk
+
build-and-release-windows:
runs-on: windows-latest
@@ -104,4 +123,14 @@ jobs:
with:
name: renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-macos
path: build/macos/Build/Products/Release/renamer.dmg
+ - name: Build ios
+ run: |
+ flutter build ios --release --no-codesign
+ ln -sf ./build/ios/iphoneos Payload
+ zip -r9 renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-release.ipa Payload/runner.app
+ - name: ios Release
+ uses: actions/upload-artifact@v4
+ with:
+ name: renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-ios
+ path: renamer-${{github.ref_name}}-${{ steps.vars.outputs.sha_short }}-release.ipa
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 20bf168..9b9bcaf 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -24,7 +24,15 @@ if (flutterVersionName == null) {
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
-keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+if (keystorePropertiesFile.exists()) {
+ keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+}
+
+def _storeFile = file(System.getenv("KEYSTORE") ?: keystoreProperties["storeFile"])
+def _storePassword = System.getenv("KEYSTORE_PASSWORD") ?: keystoreProperties["storePassword"]
+def _keyAlias = System.getenv("KEY_ALIAS") ?: keystoreProperties["keyAlias"]
+def _keyPassword = System.getenv("KEY_PASSWORD") ?: keystoreProperties["keyPassword"]
+
android {
namespace "net.sunjiao.renamer"
@@ -57,17 +65,17 @@ android {
signingConfigs {
debug {
- keyAlias keystoreProperties['keyAlias'] //别名
- keyPassword keystoreProperties['keyPassword']
- storeFile file(keystoreProperties['storeFile']) //签名文件路径
- storePassword keystoreProperties['storePassword']
+ keyAlias _keyAlias
+ keyPassword _keyPassword
+ storeFile _storeFile
+ storePassword _storePassword
}
release {
- keyAlias keystoreProperties['keyAlias'] //别名
- keyPassword keystoreProperties['keyPassword']
- storeFile file(keystoreProperties['storeFile']) //签名文件路径
- storePassword keystoreProperties['storePassword']
+ keyAlias _keyAlias
+ keyPassword _keyPassword
+ storeFile _storeFile
+ storePassword _storePassword
}
}