Skip to content

Commit e35021d

Browse files
update: workflows
1 parent 83b0d61 commit e35021d

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
1-
name: Flutter Build
1+
name: Flutter Android Build
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main] # Adjust this to match your main branch name (e.g., master, main, develop)
6+
tags:
7+
- "v*" # This will trigger the workflow when you push a tag starting with 'v'
8+
9+
# Add permissions needed for creating releases
10+
permissions:
11+
contents: write
12+
packages: write
713

814
jobs:
915
build:
1016
runs-on: ubuntu-latest
11-
1217
steps:
1318
- name: Checkout code
14-
uses: actions/checkout@v4
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Java
22+
uses: actions/setup-java@v3
23+
with:
24+
distribution: "zulu"
25+
java-version: "17"
26+
cache: gradle
1527

1628
- name: Set up Flutter
1729
uses: subosito/flutter-action@v2
1830
with:
19-
flutter-version: "stable"
31+
flutter-version: "3.29.2"
2032
channel: "stable"
21-
22-
- name: Cache Flutter dependencies
23-
uses: actions/cache@v3
24-
with:
25-
path: ~/.pub-cache
26-
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.yaml') }}
27-
restore-keys: |
28-
${{ runner.os }}-pub-cache-
33+
cache: true
2934

3035
- name: Install dependencies
3136
run: flutter pub get
3237

3338
- name: Build APK
3439
run: flutter build apk --release
3540

36-
- name: Upload APK
37-
uses: actions/upload-artifact@v4
41+
- name: Upload APK as artifact
42+
uses: actions/upload-artifact@v4.6.2
3843
with:
39-
name: flutter-apk
44+
name: app-release
4045
path: build/app/outputs/flutter-apk/app-release.apk
41-
retention-days: 7
46+
47+
- name: Get version from pubspec
48+
id: get_version
49+
if: startsWith(github.ref, 'refs/heads/main')
50+
run: |
51+
VERSION=$(grep 'version:' pubspec.yaml | awk '{print $2}' | tr -d "'" | tr -d '"')
52+
echo "VERSION=$VERSION" >> $GITHUB_ENV
53+
54+
- name: Create Release
55+
id: create_release
56+
if: startsWith(github.ref, 'refs/heads/main')
57+
uses: softprops/[email protected]
58+
with:
59+
tag_name: v${{ env.VERSION }}
60+
name: Release v${{ env.VERSION }}
61+
draft: false
62+
prerelease: false
63+
files: build/app/outputs/flutter-apk/app-release.apk
64+
generate_release_notes: true
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)