-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (106 loc) · 3.51 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Gonpa Tour CICD
on:
push:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Needed for version generation
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.4'
channel: 'stable'
cache: true
- name: Check Flutter version
run: flutter --version
- name: Get dependencies
run: flutter pub get
- name: Generate version number
id: version
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "v0.0.0")
# Extract version numbers
MAJOR=$(echo $LATEST_TAG | cut -d. -f1 | tr -d 'v')
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
PATCH=$(echo $LATEST_TAG | cut -d. -f3)
# Increment patch version
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v$MAJOR.$MINOR.$NEW_PATCH"
# Set output
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Build APK
run: flutter build apk --debug
- name: Get PR message
if: github.event_name == 'pull_request'
id: pr_message
run: echo "pr_message=$(jq -r .pull_request.body < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.new_version }}
release_name: Release ${{ steps.version.outputs.new_version }}
body: ${{ env.pr_message || 'No changelog provided.' }}
draft: false
prerelease: false
- name: Upload Release APK
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/app/outputs/flutter-apk/app-debug.apk
asset_name: app-debug.apk
asset_content_type: application/vnd.android.package-archive
# Optional: Upload artifact for debugging
- name: Upload APK Artifact
uses: actions/upload-artifact@v3
with:
name: release-apk
path: build/app/outputs/flutter-apk/app-debug.apk
retention-days: 5
ios-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Needed for version generation
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.4'
channel: 'stable'
cache: true
- name: Check Flutter version
run: flutter --version
- name: Get dependencies
run: flutter pub get
- name: Build iOS
run: flutter build ios --no-codesign
- name: Upload iOS Artifact
uses: actions/upload-artifact@v3
with:
name: release-ios
path: build/ios/ipa
retention-days: 5