-
Notifications
You must be signed in to change notification settings - Fork 138
296 lines (270 loc) · 12.1 KB
/
build.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: build
on:
workflow_dispatch:
release:
types: [ published ]
env:
FLUTTER_VERSION: "3.16.0"
CORE_VERSION: "1.18.1"
jobs:
get-release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get-release.outputs.tag_name }}
upload_url: ${{ steps.get-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- uses: thebritican/fetch-latest-release@v2.0.0
id: get-release
build-windows:
runs-on: windows-latest
needs: [ get-release ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- name: Mkdir core
run: mkdir core
- name: Build
env:
VERSION: ${{ needs.get-release.outputs.tag_name }}
run: |
pushd core
Invoke-WebRequest -Uri "https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-windows-amd64.tar.gz" -OutFile "libclash.tar.gz"
tar -zxf libclash.tar.gz
mv build/*.dll libclash.dll
popd
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "ChineseSimplified.isl"
mv ChineseSimplified.isl "C:\Program Files (x86)\Inno Setup 6\Languages\"
flutter build windows
$mingw = "C:\Program Files\Git\mingw64\bin"
$system = "C:\Windows\System32"
$release = "build/windows\x64\runner\Release\"
cp $system\msvcp140.dll $release
cp $system\vcruntime140.dll $release
cp $system\vcruntime140_1.dll $release
New-Item -Path build/windows\x64\Output -ItemType Directory
Compress-Archive -Path "$release*" -DestinationPath "build/windows\x64\Output\clash_for_flutter-$env:VERSION-windows-amd64-portable.zip"
cd build/windows/x64
echo @"
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Clash for Flutter"
#define MyAppVersion "$($env:VERSION)"
#define MyAppPublisher "mapleafgo"
#define MyAppURL "https://github.com/mapleafgo/clash-for-flutter"
#define MyAppExeName "clash_for_flutter.exe"
#define MyOutputName "clash_for_flutter"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{B3039CF4-E394-42B6-971C-4BE97F322DE8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyOutputName}
DisableProgramGroupPage=yes
LicenseFile=..\..\..\LICENSE
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename={#MyOutputName}
SetupIconFile=..\..\..\assets\icon.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
LanguageDetectionMethod=uilanguage
ShowLanguageDialog=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: ".\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[UninstallDelete]
Type: filesandordirs; Name: "{app}"
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
"@ > setup.iss
iscc.exe setup.iss
mv "Output\clash_for_flutter.exe" "Output\clash_for_flutter-$env:VERSION-windows-amd64.exe"
Compress-Archive -Path "Output\clash_for_flutter-$env:VERSION-windows-amd64.exe" -DestinationPath "Output\clash_for_flutter-$env:VERSION-windows-amd64.zip"
Remove-Item -Path "Output\clash_for_flutter-$env:VERSION-windows-amd64.exe"
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: build/windows/x64/Output/*
overwrite: true
build-linux-amd64:
runs-on: ubuntu-20.04
needs: [ get-release ]
steps:
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- run: |
sudo apt-get update -y
sudo apt-get install -y locate ninja-build libgtk-3-dev libayatana-appindicator3-dev libnotify-dev \
binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync
- name: Mkdir core
run: mkdir core
- name: Build
env:
VERSION: ${{ needs.get-release.outputs.tag_name }}
run: |
curl -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o /usr/local/bin/appimagetool
chmod +x /usr/local/bin/appimagetool
pushd core
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-linux-amd64.tar.gz -o libclash.tar.gz
tar -zxf libclash.tar.gz
mv build/*.so libclash.so
popd
dart pub global activate flutter_distributor
flutter_distributor package --platform=linux --targets=appimage,zip
mv dist/*/*.appimage dist/clash_for_flutter-$VERSION-linux-amd64.AppImage
mv dist/*/*.zip dist/clash_for_flutter-$VERSION-linux-amd64.zip
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: dist/*amd64*
overwrite: true
build-linux-arm64:
runs-on: ubuntu-20.04
needs: [ get-release ]
steps:
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- run: |
sudo apt-get update -y
sudo apt-get install -y locate ninja-build libgtk-3-dev libayatana-appindicator3-dev libnotify-dev \
binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync
- name: Mkdir core
run: mkdir core
- name: Build
env:
VERSION: ${{ needs.get-release.outputs.tag_name }}
run: |
curl -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o /usr/local/bin/appimagetool
chmod +x /usr/local/bin/appimagetool
pushd core
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-linux-arm64.tar.gz -o libclash.tar.gz
tar -zxf libclash.tar.gz
mv build/*.so libclash.so
popd
dart pub global activate flutter_distributor
flutter_distributor package --platform=linux --targets=appimage,zip
mv dist/*/*.appimage dist/clash_for_flutter-$VERSION-linux-arm64.AppImage
mv dist/*/*.zip dist/clash_for_flutter-$VERSION-linux-arm64.zip
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: dist/*arm64*
overwrite: true
build-macos:
runs-on: macos-latest
needs: [ get-release ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- name: Install appdmg
run: |
python3 -m pip install setuptools
npm install -g appdmg
- name: Mkdir core
run: mkdir core
- name: Build
env:
VERSION: ${{ needs.get-release.outputs.tag_name }}
run: |
PROJECT_DIR=$(pwd)
pushd core
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-darwin-amd64.tar.gz -o libclash-amd64.tar.gz
tar -zxf libclash-amd64.tar.gz
mv build/*.dylib libclash-amd64.dylib
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-darwin-arm64.tar.gz -o libclash-arm64.tar.gz
tar -zxf libclash-arm64.tar.gz
mv build/*.dylib libclash-arm64.dylib
popd
mkdir -p $PROJECT_DIR/macos/Frameworks
cp build/libclash-amd64.dylib $PROJECT_DIR/macos/Frameworks/amd64-lib
cp build/libclash-arm64.dylib $PROJECT_DIR/macos/Frameworks/arm64-lib
cd $PROJECT_DIR/macos/Frameworks
lipo -create -output libclash.dylib amd64-lib arm64-lib
cd $PROJECT_DIR
flutter build macos
cd build/macos/Build/Products/Release
cat>appdmg.json<<EOF
{
"title": "Clash for Flutter",
"icon": "clash_for_flutter.app/Contents/Resources/AppIcon.icns",
"contents": [
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
{ "x": 192, "y": 344, "type": "file", "path": "clash_for_flutter.app" }
]
}
EOF
mkdir dist
appdmg appdmg.json dist/clash_for_flutter-$VERSION-macos.dmg
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: build/macos/Build/Products/Release/dist/*.dmg
overwrite: true
build-android:
runs-on: ubuntu-latest
needs: [ get-release ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: "liberica"
java-version: "17"
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
- name: Mkdir core
run: mkdir core
- name: Build
env:
VERSION: ${{ needs.get-release.outputs.tag_name }}
run: |
pushd core
curl -L https://github.com/mapleafgo/cff-core/releases/download/$CORE_VERSION/libclash-$CORE_VERSION-android-arm64.tar.gz -o libclash.tar.gz
tar -zxf libclash.tar.gz
mv build/*.aar libclash.aar
popd
mkdir -p android/app/libs
mv core/libclash.aar android/app/libs/libclash.aar
flutter build apk --release --target-platform android-arm64
cd build/app/outputs/flutter-apk
mv app-release.apk clash_for_flutter-$VERSION-arm64.apk
- name: Upload
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.get-release.outputs.upload_url }}
asset_path: build/app/outputs/flutter-apk/*.apk
overwrite: true