Skip to content

Commit b29f08a

Browse files
committed
Updating workflow and make file
1 parent 62f3b78 commit b29f08a

3 files changed

Lines changed: 332 additions & 274 deletions

File tree

Lines changed: 113 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,124 @@
1-
name: Flutter CI/CD - Build APK & Deploy Web
1+
name: Flutter Release
22

33
on:
44
push:
55
tags:
6-
- 'v*' # Trigger on version tags (e.g., v1.0.0)
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
pages: write
11+
id-token: write
712

813
env:
9-
FLUTTER_VERSION: '3.38.5' # Specify your Flutter version
10-
BUILD_NUMBER: ${{ github.run_number }}
11-
BUILD_DATE: ${{ github.event.head_commit.timestamp }}
14+
FLUTTER_VERSION: '3.41.8'
15+
JAVA_VERSION: '17'
1216

1317
jobs:
18+
19+
# ─────────────────────────────────────────────
20+
# JOB 1 — Build & Deploy Flutter Web → gh-pages
21+
# ─────────────────────────────────────────────
22+
deploy-web:
23+
name: Deploy Web to GitHub Pages
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Flutter
31+
uses: subosito/flutter-action@v2
32+
with:
33+
flutter-version: ${{ env.FLUTTER_VERSION }}
34+
channel: master
35+
36+
- name: Install dependencies
37+
run: flutter pub get
38+
39+
- name: Build Flutter Web
40+
run: |
41+
flutter build web \
42+
--release \
43+
--base-href "/${{ github.event.repository.name }}/"
44+
45+
- name: Deploy to GitHub Pages (gh-pages branch)
46+
uses: peaceiris/actions-gh-pages@v4
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: build/web
50+
publish_branch: gh-pages
51+
# Optional: keep old deployments or force-push
52+
force_orphan: false
53+
# Optional: add a .nojekyll file so assets load correctly
54+
enable_jekyll: false
55+
commit_message: "deploy: web build for ${{ github.ref_name }}"
56+
57+
# ─────────────────────────────────────────────
58+
# JOB 2 — Build Android APK with ABI splits
59+
# ─────────────────────────────────────────────
1460
build-android:
61+
name: Build & Release Android APK
1562
runs-on: ubuntu-latest
16-
permissions:
17-
contents: write # Required for creating releases
18-
63+
1964
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
23-
- name: Set up Java
24-
uses: actions/setup-java@v3
25-
with:
26-
distribution: 'temurin'
27-
java-version: '21'
28-
29-
- name: Set up Flutter
30-
uses: subosito/flutter-action@v2
31-
with:
32-
flutter-version: ${{ env.FLUTTER_VERSION }}
33-
channel: stable
34-
cache: true
35-
36-
- name: Install dependencies
37-
run: flutter pub get
38-
39-
- name: Verify Flutter installation
40-
run: flutter doctor -v
41-
42-
- name: Build APK (Release - Unsigned)
43-
run: |
44-
flutter build apk --release --target-platform android-arm64
45-
echo "APK built successfully!"
46-
ls -la build/app/outputs/flutter-apk/
47-
48-
- name: Upload APK artifact
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: app-release-unsigned
52-
path: build/app/outputs/flutter-apk/app-release-arm64.apk
53-
retention-days: 2
54-
55-
- name: Create GitHub Release
56-
if: startsWith(github.ref, 'refs/tags/v')
57-
uses: softprops/action-gh-release@v1
58-
with:
59-
files: build/app/outputs/flutter-apk/app-release-arm64.apk
60-
generate_release_notes: true
61-
prerelease: false
62-
draft: false
63-
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Java
69+
uses: actions/setup-java@v4
70+
with:
71+
distribution: temurin
72+
java-version: ${{ env.JAVA_VERSION }}
73+
74+
- name: Setup Flutter
75+
uses: subosito/flutter-action@v2
76+
with:
77+
flutter-version: ${{ env.FLUTTER_VERSION }}
78+
channel: stable
79+
cache: true
80+
81+
- name: Install dependencies
82+
run: flutter pub get
83+
84+
# ── Build split APKs (one per ABI) ──
85+
- name: Build APKs (split per ABI)
86+
run: |
87+
flutter build apk \
88+
--release \
89+
--split-per-abi
90+
91+
# Output files:
92+
# build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
93+
# build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
94+
# build/app/outputs/flutter-apk/app-x86_64-release.apk
95+
96+
- name: Rename APKs with version tag
97+
run: |
98+
TAG="${{ github.ref_name }}"
99+
cd build/app/outputs/flutter-apk
100+
for apk in app-*-release.apk; do
101+
abi="${apk#app-}"
102+
abi="${abi%-release.apk}"
103+
mv "$apk" "app-${abi}-${TAG}.apk"
104+
done
105+
106+
- name: Upload APKs as artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: apks-${{ github.ref_name }}
110+
path: build/app/outputs/flutter-apk/*.apk
111+
retention-days: 7
112+
113+
# ── Create GitHub Release & attach APKs ──
114+
- name: Create GitHub Release
115+
uses: softprops/action-gh-release@v2
116+
with:
117+
tag_name: ${{ github.ref_name }}
118+
name: Release ${{ github.ref_name }}
119+
draft: false
120+
prerelease: ${{ contains(github.ref_name, '-') }} # e.g. v1.0.0-beta → pre-release
121+
generate_release_notes: true
122+
files: build/app/outputs/flutter-apk/*.apk
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
.PHONY: all check autogen rebuild build_runner deploy pip_install build_web gen_l10n gen_icon run_web claude doc run_doc
2+
.PHONY: all check autogen rebuild build_runner deploy_web pip_install build_web gen_l10n gen_icon run_web claude doc run_doc
33

44
claude:
55
ollama launch claude --model llama3.1:latest
@@ -18,7 +18,7 @@ gen_icon:
1818
dart run icons_launcher:create
1919

2020
gen_l10n:
21-
flutter gen-l10ns
21+
flutter gen-l10n
2222

2323
dist_linux:
2424
flutter_distributor release --name=dev --jobs=release-dev-linux-deb
@@ -49,9 +49,7 @@ add_assets:
4949

5050
all: clean autogen build_runner
5151

52-
deploy: clean all gen_l10n
52+
deploy_web: clean all gen_l10n
5353
# flutter pub global run dependency_validator
5454
flutter pub global run peanut --extra-args --base-href=/ --no-wasm --release
5555
git push origin --set-upstream gh-pages
56-
57-
# dart run rename_app:main all="My App Name"

0 commit comments

Comments
 (0)