Skip to content

Commit 65999d7

Browse files
ci: add CI workflows for Android, Linux, and Windows builds
1 parent 2f7a128 commit 65999d7

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Flutter CI - Android
2+
3+
on:
4+
workflow_dispatch: # This is a trigger for manual workflow run
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
# Install dependencies
18+
- name: Set up Flutter
19+
uses: subosito/flutter-action@v2
20+
with:
21+
channel: 'stable'
22+
23+
- name: Set up JDK 17
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: '17'
27+
distribution: 'adopt'
28+
29+
- name: Setup Android SDK
30+
uses: android-actions/setup-android@v3
31+
32+
# Build for Android
33+
- name: Install Flutter dependencies
34+
run: flutter pub get
35+
36+
- name: Modify app_usage build.gradle
37+
run: |
38+
PUB_CACHE="${HOME}/.pub-cache"
39+
APP_USAGE_PATH="${PUB_CACHE}/hosted/pub.dev/app_usage-3.0.1/android/build.gradle"
40+
if [ -f "$APP_USAGE_PATH" ]; then
41+
sed -i 's/^ compileSdkVersion .*$/ compileSdkVersion 33/' "$APP_USAGE_PATH"
42+
sed -i '/^android {/a \ \ namespace "dk.cachet.app_usage"' "$APP_USAGE_PATH"
43+
sed -i '/^android {/a \ \ compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17; }' "$APP_USAGE_PATH"
44+
sed -i '/^android {/a \ \ kotlinOptions { jvmTarget = "17" }' "$APP_USAGE_PATH"
45+
else
46+
echo "build.gradle not found. Please check the package path."
47+
exit 1
48+
fi
49+
50+
- name: Build for Android
51+
run: flutter build apk --release
52+
53+
# Publish the build artifacts
54+
- name: Get application version
55+
id: app_version
56+
run: |
57+
APP_VERSION=$(awk '/^version:/ {print $2}' pubspec.yaml)
58+
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
59+
60+
- name: Upload Android build artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: whph-v${{ env.APP_VERSION }}-android
64+
path: build/app/outputs/flutter-apk/app-release.apk
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Flutter CI - Linux
2+
3+
on:
4+
workflow_dispatch: # This is a trigger for manual workflow run
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
# Install dependencies
18+
- name: Set up Flutter
19+
uses: subosito/flutter-action@v2
20+
with:
21+
channel: 'stable'
22+
23+
- name: Install Flutter dependencies
24+
run: flutter pub get
25+
26+
- name: Install dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y cmake ninja-build build-essential clang pkg-config libgtk-3-dev
30+
env:
31+
CXX: clang++
32+
33+
# Build for Linux
34+
- name: Build for Linux
35+
run: flutter build linux --release
36+
37+
# Publish the build artifacts
38+
- name: Get application version
39+
id: app_version
40+
run: |
41+
APP_VERSION=$(awk '/^version:/ {print $2}' pubspec.yaml)
42+
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
43+
44+
- name: Upload Linux build artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: whph-v${{ env.APP_VERSION }}-linux
48+
path: build/linux/x64/release/bundle/
49+
if-no-files-found: warn
50+
compression-level: 6
51+
overwrite: false
52+
include-hidden-files: false
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Flutter CI - Windows
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
16+
# Install dependencies
17+
- name: Set up Flutter
18+
uses: subosito/flutter-action@v2
19+
with:
20+
channel: "stable"
21+
22+
- name: Install Flutter dependencies
23+
run: flutter pub get
24+
25+
# Build for Windows
26+
- name: Build for Windows
27+
run: flutter build windows --release
28+
29+
# Publish the build artifacts
30+
- name: Get application version
31+
id: app_version
32+
run: |
33+
$content = Get-Content 'pubspec.yaml'
34+
$version = $content | Select-String 'version: (.*)' | ForEach-Object { $_.Matches.Groups[1].Value }
35+
echo "App version is $version"
36+
echo "APP_VERSION=$version" >> $GITHUB_ENV
37+
38+
- name: Upload Windows build artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: whph-v${{ env.APP_VERSION }}-windows
42+
path: build/windows/runner/Release/

0 commit comments

Comments
 (0)