9 Commits
test3 ... main

Author SHA1 Message Date
Hermes
c84181ea18 ci: route Android builds through BuildTool
All checks were successful
Android build / build (push) Successful in 8m23s
Android build / build (release) Successful in 16m1s
2026-09-01 17:16:44 -05:00
Hermes
0ae7ac86d9 ci: prefer github token for release asset upload
All checks were successful
Android build / build (push) Successful in 7m8s
Android build / build (release) Successful in 8m28s
2026-08-31 18:22:00 -05:00
Hermes
61b8c3d18f ci: broaden release asset upload token fallback
All checks were successful
Android build / build (push) Successful in 8m8s
2026-08-31 16:12:12 -05:00
Hermes
87c77dc1fa ci: bump APK versionCode and timestamp AAB names
Some checks failed
Android build / build (push) Successful in 11m31s
Android build / build (release) Failing after 8m2s
2026-08-31 15:05:45 -05:00
Hermes
e53a33c7b5 fix: repair AGP upgrade file corruption
All checks were successful
Android build / build (push) Successful in 9m9s
2026-08-31 13:49:22 -05:00
Hermes
4bbcead398 build: upgrade AGP for Android 16 support
Some checks failed
Android build / build (push) Has been cancelled
2026-08-31 13:30:46 -05:00
Hermes
dcdf69d02a build: target Android 16 / API 36
All checks were successful
Android build / build (push) Successful in 12m16s
2026-08-31 12:17:46 -05:00
Hermes Agent
aae81c202e ci: mark missing signing secrets as non-blocking error
All checks were successful
Android build / build (push) Successful in 10m49s
Android build / build (release) Successful in 10m22s
2026-08-29 12:22:56 -05:00
Hermes Agent
a2c34d5e3b ci: add optional release signing from repository secrets
All checks were successful
Android build / build (push) Successful in 9m43s
Android build / build (release) Successful in 10m35s
2026-08-29 12:04:19 -05:00
6 changed files with 120 additions and 66 deletions

View File

