84 lines
2.6 KiB
YAML
84 lines
2.6 KiB
YAML
name: Build and Release to F-Droid
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: '17'
|
|
|
|
- name: Setup Flutter
|
|
uses: subosito/flutter-action@v2
|
|
with:
|
|
flutter-version: '3.11.0'
|
|
channel: 'stable'
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Setup Android Keystore
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
|
run: |
|
|
# Decode the base64 string back into the binary .jks file
|
|
echo "$KEYSTORE_BASE64" | base64 --decode > android/app/upload-keystore.jks
|
|
|
|
echo "storePassword=$KEY_PASSWORD" > android/key.properties
|
|
echo "keyPassword=$KEY_PASSWORD" >> android/key.properties
|
|
echo "keyAlias=$KEY_ALIAS" >> android/key.properties
|
|
echo "storeFile=upload-keystore.jks" >> android/key.properties
|
|
|
|
- name: Build APK
|
|
run: flutter build apk --release
|
|
|
|
- name: Setup F-Droid Server Tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y fdroidserver sshpass
|
|
|
|
- name: Initialize or fetch F-Droid Repository
|
|
env:
|
|
HOST: ${{ secrets.HETZNER_HOST }}
|
|
USER: ${{ secrets.HETZNER_USER }}
|
|
PASS: ${{ secrets.HETZNER_PASS }}
|
|
run: |
|
|
mkdir -p fdroid
|
|
cd fdroid
|
|
|
|
sshpass -p "$PASS" scp -o StrictHostKeyChecking=no -r $USER@$HOST:dev/fdroid/repo . || fdroid init
|
|
|
|
- name: Copy new APK to repo
|
|
run: |
|
|
# The app-release.apk name should ideally include the version number
|
|
# so it doesn't overwrite older versions in the repo.
|
|
VERSION_TAG=${GITHUB_REF#refs/tags/} # gets 'v1.0.0'
|
|
cp build/app/outputs/flutter-apk/app-release.apk fdroid/repo/my_flutter_app_${VERSION_TAG}.apk
|
|
|
|
- name: Generate F-Droid Index
|
|
run: |
|
|
cd fdroid
|
|
fdroid update -c
|
|
|
|
- name: Upload Repo to Hetzner
|
|
env:
|
|
HOST: ${{ secrets.HETZNER_HOST }}
|
|
USER: ${{ secrets.HETZNER_USER }}
|
|
PASS: ${{ secrets.HETZNER_PASS }}
|
|
run: |
|
|
# Use rsync to efficiently upload only the changed files (the new APK and updated index files)
|
|
sshpass -p "$PASS" rsync -avz -e "ssh -o StrictHostKeyChecking=no" fdroid/repo/ $USER@$HOST:dev/fdroid/repo/
|