-
Notifications
You must be signed in to change notification settings - Fork 128
271 lines (238 loc) · 8.96 KB
/
release.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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Build Release
on:
push:
branches:
- 'master'
tags:
- v*
- '!v*ios'
- '!v*apk'
- '!v*mac'
- '!v*win'
- '!v*.flutter2'
- '!v*.bot'
- '!v*.linux'
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
PACKAGE_NAME: Eros-FE
jobs:
Build_and_upload:
name: Build releases
strategy:
fail-fast: false
matrix:
target: ["android", "ios", "macos", "windows"]
flutter_version: ["3.22.x"]
flutter_channel: ["stable"]
include:
- target: android
os: ubuntu-latest
artifact_name: release-apk
artifact_path: build/app/outputs/apk/release/Eros-FE*.apk
- target: ios
os: macos-14
artifact_name: release-ios
artifact_path: build/**/Eros-FE*.ipa
- target: macos
os: macos-14
artifact_name: release-mac
artifact_path: build/macos/Eros-FE*.zip
- target: windows
os: windows-latest
artifact_name: release-windows
artifact_path: build/windows/Eros-FE*.zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
# Get app version
- name: Get app version
id: get_version
shell: bash
run: |
app_version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2)
echo "app_version=${app_version}" >> $GITHUB_ENV
- name: show version
run: echo ${{ env.app_version }}
# - name: Cache Pods (build macos)
# uses: actions/cache@v3
# if: matrix.target == 'macos'
# with:
# path: |
# macos/Pods
# key: ${{ runner.os }}-pods-${{ hashFiles('macos/Podfile.lock') }}
# restore-keys: |
# ${{ runner.os }}-pods-
# - name: Cache Pods (build ios)
# uses: actions/cache@v3
# if: matrix.target == 'ios'
# with:
# path: |
# ios/Pods
# key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
# restore-keys: |
# ${{ runner.os }}-pods-
# git-crypt unlock
- name: Unlock secrets (MacOS)
if: matrix.os == 'macos-14'
run: |
brew install git-crypt
echo $GIT_CRYPT_KEY | base64 -d -o grypt.key
git-crypt unlock grypt.key
env:
GIT_CRYPT_KEY: ${{ secrets.ENCODED_GIT_CRYPT }}
- name: Unlock secrets (Linux)
if: matrix.os == 'ubuntu-latest'
uses: sliteteam/[email protected]
env:
GIT_CRYPT_KEY: ${{ secrets.ENCODED_GIT_CRYPT }}
- name: Unlock secrets (Windows)
if: matrix.os == 'windows-latest'
run: |
Invoke-WebRequest -Uri https://github.com/AGWA/git-crypt/releases/download/0.7.0/git-crypt-0.7.0-x86_64.exe -OutFile git-crypt.exe
echo "${{ secrets.ENCODED_GIT_CRYPT }}" | openssl base64 -d -out git-crypt.key
.\git-crypt.exe unlock .\git-crypt.key
- name: Decode keystore
if: matrix.target == 'android'
run: |
echo $ENCODED_KEYSTORE | base64 -di > android/app/keystore.jks
env:
ENCODED_KEYSTORE: ${{ secrets.ENCODED_KEYSTORE }}
# 安装 JDK
- name: Setup Java JDK (Android)
if: matrix.target == 'android'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
# cache: gradle
# 安装 Flutter
- name: Flutter action
uses: subosito/[email protected]
with:
flutter-version: ${{ matrix.flutter_version }}
channel: ${{ matrix.flutter_channel }}
- name: Flutter version
run: flutter --version
- name: Build resolve Swift dependencies
if: matrix.target == 'macos'
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release
# - name: replace cronet_http
# if: matrix.target == 'macos'
# shell: bash
# run: |
# brew install gnu-sed
# export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
# which sed
# which gsed
# gsed -i "s,#cronet_http: ^0.2.1,cronet_http: ^0.2.1,g" pubspec.yaml
# grep cronet_http pubspec.yaml
# git stash
- name: ios disable impeller
if: matrix.target == 'ios' && matrix.suffix == '-canvas'
run: |
sed -i '' '/FLTEnableImpeller/{n; s/true/false/;}' ios/Runner/Info.plist
- name: Flutter pub get
run: |
git config --global core.longpaths true
flutter pub get && flutter pub upgrade
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run intl_utils:generate
# 打包 apk
- name: Collect Apks
if: matrix.target == 'android'
run: flutter build apk --release
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}}
# 打包 ipa
- name: Build ios app
if: matrix.target == 'ios'
run: |
sed -i '' 's/dev2.cn.honjow.fehv/cn.honjow.fehv/g' 'ios/Runner.xcodeproj/project.pbxproj'
rm ios/Podfile.lock
cd ios && pod update && pod install --repo-update && cd ..
flutter build ios --release --no-codesign
- name: upload-symbols
if: matrix.target == 'ios'
run: find build/ios/Release-iphoneos -name "*.dSYM" | xargs -I \{\} ios/Pods/FirebaseCrashlytics/upload-symbols -gsp ios/Runner/GoogleService-Info.plist -p ios \{\}
- name: Thin app
if: matrix.target == 'ios'
run: sh scripts/thin-payload.sh build/ios/iphoneos/*.app
- name: Build ipa file
if: matrix.target == 'ios'
run: |
cd build
mkdir -p Payload
mv ios/iphoneos/*.app Payload
zip -9 ${{ env.PACKAGE_NAME }}${{ matrix.suffix }}_${{ env.app_version }}.ipa -r Payload
# 打包 mac
- name: Build mac app
if: matrix.target == 'macos'
run: |
cd macos && pod update && pod install && cd ..
flutter build macos --release
APP_PATH=build/macos/Build/Products/Release/fehviewer.app
cp -a $APP_PATH ./build
cd build && zip -qroy macos/${{ env.PACKAGE_NAME }}_${{ env.app_version }}_macos.zip fehviewer.app
- name: Build windows
if: matrix.target == 'windows'
run: |
flutter build windows --release
$DestDir = "build\windows\${{ env.PACKAGE_NAME }}"
$SrcDir = "build\windows\x64\runner\Release"
New-Item -Path $DestDir -ItemType Directory
Copy-Item $SrcDir\* -Recurse $DestDir
Copy-Item -Filter *.dll -Path windows\* -Destination $DestDir -Force
Compress-Archive $DestDir build\windows\${{ env.PACKAGE_NAME }}_${{ env.app_version }}_windows.zip
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
Publish_releases:
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') && !contains(github.ref, 'rc')
name: Publish releases
needs: Build_and_upload
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: mkdir /tmp/artifacts
- name: Download all Artifacts
uses: actions/download-artifact@v3
with:
path: /tmp/artifacts
- run: ls -R /tmp/artifacts
# Get app version
- name: Get app version
id: get_version
shell: bash
run: |
app_version=$(head -n 5 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2)
echo "app_version=${app_version}" >> $GITHUB_ENV
- name: Upload to release
uses: ncipollo/release-action@v1
with:
artifacts: "/tmp/artifacts/release-apk/*.apk,/tmp/artifacts/release-ios*/*.ipa,/tmp/artifacts/release-mac/*.zip"
tag: ${{ github.ref_name }}
bodyFile: changelog/v${{ env.app_version }}.md
prerelease: contains(github.ref, 'pre')
allowUpdates: true
artifactErrorsFailBuild: true
replacesArtifacts: true
# - name: Post release notes
# run: |
# changelog=$(cat changelog/v${{ env.app_version }}.md)
# curl 'https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage' \
# --header 'Content-Type: application/x-www-form-urlencoded' \
# -d parse_mode=markdown \
# -d chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }} \
# --data-urlencode text="[Eros-FE_${{ github.ref_name }}](https://github.com/honjow/FEhViewer/releases/tag/${{ github.ref_name }})
# $changelog" \
# -d disable_web_page_preview=true