Files
Messenger/.github/workflows/android-release.yml
Codex ef5f866bd0
Some checks failed
Android CI / android (push) Failing after 3m38s
Android Release / release (push) Failing after 3m34s
CI / test (push) Failing after 2m25s
ci: add android release workflow for gitea
2026-03-09 15:44:31 +03:00

95 lines
3.2 KiB
YAML

name: Android Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://git.daemonlord.ru/actions/checkout@v4
with:
fetch-depth: 0
tags: true
- name: Set up JDK 17
uses: https://git.daemonlord.ru/actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Extract versionName from Kotlin DSL
id: extract_version
run: |
VERSION=$(grep -oP 'versionName\s*=\s*"[^"]+"' android/app/build.gradle.kts | head -n1 | cut -d'"' -f2 | tr -d '\r\n')
if [ -z "$VERSION" ]; then
echo "Failed to detect versionName in android/app/build.gradle.kts"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
- name: Stop if version already released
id: version_check
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
if git show-ref --tags --quiet --verify "refs/tags/$VERSION"; then
echo "Version $VERSION already released, stopping job."
echo "continue=false" >> "$GITHUB_OUTPUT"
else
echo "Version $VERSION is new, continuing..."
echo "continue=true" >> "$GITHUB_OUTPUT"
fi
- name: Decode keystore
if: steps.version_check.outputs.continue == 'true'
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > android/app/release.keystore
- name: Set up Android SDK
if: steps.version_check.outputs.continue == 'true'
uses: https://git.daemonlord.ru/actions/setup-android@v3
- name: Make Gradlew executable
if: steps.version_check.outputs.continue == 'true'
run: chmod +x ./android/gradlew
- name: Build release APK
if: steps.version_check.outputs.continue == 'true'
working-directory: android
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew --no-daemon assembleRelease
- name: Create git tag
if: steps.version_check.outputs.continue == 'true'
run: |
VERSION="${{ steps.extract_version.outputs.version }}"
git config user.name "android-release-bot"
git config user.email "android-release-bot@daemonlord.ru"
git tag "$VERSION"
git push origin "$VERSION"
- name: Create Gitea release
if: steps.version_check.outputs.continue == 'true'
uses: https://git.daemonlord.ru/actions/gitea-release-action@v1
with:
server_url: https://git.daemonlord.ru
repository: ${{ gitea.repository }}
token: ${{ secrets.API_TOKEN }}
tag_name: ${{ steps.extract_version.outputs.version }}
name: Release ${{ steps.extract_version.outputs.version }}
body: |
Android release ${{ steps.extract_version.outputs.version }}
files: |
android/app/build/outputs/apk/release/*.apk