Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
16d810192This file is pinned to the selected release. Download the original to open it in your design tool.
name: Flutter CI
permissions:
contents: write
on:
push:
branches: [master]
paths:
- 'client/**'
- '.github/workflows/flutter-ci.yml'
pull_request:
branches: [master]
paths:
- 'client/**'
- '.github/workflows/flutter-ci.yml'
workflow_dispatch:
env:
FLUTTER_WORKING_DIR: client
jobs:
test:
runs-on: ubuntu-latest
if: ${{ vars.BO_EDITION == 'ce' }}
defaults:
run:
working-directory: ${{ env.FLUTTER_WORKING_DIR }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: client/pubspec.yaml
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('client/pubspec.yaml', 'client/pubspec.lock', 'client/packages/*/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-cache-
- name: Add pub cache to PATH
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Activate melos and bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Run Melos format check
run: melos format --set-exit-if-changed .
- name: Run analyze
run: melos run analyze
- name: Run unit/widget tests
run: |
flutter test
melos run test:dart --no-select
- name: Install requirements for desktop integration tests and Linux builds)
run: sudo apt-get update && sudo apt-get install -y xvfb libgtk-3-dev libstdc++-12-dev
- name: Run linux integration tests
if: runner.os == 'Linux'
# desktop integration tests run on the same container; wrap in Xvfb
run: |
xvfb-run flutter test integration_test/app_test.dart -d linux -r github
get-version:
if: ${{ vars.BO_EDITION == 'ce' }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
version_base: ${{ steps.extract.outputs.version_base }}
build_number: ${{ steps.extract.outputs.build_number }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version & build number
id: extract
run: |
# read base version from pubspec (client folder)
VERSION_BASE=$(grep '^version:' client/pubspec.yaml | head -n1 | awk '{print $2}' | cut -d'+' -f1)
# use the workflow run number provided by GitHub Actions
BUILD_NUM="$GITHUB_RUN_NUMBER"
VERSION_PLUS="${VERSION_BASE}+${BUILD_NUM}"
echo "version_base=${VERSION_BASE}" >> $GITHUB_OUTPUT
echo "build_number=${BUILD_NUM}" >> $GITHUB_OUTPUT
echo "version=${VERSION_PLUS}" >> $GITHUB_OUTPUT
build-apk:
if: ${{ vars.BO_EDITION == 'ce' }}
needs: [test, get-version]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.FLUTTER_WORKING_DIR }}
outputs:
version: ${{ needs.get-version.outputs.version }}
version_base: ${{ needs.get-version.outputs.version_base }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Decode keystore from base64
shell: bash
run: |
printf "%s" "$KEYSTORE_BASE64" | base64 -d > android/app/keystore.jks
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Set up signing properties
run: |
cat > android/app/key.properties << EOF
storeFile=keystore.jks
keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}
storePassword=${{ secrets.KEYSTORE_PASSWORD }}
keyPassword=${{ secrets.KEYSTORE_PASSWORD }}
EOF
- name: Validate Android keystore
shell: bash
run: |
keytool -list -keystore android/app/keystore.jks -storepass "$KEYSTORE_PASSWORD" -alias "$KEYSTORE_KEY_ALIAS"
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: client/pubspec.yaml
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('client/pubspec.yaml', 'client/pubspec.lock', 'client/packages/*/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-cache-
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('client/**/*.gradle*', 'client/**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Add pub cache to PATH
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Activate melos and bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Get Flutter dependencies
run: flutter pub get
- name: Build APK
run: flutter build apk --release --target-platform android-arm64 --build-number ${{ needs.get-version.outputs.build_number }}
- name: Rename APK with version
run: |
mv build/app/outputs/flutter-apk/app-release.apk \
build/app/outputs/flutter-apk/borneo-app-ce-${{ needs.get-version.outputs.version }}.apk
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: borneo-app-ce-${{ needs.get-version.outputs.version }}
path: ${{ github.workspace }}/${{ env.FLUTTER_WORKING_DIR }}/build/app/outputs/flutter-apk/borneo-app-ce-${{ needs.get-version.outputs.version }}.apk
build-windows:
if: ${{ vars.BO_EDITION == 'ce' }}
needs: [test, get-version]
runs-on: windows-latest
defaults:
run:
working-directory: ${{ env.FLUTTER_WORKING_DIR }}
outputs:
version: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: client/pubspec.yaml
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('client/pubspec.yaml', 'client/pubspec.lock', 'client/packages/*/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-cache-
# Cache NuGet packages to speed MSBuild / CMake native deps
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('client/windows/**') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Cache MSBuild
uses: actions/cache@v4
with:
path: ~/AppData/Local/Microsoft/VisualStudio
key: ${{ runner.os }}-msbuild-${{ hashFiles('client/windows/**') }}
restore-keys: ${{ runner.os }}-msbuild-
# Pre-download Flutter engine/artifacts for Windows (avoid on-the-fly downloads)
- name: Flutter precache (windows)
run: flutter precache --windows
- name: Activate melos and bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Get Flutter dependencies
run: flutter pub get
- name: Build Windows executable
run: flutter build windows --release --build-number ${{ needs.get-version.outputs.build_number }}
- name: Create and zip Windows release
run: |
pwsh ./scripts/windows-dist-pack.ps1 ce-${{ needs.get-version.outputs.version }}
- name: Upload Windows zip artifact
uses: actions/upload-artifact@v4
with:
name: borneo-app-ce-${{ needs.get-version.outputs.version }}-windows-x64
path: client/build/windows/dist/borneo-app-ce-${{ needs.get-version.outputs.version }}-windows-x64.zip
build-ios:
if: ${{ vars.BO_EDITION == 'ce' }}
needs: [test, get-version]
runs-on: macos-15
defaults:
run:
working-directory: ${{ env.FLUTTER_WORKING_DIR }}
outputs:
version: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Select Xcode 26.1.1
run: |
sudo xcode-select -s /Applications/Xcode_26.1.1.app/Contents/Developer
xcodebuild -version
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version-file: client/pubspec.yaml
cache: true
- name: Cache pub dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('client/pubspec.yaml', 'client/pubspec.lock', 'client/packages/*/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-cache-
- name: Cache CocoaPods
uses: actions/cache@v4
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
${{ github.workspace }}/client/ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('client/ios/Podfile.lock') }}
restore-keys: ${{ runner.os }}-pods-
- name: Flutter precache (iOS)
run: flutter precache --ios
- name: Activate melos and bootstrap
run: |
dart pub global activate melos
melos bootstrap
- name: Get Flutter dependencies
run: flutter pub get
- name: Build iOS app (no codesign)
run: flutter build ios --release --no-codesign --build-number ${{ needs.get-version.outputs.build_number }}
release:
needs: [build-apk, build-windows, build-ios]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' && vars.BO_EDITION == 'ce' }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./release-artifacts
merge-multiple: true
- name: Set prerelease flag
id: set_prerelease
run: |
if [[ "${{ needs.build-apk.outputs.version }}" == *beta* || "${{ needs.build-apk.outputs.version }}" == *alpha* ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Create latest asset aliases
run: |
cp \
"release-artifacts/borneo-app-ce-${{ needs.build-apk.outputs.version }}.apk" \
"release-artifacts/borneo-app-ce-latest.apk"
cp \
"release-artifacts/borneo-app-ce-${{ needs.build-windows.outputs.version }}-windows-x64.zip" \
"release-artifacts/borneo-app-ce-latest.windows-x64.zip"
- name: Create Versionized GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: app-ce-v${{ needs.build-apk.outputs.version_base }}
name: Borneo-IoT App Release app-ce-v${{ needs.build-apk.outputs.version_base }}
draft: false
overwrite_files: true
prerelease: ${{ steps.set_prerelease.outputs.prerelease }}
files: |
release-artifacts/borneo-app-ce-${{ needs.build-apk.outputs.version }}.apk
release-artifacts/borneo-app-ce-${{ needs.build-windows.outputs.version }}-windows-x64.zip
- name: Delete previous latest app release and tag
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = 'release-app-latest';
const refName = `tags/${tag}`;
const fullRef = `refs/tags/${tag}`;
// Delete the release first (while tag still points to old SHA, so getReleaseByTag works)
try {
const rel = await github.rest.repos.getReleaseByTag({ owner: context.repo.owner, repo: context.repo.repo, tag });
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: rel.data.id,
});
console.log('Deleted previous latest app release.');
} catch (err) {
if (err.status === 404) {
console.log('Latest app release not found, nothing to delete.');
} else {
throw err;
}
}
// Then delete and recreate the tag pointing to the current commit
try {
await github.rest.git.deleteRef({ owner: context.repo.owner, repo: context.repo.repo, ref: refName });
console.log(`Deleted existing tag ${tag}`);
} catch (err) {
// GitHub returns 404 _or_ 422 when the tag doesn't exist; ignore both
if (err.status === 404 || err.status === 422) {
console.log(`Tag ${tag} did not exist, proceeding to create`);
} else {
throw err;
}
}
await github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, ref: fullRef, sha: context.sha });
console.log(`Created tag ${tag} pointing to ${context.sha}`);
- name: Create GitHub Latest App Release
uses: softprops/action-gh-release@v2
with:
tag_name: release-app-latest
name: Latest App Release
draft: false
overwrite_files: true
files: |
release-artifacts/borneo-app-ce-${{ needs.build-apk.outputs.version }}.apk
release-artifacts/borneo-app-ce-latest.apk
release-artifacts/borneo-app-ce-${{ needs.build-windows.outputs.version }}-windows-x64.zip
release-artifacts/borneo-app-ce-latest.windows-x64.zip