Skip to content

v1.11.6

v1.11.6 #88

Workflow file for this run

name: FxFiles Android Deploy
on:
workflow_dispatch:
release:
types: [published]
jobs:
deploy-android:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space
run: |
echo "Disk space before cleanup:"
df -h
# Remove unused software to free up space
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/share/swift
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Remove Docker images
sudo docker image prune --all --force || true
# Clean apt cache
sudo apt-get clean
echo "Disk space after cleanup:"
df -h
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.38.5'
channel: 'stable'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
# The fllama plugin pins NDK 28.0.12433566. The GitHub Actions ubuntu-latest
# image ships some NDKs pre-installed but doesn't necessarily include this
# exact build, and the license for it isn't pre-accepted, which causes
# `flutter build appbundle` to fail at the Gradle configure step:
# "License for package NDK (Side by side) 28.0.12433566 not accepted"
# android-actions/setup-android puts sdkmanager on PATH, accepts licenses,
# and installs the listed packages. Using it is more robust than calling
# sdkmanager directly — the runner's PATH varies across image revisions.
- name: Install Android NDK 28.0.12433566 (accept licenses)
uses: android-actions/setup-android@v3
with:
packages: 'ndk;28.0.12433566'
accept-android-sdk-licenses: true
- name: Verify NDK installed
run: ls -la "$ANDROID_HOME/ndk" || true
# fllama's android/build.gradle pins `cmake { version "3.31.0" }`, and
# AGP requires that exact version — it won't fall back to 3.22.1 (which
# is what sdkmanager would auto-install). sdkmanager doesn't have 3.31.0
# in its repo. Download the official Kitware binary and drop it where
# AGP looks for it ($ANDROID_HOME/cmake/<version>/). The upstream tarball
# doesn't bundle ninja but AGP needs it next to cmake, so install ninja
# via apt and symlink it into bin/.
- name: Install CMake 3.31.0 (fllama requires this exact version)
run: |
CMAKE_VERSION="3.31.0"
SDK_CMAKE_DIR="$ANDROID_HOME/cmake/$CMAKE_VERSION"
if [ -x "$SDK_CMAKE_DIR/bin/cmake" ]; then
echo "CMake $CMAKE_VERSION already at $SDK_CMAKE_DIR"
else
echo "Downloading CMake $CMAKE_VERSION from Kitware"
mkdir -p "$SDK_CMAKE_DIR"
curl -fsSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" \
| tar -xz --strip-components=1 -C "$SDK_CMAKE_DIR"
fi
if [ ! -x "$SDK_CMAKE_DIR/bin/ninja" ]; then
echo "Installing ninja and placing it in $SDK_CMAKE_DIR/bin/"
sudo apt-get update
sudo apt-get install -y ninja-build
cp "$(command -v ninja)" "$SDK_CMAKE_DIR/bin/ninja"
fi
"$SDK_CMAKE_DIR/bin/cmake" --version
"$SDK_CMAKE_DIR/bin/ninja" --version
echo "Available CMake versions in SDK:"
ls -la "$ANDROID_HOME/cmake/"
- name: Flutter Doctor
run: flutter doctor -v
- name: Get Dependencies
run: flutter pub get
- name: Set Production Package Name
run: |
echo "Changing package name from land.fx.files.dev to land.fx.files for production..."
# Update build.gradle.kts
sed -i 's/namespace = "land.fx.files.dev"/namespace = "land.fx.files"/' android/app/build.gradle.kts
sed -i 's/applicationId = "land.fx.files.dev"/applicationId = "land.fx.files"/' android/app/build.gradle.kts
# Update package declarations in all Kotlin files
for file in android/app/src/main/kotlin/land/fx/files/dev/*.kt; do
sed -i 's/^package land.fx.files.dev$/package land.fx.files/' "$file"
echo "Updated package in: $file"
done
# Move all Kotlin files to production package directory
mkdir -p android/app/src/main/kotlin/land/fx/files
mv android/app/src/main/kotlin/land/fx/files/dev/*.kt android/app/src/main/kotlin/land/fx/files/
rm -rf android/app/src/main/kotlin/land/fx/files/dev
echo "Package name updated to land.fx.files"
echo "Verifying changes..."
grep -n "namespace\|applicationId" android/app/build.gradle.kts
ls -la android/app/src/main/kotlin/land/fx/files/
head -1 android/app/src/main/kotlin/land/fx/files/*.kt
- name: Get Package Version
run: |
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | tr -d ' ')
echo "APP_VERSION=$VERSION" >> $GITHUB_ENV
echo "App version: $VERSION"
- name: Decode Keystore
run: echo "${{ secrets.SIGNING_KEY_BASE64 }}" | base64 -d > ${{ github.workspace }}/android/app/signingKey.jks
- name: Create key.properties
run: |
echo "storePassword=${{ secrets.KEY_STORE_PASSWORD }}" > ${{ github.workspace }}/android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> ${{ github.workspace }}/android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> ${{ github.workspace }}/android/key.properties
echo "storeFile=${{ github.workspace }}/android/app/signingKey.jks" >> ${{ github.workspace }}/android/key.properties
- name: Build Android App Bundle
run: flutter build appbundle --release
- name: List Build Output
run: ls -la ${{ github.workspace }}/build/app/outputs/bundle/release/
- name: Get Release Info
id: get-release-info
uses: actions/github-script@v5
with:
script: |
let releaseId = 0;
try {
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
releaseId = release.data.id;
} catch (error) {
console.log('Error fetching latest release: ', error.message);
}
return releaseId;
- name: Print Release ID
run: echo "Release ID is ${{ steps.get-release-info.outputs.result }}"
- name: Upload AAB to Release
uses: actions/github-script@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const fs = require('fs');
const path = require('path');
const directory = '${{ github.workspace }}/build/app/outputs/bundle/release';
const files = fs.readdirSync(directory);
for (const file of files) {
if (file.endsWith('.aab')) {
const filePath = path.join(directory, file);
console.log(`Uploading ${file}...`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ steps.get-release-info.outputs.result }},
name: `FxFiles_v${{ env.APP_VERSION }}_${file}`,
data: fs.readFileSync(filePath)
});
}
}
# Optional: Upload to Google Play using Fastlane or r0adkll/upload-google-play
# - name: Upload to Google Play
# uses: r0adkll/upload-google-play@v1
# with:
# serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
# packageName: land.fx.files
# releaseFiles: build/app/outputs/bundle/release/app-release.aab
# track: internal
# status: completed