124 lines
5.0 KiB
YAML
124 lines
5.0 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*.*.*'
|
|
|
|
jobs:
|
|
build-release:
|
|
name: Build & attach release APK
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone https://git.trevena.info/nick/incido.git repo
|
|
cd repo
|
|
|
|
- name: Set up JDK 17
|
|
run: |
|
|
WORKDIR=/tmp/gitea-runner-work
|
|
if [ ! -d "$WORKDIR/jdk" ]; then
|
|
wget -q 'https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz' -O /tmp/jdk.tar.gz
|
|
mkdir -p "$WORKDIR/jdk"
|
|
tar -xzf /tmp/jdk.tar.gz -C "$WORKDIR/jdk" --strip-components=1
|
|
rm /tmp/jdk.tar.gz
|
|
fi
|
|
echo "JAVA_HOME=$WORKDIR/jdk" >> $GITHUB_ENV
|
|
echo "PATH=$WORKDIR/jdk/bin:$PATH" >> $GITHUB_ENV
|
|
|
|
- name: Set up Android SDK
|
|
run: |
|
|
WORKDIR=/tmp/gitea-runner-work
|
|
SDK=$WORKDIR/android-sdk
|
|
if [ ! -d "$SDK/cmdline-tools/latest" ]; then
|
|
mkdir -p "$SDK"
|
|
wget -q 'https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip' -O /tmp/cmdline-tools.zip
|
|
unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools-extract
|
|
mkdir -p "$SDK/cmdline-tools"
|
|
mv /tmp/cmdline-tools-extract/cmdline-tools "$SDK/cmdline-tools/latest"
|
|
rm -rf /tmp/cmdline-tools.zip /tmp/cmdline-tools-extract
|
|
yes | "$SDK/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null 2>&1 || true
|
|
"$SDK/cmdline-tools/latest/bin/sdkmanager" --install \
|
|
"platform-tools" \
|
|
"platforms;android-34" \
|
|
"build-tools;34.0.0" > /dev/null 2>&1
|
|
fi
|
|
echo "ANDROID_HOME=$SDK" >> $GITHUB_ENV
|
|
echo "ANDROID_SDK_ROOT=$SDK" >> $GITHUB_ENV
|
|
echo "PATH=$SDK/cmdline-tools/latest/bin:$SDK/platform-tools:$PATH" >> $GITHUB_ENV
|
|
|
|
# The release signing config in app/build.gradle.kts only attaches a
|
|
# storeFile when keystore/release.jks exists, and that .jks is
|
|
# gitignored -- so the CI runner must mint its own. We use the exact
|
|
# dev keystore documented in keystore/README.md (alias "incido",
|
|
# both passwords "incido_dev_keystore"). Move to a Gitea Actions
|
|
# secret + production keystore before publishing to Play / F-Droid.
|
|
- name: Build debug + release APKs
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
run: |
|
|
set -e
|
|
cd repo
|
|
chmod +x gradlew
|
|
|
|
# Mint the dev keystore in the same shell session as the build
|
|
# so gradle can find it at keystore/release.jks (rootProject.file).
|
|
mkdir -p keystore
|
|
keytool -genkey -noprompt -v \
|
|
-keystore keystore/release.jks \
|
|
-keyalg RSA -keysize 2048 -validity 10000 \
|
|
-alias incido \
|
|
-storepass incido_dev_keystore \
|
|
-keypass incido_dev_keystore \
|
|
-dname "CN=Incido Dev, OU=Local, O=Incido, L=Local, ST=Local, C=NZ"
|
|
|
|
export JAVA_HOME=/tmp/gitea-runner-work/jdk
|
|
export ANDROID_HOME=/tmp/gitea-runner-work/android-sdk
|
|
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH
|
|
|
|
# Build both variants; copyReleaseApks finalizes assembleRelease and
|
|
# drops version-stamped APKs at the repo root:
|
|
# Incido-<version>-debug.apk
|
|
# Incido-<version>-release.apk
|
|
./gradlew assembleDebug assembleRelease --no-daemon
|
|
|
|
# Verify both files exist before proceeding
|
|
TAG="${GITHUB_REF##*/}"
|
|
|
|
- name: Create release + attach both APKs
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
run: |
|
|
cd repo
|
|
TAG="${GITHUB_REF##*/}"
|
|
VERSION="${TAG#v}"
|
|
|
|
echo "Creating release for tag: $TAG"
|
|
RELEASE_ID=$(curl -s -X POST "https://git.trevena.info/api/v1/repos/nick/incido/releases" \
|
|
-H "Authorization: token $GITHUB_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"$TAG\",
|
|
\"name\": \"$TAG\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id','') or '')")
|
|
echo "Release ID: $RELEASE_ID"
|
|
|
|
if [ -z "$RELEASE_ID" ]; then
|
|
echo "ERROR: Failed to create release"
|
|
exit 1
|
|
fi
|
|
|
|
for APK in "Incido-${VERSION}-debug.apk" "Incido-${VERSION}-release.apk"; do
|
|
echo "Attaching $APK to release $RELEASE_ID"
|
|
RESPONSE=$(curl -s -X POST \
|
|
"https://git.trevena.info/api/v1/repos/nick/incido/releases/$RELEASE_ID/assets?name=$APK" \
|
|
-H "Authorization: token $GITHUB_TOKEN" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary "@$APK")
|
|
echo "Attach response: $RESPONSE"
|
|
done
|