-
Notifications
You must be signed in to change notification settings - Fork 33
242 lines (201 loc) · 8.29 KB
/
Copy pathrelease.yml
File metadata and controls
242 lines (201 loc) · 8.29 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: Build and Release APK
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag version (e.g., v1.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
build-android-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && 'master' || github.ref }}
- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG=${GITHUB_REF#refs/tags/}
fi
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Check if tag contains beta
if [[ "$TAG" == *"beta"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Update pubspec.yaml version
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}+${{ github.run_number }}/" pubspec.yaml
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.2'
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Decode keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > android/app/keystore.jks
- name: Create key.properties
run: |
echo "storePassword=${{ secrets.STORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
- name: Build APK - All-in-one (arm64-v8a + armeabi-v7a)
run: |
flutter build apk --release --target-platform android-arm64,android-arm
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-allinone.apk
- name: Build APK - ARM64 (v8a)
run: |
flutter build apk --release --target-platform android-arm64
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-arm64-v8a.apk
- name: Build APK - ARMv7
run: |
flutter build apk --release --target-platform android-arm
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-armeabi-v7a.apk
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-artifacts
path: |
build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-allinone.apk
build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-arm64-v8a.apk
build/app/outputs/flutter-apk/pt_mate-${{ steps.version.outputs.version }}-armeabi-v7a.apk
retention-days: 1
# 直接在Android构建后添加Linux构建步骤
- name: Install Linux dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libblkid-dev libsecret-1-dev
- name: Build Linux
run: flutter build linux --release
- name: Create Linux package
run: |
mkdir -p pt_mate-${{ steps.version.outputs.version }}-linux-x64
cp -r build/linux/x64/release/bundle/* pt_mate-${{ steps.version.outputs.version }}-linux-x64/
tar -czf pt_mate-${{ steps.version.outputs.version }}-linux-x64.tar.gz pt_mate-${{ steps.version.outputs.version }}-linux-x64
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: linux-artifact
path: pt_mate-${{ steps.version.outputs.version }}-linux-x64.tar.gz
retention-days: 1
build-windows:
runs-on: windows-latest
# 移除对Android构建的依赖,实现并行构建
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && 'master' || github.ref }}
- name: Extract version from tag
id: version
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG=${GITHUB_REF#refs/tags/}
fi
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.2'
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Build Windows
run: flutter build windows --release
- name: Install Inno Setup
run: |
choco install innosetup -y
- name: Download Chinese language file
run: |
$languagesDir = "C:\Program Files (x86)\Inno Setup 6\Languages"
if (-not (Test-Path "$languagesDir\ChineseSimplified.isl")) {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "$languagesDir\ChineseSimplified.isl"
}
- name: Compile Inno Setup installer
run: |
iscc /DMyAppVersion="${{ steps.version.outputs.version }}" windows/inno_setup.iss
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-artifact
path: Output/pt_mate-${{ steps.version.outputs.version }}-windows-x64.exe
retention-days: 1
create-release:
runs-on: ubuntu-latest
needs: [build-android-linux, build-windows]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && 'master' || github.ref }}
- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG=${GITHUB_REF#refs/tags/}
fi
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Check if tag contains beta
if [[ "$TAG" == *"beta"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release and Upload All Artifacts
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body: |
## Changes in this release
${{ github.event.head_commit.message }}
## 📱 Android APK Downloads
- **All-in-one APK** (arm64-v8a + armeabi-v7a): Compatible with most devices
- **ARM64 APK** (arm64-v8a): For modern 64-bit devices
- **ARMv7 APK** (armeabi-v7a): For older 32-bit devices
## 💻 Desktop Downloads
- **Windows x64**: Windows installer for 64-bit systems
- **Linux x64**: Linux package for 64-bit systems
draft: false
prerelease: ${{ steps.version.outputs.is_prerelease }}
files: |
android-artifacts/pt_mate-${{ steps.version.outputs.version }}-allinone.apk
android-artifacts/pt_mate-${{ steps.version.outputs.version }}-arm64-v8a.apk
android-artifacts/pt_mate-${{ steps.version.outputs.version }}-armeabi-v7a.apk
windows-artifact/pt_mate-${{ steps.version.outputs.version }}-windows-x64.exe
linux-artifact/pt_mate-${{ steps.version.outputs.version }}-linux-x64.tar.gz
fail_on_unmatched_files: true