Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c34d5e3b | ||
|
|
94418c9edb | ||
|
|
f7377406df |
@@ -1,5 +1,9 @@
|
||||
name: Android build
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
releases: write
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -33,7 +37,9 @@ jobs:
|
||||
export ANDROID_HOME="$ANDROID_SDK_ROOT"
|
||||
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||
if [ ! -x "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
|
||||
curl -fsSL -o /tmp/commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip
|
||||
tools_url="$(curl -fsSL https://developer.android.com/studio | grep -o 'https://dl.google.com/android/repository/commandlinetools-linux-[0-9][0-9]*_latest.zip' | head -n 1)"
|
||||
test -n "$tools_url"
|
||||
curl -fsSL -o /tmp/commandlinetools.zip "$tools_url"
|
||||
rm -rf "$ANDROID_SDK_ROOT/cmdline-tools/latest" "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools"
|
||||
unzip -q /tmp/commandlinetools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
||||
@@ -47,6 +53,39 @@ jobs:
|
||||
"platforms;android-35" \
|
||||
"build-tools;35.0.0"
|
||||
|
||||
- name: Prepare optional release signing
|
||||
if: github.event_name == 'release'
|
||||
env:
|
||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
|
||||
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
missing=()
|
||||
for key in ANDROID_KEYSTORE_BASE64 ANDROID_KEYSTORE_PASSWORD ANDROID_KEY_ALIAS ANDROID_KEY_PASSWORD; do
|
||||
if [ -z "${!key:-}" ]; then
|
||||
missing+=("$key")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#missing[@]} -gt 0 ]; then
|
||||
printf -v missing_csv '%s, ' "${missing[@]}"
|
||||
missing_csv="${missing_csv%, }"
|
||||
echo "::warning::Release signing secrets missing: ${missing_csv}. Building unsigned/default-signed release AAB."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p .ci-secrets
|
||||
printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 -d > .ci-secrets/release-keystore.jks
|
||||
cat > keystore.properties <<EOF
|
||||
storeFile=.ci-secrets/release-keystore.jks
|
||||
storePassword=$ANDROID_KEYSTORE_PASSWORD
|
||||
keyAlias=$ANDROID_KEY_ALIAS
|
||||
keyPassword=$ANDROID_KEY_PASSWORD
|
||||
EOF
|
||||
|
||||
- name: Make Gradle wrapper executable
|
||||
run: chmod +x gradlew
|
||||
|
||||
@@ -82,10 +121,17 @@ jobs:
|
||||
path: app/build/outputs/apk/debug/*.apk
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload release AAB
|
||||
- name: Attach release AAB to Gitea release
|
||||
if: github.event_name == 'release'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: release-aab
|
||||
path: app/build/outputs/bundle/release/*.aab
|
||||
if-no-files-found: error
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
release_id="$(python3 -c 'import json, os; print(json.load(open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8"))["release"]["id"])')"
|
||||
aab="$(find app/build/outputs/bundle/release -name '*.aab' | head -n 1)"
|
||||
curl --fail-with-body \
|
||||
--request POST \
|
||||
--header "Authorization: token ${GITEA_TOKEN}" \
|
||||
--form "attachment=@${aab}" \
|
||||
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=$(basename "$aab")"
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
|
||||
}
|
||||
val hasReleaseSigning = listOf(
|
||||
"storeFile",
|
||||
"storePassword",
|
||||
"keyAlias",
|
||||
"keyPassword",
|
||||
).all { !keystoreProperties.getProperty(it).isNullOrBlank() }
|
||||
|
||||
android {
|
||||
namespace = "solutions.tretter.esunandroid"
|
||||
compileSdk = 35
|
||||
@@ -19,6 +33,17 @@ android {
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (hasReleaseSigning) {
|
||||
create("release") {
|
||||
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
@@ -26,6 +51,9 @@ android {
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
if (hasReleaseSigning) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user