Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/flutter-prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Flutter Prepare
description: Set up Flutter from .flutter_version and fetch dependencies.

inputs:
app-dir:
description: Path to the Flutter application directory.
required: true

runs:
using: composite
steps:
- name: Read Flutter version
id: flutter_version
shell: bash
run: echo "version=$(cat ${{ inputs.app-dir }}/.flutter_version)" >> "$GITHUB_OUTPUT"

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ steps.flutter_version.outputs.version }}
cache: true

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.app-dir }}
run: flutter pub get
213 changes: 213 additions & 0 deletions .github/workflows/pr_build_all_platforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: Build PR Artifacts

on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review

permissions:
contents: read
pull-requests: write

concurrency:
group: pr-build-artifacts-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
APP_DIR: open_wearable

jobs:
build_android:
name: Build Android
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_android.outputs.artifact-id }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: "17"
cache: gradle

- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}

- name: Build Android APK
working-directory: ${{ env.APP_DIR }}
run: flutter build apk --release

- name: Upload Android APK
id: upload_android
uses: actions/upload-artifact@v6
with:
name: android-apk
path: open_wearable/build/app/outputs/flutter-apk/app-release.apk
if-no-files-found: error

build_linux:
name: Build Linux
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_linux.outputs.artifact-id }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
libgtk-3-dev \
ninja-build \
pkg-config

- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}

- name: Build Linux bundle
working-directory: ${{ env.APP_DIR }}
run: flutter build linux --release

- name: Upload Linux bundle
id: upload_linux
uses: actions/upload-artifact@v6
with:
name: linux-bundle
path: open_wearable/build/linux/x64/release/bundle
if-no-files-found: error

build_windows:
name: Build Windows
runs-on: windows-latest
outputs:
artifact_id: ${{ steps.upload_windows.outputs.artifact-id }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}

- name: Build Windows runner
working-directory: ${{ env.APP_DIR }}
run: flutter build windows --release

- name: Upload Windows runner
id: upload_windows
uses: actions/upload-artifact@v6
with:
name: windows-runner
path: open_wearable/build/windows/x64/runner/Release
if-no-files-found: error

build_web:
name: Build Web
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_web.outputs.artifact-id }}

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}

- name: Build Web bundle
working-directory: ${{ env.APP_DIR }}
run: flutter build web --release

- name: Upload Web bundle
id: upload_web
uses: actions/upload-artifact@v6
with:
name: web-bundle
path: open_wearable/build/web
if-no-files-found: error

comment_artifact_links:
name: Comment Artifact Links
runs-on: ubuntu-latest
needs:
- build_android
- build_linux
- build_windows
- build_web
if: always()

steps:
- name: Post or update PR comment with artifact links
uses: actions/github-script@v8
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
ANDROID_ARTIFACT_ID: ${{ needs.build_android.outputs.artifact_id }}
LINUX_ARTIFACT_ID: ${{ needs.build_linux.outputs.artifact_id }}
WINDOWS_ARTIFACT_ID: ${{ needs.build_windows.outputs.artifact_id }}
WEB_ARTIFACT_ID: ${{ needs.build_web.outputs.artifact_id }}
with:
script: |
const marker = '<!-- pr-build-artifacts -->';
const prNumber = context.payload.pull_request.number;
const runUrl = process.env.RUN_URL;
const repoUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}`;
const linkFor = (id) => id
? `${repoUrl}/actions/runs/${context.runId}/artifacts/${id}`
: runUrl;

const body = `${marker}
### PR Build Artifacts
- Android APK: [Download Android build](${linkFor(process.env.ANDROID_ARTIFACT_ID)})
- Linux Bundle: [Download Linux build](${linkFor(process.env.LINUX_ARTIFACT_ID)})
- Windows Runner: [Download Windows build](${linkFor(process.env.WINDOWS_ARTIFACT_ID)})
- Web Bundle: [Download Web build](${linkFor(process.env.WEB_ARTIFACT_ID)})

Full workflow run: ${runUrl}`;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});

const previous = comments.find(
(comment) =>
comment.user.type === 'Bot' &&
comment.body &&
comment.body.includes(marker)
);

if (previous) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: previous.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}
2 changes: 2 additions & 0 deletions open_wearable/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import file_picker
import file_selector_macos
import flutter_archive
import open_file_mac
import path_provider_foundation
import share_plus
import shared_preferences_foundation
import universal_ble
Expand All @@ -19,6 +20,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterArchivePlugin.register(with: registry.registrar(forPlugin: "FlutterArchivePlugin"))
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UniversalBlePlugin.register(with: registry.registrar(forPlugin: "UniversalBlePlugin"))
Expand Down
Loading