@@ -1,7 +1,7 @@
name: Android build
permissions:
contents: read
contents: write
releases: write
on:
@@ -29,76 +29,56 @@ jobs:
distribution: temurin
java-version: '17'
- name: Install Android SDK command-line tools and packages
shell: bash
run: |
set -euxo pipefail
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
if [ ! -x "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
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"
fi
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
set +o pipefail
yes | sdkmanager --licenses >/dev/null
set -o pipefail
sdkmanager \
"platform-tools" \
"platforms;android-35" \
"build-tools;35.0.0"
- name: Make Gradle wrapper executable
run: chmod +x gradlew
- name: Write Android SDK location
shell: bash
run: |
set -euxo pipefail
printf 'sdk.dir=%s/.android/sdk\n' "$HOME" > local.properties
- name: Build debug APK
- name: Run project build tooling for debug APK
if: github.event_name != 'release'
shell: bash
env:
CI_VERSION_CODE: ${{ github.run_number }}
run: |
set -euxo pipefail
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
./gradlew --no-daemon clean assembleDebug
chmod +x ./BuildTool.sh
./BuildTool.sh --no-commit --apk-only
- name: Build release AAB
- name: Run project build tooling for release AAB
if: github.event_name == 'release'
shell: bash
env:
CI_VERSION_CODE: ${{ github.run_number }}
CI_ARTIFACT_TIMESTAMP: ${{ github.run_id }}
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 }}
run: |
set -euxo pipefail
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
export ANDROID_HOME="$ANDROID_SDK_ROOT"
./gradlew --no-daemon bundleRelease
chmod +x ./BuildTool.sh
./BuildTool.sh --no-commit --with-aab
- name: Upload debug APK
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: debug-apk
path: app/build/outputs/apk/debug/*.apk
path: dist/*.apk
if-no-files-found: error
- name: Attach release AAB to Gitea release
if: github.event_name == 'release'
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euxo pipefail
token="${GITHUB_TOKEN:-${GITEA_TOKEN:-}}"
if [ -z "$token" ]; then
echo "::error::No release upload token is available from secrets.GITEA_TOKEN or github.token"
exit 1
fi
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)"
aab="$(find dist -name '*.aab' | head -n 1)"
curl --fail-with-body \
--request POST \
--header "Authorization: token ${GITEA_TOKEN}" \
--header "Authorization: token ${token}" \
--form "attachment=@${aab}" \
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=$(basename "$aab")"

View File

@@ -3,8 +3,8 @@ set -Eeuo pipefail
APP_NAME="e-SUN"
MODULE="app"
API_LEVEL="35"
BUILD_TOOLS_VERSION="35.0.0"
API_LEVEL="36"
BUILD_TOOLS_VERSION="36.0.0"
DIST_DIR="dist"
COMMIT_MSG_FILE="commit-message.txt"
@@ -47,6 +47,9 @@ for arg in "$@"; do
esac
done
CI_VERSION_CODE="${CI_VERSION_CODE:-}"
CI_ARTIFACT_TIMESTAMP="${CI_ARTIFACT_TIMESTAMP:-}"
need_cmd() {
command -v "$1" >/dev/null 2>&1 || {
echo "Missing required command: $1" >&2
@@ -111,6 +114,35 @@ gradle_no_daemon() {
./gradlew --no-daemon -Dorg.gradle.daemon=false "$@"
}
prepare_optional_release_signing() {
local required=(ANDROID_KEYSTORE_BASE64 ANDROID_KEYSTORE_PASSWORD ANDROID_KEY_ALIAS ANDROID_KEY_PASSWORD)
local missing=()
local key
for key in "${required[@]}"; do
if [[ -z "${!key:-}" ]]; then
missing+=("$key")
fi
done
if [[ ${#missing[@]} -eq ${#required[@]} ]]; then
return
fi
if [[ ${#missing[@]} -gt 0 ]]; then
printf 'Release signing secrets missing: %s\n' "${missing[*]}" >&2
exit 1
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
}
ensure_gitignore_entries() {
touch .gitignore
for entry in \
@@ -134,13 +166,14 @@ increment_versions() {
exit 1
fi
python3 - "$gradle_file" <<'PY'
python3 - "$gradle_file" "$CI_VERSION_CODE" <<'PY'
import re
import sys
from pathlib import Path
path = Path(sys.argv[1])
text = path.read_text()
ci_version_code = sys.argv[2].strip()
m_code = re.search(r'\bversionCode\s*=\s*(\d+)', text)
m_name = re.search(r'\bversionName\s*=\s*"(\d+(?:\.\d+)*)"', text)
@@ -151,7 +184,7 @@ if not m_name:
raise SystemExit('versionName = "<number>" not found (must be numeric, e.g. "1" or "1.0")')
old_code = int(m_code.group(1))
new_code = old_code + 1
new_code = int(ci_version_code) if ci_version_code else old_code + 1
old_name = m_name.group(1)
parts = old_name.split('.')
@@ -159,7 +192,8 @@ parts[-1] = str(int(parts[-1]) + 1)
new_name = '.'.join(parts)
text = re.sub(r'(\bversionCode\s*=\s*)\d+', r'\g<1>%d' % new_code, text, count=1)
text = re.sub(r'(\bversionName\s*=\s*)"\d+(?:\.\d+)*"', r'\g<1>"%s"' % new_name, text, count=1)
if not ci_version_code:
text = re.sub(r'(\bversionName\s*=\s*)"\d+(?:\.\d+)*"', r'\g<1>"%s"' % new_name, text, count=1)
path.write_text(text)
print(new_code)
@@ -193,8 +227,14 @@ copy_artifacts() {
echo "Release AAB not found." >&2
exit 1
fi
cp "$release_aab" "$DIST_DIR/${APP_NAME}-v${version_code}-release.aab"
echo "Created: $DIST_DIR/${APP_NAME}-v${version_code}-release.aab"
local release_name
if [[ -n "$CI_ARTIFACT_TIMESTAMP" ]]; then
release_name="${APP_NAME}-${CI_ARTIFACT_TIMESTAMP}-release.aab"
else
release_name="${APP_NAME}-v${version_code}-release.aab"
fi
cp "$release_aab" "$DIST_DIR/$release_name"
echo "Created: $DIST_DIR/$release_name"
fi
}
@@ -233,6 +273,10 @@ main() {
exit 0
fi
if [[ "$WITH_AAB" == true ]]; then
prepare_optional_release_signing
fi
local version_code
version_code="$(increment_versions)"

View File

@@ -16,22 +16,24 @@ Native Kotlin + Jetpack Compose app (API 35) that provides a light-therapy style
- Unit test coverage for Kelvin conversion output range
## BuildTool.sh
The project intentionally runs Gradle with daemon disabled (`--no-daemon` and `org.gradle.daemon=false`).
The project intentionally runs builds through `./BuildTool.sh` so local development and CI use the same build path.
### Options
### Common commands
```bash
./BuildTool.sh --setup-only
./BuildTool.sh --debug
./BuildTool.sh --release
./BuildTool.sh --all
./BuildTool.sh --no-commit --apk-only
./BuildTool.sh --no-commit --with-aab
```
### Behavior
- `--setup-only`: prepares wrapper/dependencies without building release artifacts.
- `--debug`: increments version code/name, builds debug APK, renames output to include app name and version code.
- `--release`: increments version code/name, builds release AAB, renames output similarly.
- `--all`: runs debug + release flow in one run.
- After successful build tasks, script commits all changes with message from `commit-message.txt` (fallback: `No Details`) and then clears that file.
- `--setup-only`: prepares the local Android SDK/tooling and exits.
- `--apk-only`: builds the debug APK.
- `--with-aab`: also builds the release AAB.
- `--no-commit`: skips the post-build git commit step.
- Local builds increment `versionCode` and `versionName`.
- CI can provide `CI_VERSION_CODE` to force the build version code and `CI_ARTIFACT_TIMESTAMP` to control the release AAB filename.
- Artifacts are copied into `dist/`.
- Gitea Actions uses this same script instead of duplicating build logic in YAML.
## Upload Key (Release Signing)
For this first increment, release uses default debug signing unless custom signing is added.

View File

@@ -1,17 +1,31 @@
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
compileSdk = 36
defaultConfig {
applicationId = "solutions.tretter.esunandroid"
minSdk = 26
targetSdk = 35
targetSdk = 36
versionCode = 19
versionName = "19"
@@ -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")
}
}
}

View File

@@ -1,5 +1,5 @@
plugins {
id("com.android.application") version "8.7.2" apply false
id("com.android.application") version "8.10.0" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
// Required for Kotlin 2.0+ when Compose is enabled
id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" apply false

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists