-
Notifications
You must be signed in to change notification settings - Fork 1.6k
428 lines (368 loc) · 15.3 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
name: Build
on:
workflow_call:
inputs:
upload-artifact:
type: boolean
default: true
tag-name:
type: string
default: "draft"
channel:
type: string
default: "dev"
env:
IS_GITHUB_ACTIONS: 1
CHANNEL: "${{ inputs.channel }}"
FLUTTER_VERSION: '3.24.0'
NDK_VERSION: r26d
UPLOAD_ARTIFACT: "${{ inputs.upload-artifact }}"
TAG_NAME: "${{ inputs.tag-name }}"
TARGET_NAME_AppImage: "Hiddify-Linux-x64"
TARGET_NAME_deb: "Hiddify-Debian-x64"
TARGET_NAME_rpm: "Hiddify-rpm-x64"
TARGET_NAME_apk: "Hiddify-Android"
TARGET_NAME_aab: "Hiddify-Android"
#TARGET_NAME_exe: "Hiddify-Windows-x64"
TARGET_NAME_dmg: "Hiddify-MacOS"
TARGET_NAME_pkg: "Hiddify-MacOS-Installer"
TARGET_NAME_ipa: "Hiddify-iOS"
jobs:
test:
outputs:
draftBuildCode: ${{ steps.draftBuildCode.outputs.datetime }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/[email protected] #issue with 2.13
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
- name: Prepare
run: make linux-prepare
- name: Test
run: flutter test
- name: make draftBuildCode
id: draftBuildCode
run: echo "::set-output name=datetime::$(date +'%d.%H.%M')"
build:
needs: test
permissions: write-all
strategy:
fail-fast: false
matrix:
include:
- platform: android-apk
os: ubuntu-latest
targets: apk
- platform: android-aab
os: ubuntu-latest
targets: aab
- platform: windows
os: windows-2019
aarch: amd64
targets: exe,msix
- platform: linux
os: ubuntu-22.04
aarch: amd64
targets: AppImage,deb,rpm
- platform: macos
os: macos-13
aarch: universal
targets: dmg,pkg
# - platform: ios
# os: macos-14
# aarch: universal
# filename: hiddify-ios
# targets: ipa
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Import Apple Codesign Certificates
if: ${{ inputs.upload-artifact && startsWith(matrix.os,'macos') }}
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: "${{ secrets.APPLE_CERTIFICATE_P12 }}"
p12-password: "${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}"
- name: Import Apple Mobile Provisioning Profile
if: ${{ inputs.upload-artifact && startsWith(matrix.os,'macos') }}
run: |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
echo "${{secrets.APPLE_MOBILE_PROVISIONING_PROFILES_TARGZ_BASE64}}"|base64 --decode | tar xz -C ~/Library/MobileDevice/Provisioning\ Profiles
ls ~/Library/MobileDevice/Provisioning\ Profiles
# ls ~/Library/MobileDevice/Provisioning\ Profiles
# echo "${{secrets.NEW_APPLE_MOBILE_PROVISIONING_PROFILES_TARXZ_BASE64}}"|base64 --decode | tar xJ -C ~/Library/MobileDevice/Provisioning\ Profiles
# # echo "${{secrets.NEW_APPLE_MOBILE_PROVISIONING_PROFILES_TARGZ_BASE64_2}}"|base64 --decode | tar xz -C ~/Library/MobileDevice/Provisioning\ Profiles
- name: Setup Flutter
uses: subosito/[email protected] #issue with 2.13
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
# flutter-version-file: pubspec.yaml
channel: 'stable'
cache: true
- name: Setup Java
if: startsWith(matrix.platform,'android')
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Setup NDK
if: startsWith(matrix.platform,'android')
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: ${{ env.NDK_VERSION }}
add-to-path: true
link-to-sdk: true
- name: Setup Gradle 8.1
if: startsWith(matrix.platform,'android')
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 7.5
- name: Setup dependencies
run: |
make ${{ matrix.platform }}-install-dependencies
- name: Setup Android Signing Properties
if: ${{ inputs.upload-artifact && startsWith(matrix.platform,'android') }}
run: |
echo "${{ secrets.ANDROID_SIGNING_KEY }}" | base64 --decode > android/key.jks
echo "storeFile=$(pwd)/android/key.jks" > android/key.properties
echo "storePassword=${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}" >> android/key.properties
- name: Setup Windows Signing Properties
if: ${{ inputs.upload-artifact && startsWith(matrix.platform,'windows') }}
run: |
[IO.File]::WriteAllBytes("windows\sign.pfx", [Convert]::FromBase64String("${{ secrets.WINDOWS_SIGNING_KEY }}"))
(Get-Content "windows\packaging\msix\make_config.yaml") -replace '^certificate_password:.*$', 'certificate_password: ${{ secrets.WINDOWS_SIGNING_PASSWORD }}' | Set-Content "windows\packaging\msix\make_config.yaml"
# - name: Temporary disable Permission Handler for windows due to its issue in permission
# if: ${{ startsWith(matrix.platform,'windows') }}
# run: |
# (Get-Content -Path "pubspec.yaml") -notmatch "permission_handler" | Set-Content -Path "pubspec.yaml"
# (Get-Content -Path "lib\features\profile\add\add_profile_modal.dart") -notmatch "qr_code_scanner_screen" | Set-Content -Path "lib\features\profile\add\add_profile_modal.dart"
# (Get-Content -Path lib\features\profile\add\add_profile_modal.dart) -replace 'await QRCodeScannerScreen\(\).open\(context\);', 'null;' | Set-Content -Path lib\features\profile\add\add_profile_modal.dart
# Remove-Item -Path "lib\features\common\qr_code_scanner_screen.dart"
- name: Prepare for ${{ matrix.platform }}
run: |
make ${{ matrix.platform }}-prepare
tree
- name: Build ${{ matrix.platform }}
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
make ${{ matrix.platform }}-release
- name: Code Sign
if: ${{ inputs.upload-artifact && startsWith(matrix.platform,'windows') }}
uses: hiddify/signtool-code-sign-sha256@main
with:
certificate: '${{ secrets.WINDOWS_SIGNING_KEY }}'
cert-password: '${{ secrets.WINDOWS_SIGNING_PASSWORD }}'
cert-sha1: '${{ secrets.WINDOWS_SIGNING_SHA1 }}'
folder: 'dist'
timestamp-server: 'http://timestamp.digicert.com'
recursive: true
description: 'Hiddify'
- name: Copy to out Windows
if: matrix.platform == 'windows'
run: |
tree
.\scripts\package_windows.ps1
- name: Upload Debug Symbols
if: ${{ inputs.upload-artifact && inputs.tag-name != 'draft' }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_DIST: ${{ matrix.platform == 'android-aab' && 'google-play' || 'general' }}
run: |
dart pub global activate sentry_dart_plugin
dart run sentry_dart_plugin
- name: Copy to out Android APK
if: matrix.platform == 'android-apk'
run: |
mkdir out
ls -R ./build/app/outputs
cp ./build/app/outputs/flutter-apk/*arm64-v8a*.apk out/${TARGET_NAME_apk}-arm64.apk || echo "no arm64 apk"
cp ./build/app/outputs/flutter-apk/*armeabi-v7a*.apk out/${TARGET_NAME_apk}-arm7.apk || echo "no arm7 apk"
cp ./build/app/outputs/flutter-apk/*x86_64*.apk out/${TARGET_NAME_apk}-x86_64.apk || echo "no x64 apk"
cp ./build/app/outputs/flutter-apk/app-release.apk out/${TARGET_NAME_apk}-universal.apk || echo "no universal apk"
- name: Copy to out Android AAB
if: matrix.platform == 'android-aab'
run: |
mkdir out
ls -R ./build/app/outputs
cp ./build/app/outputs/bundle/release/app-release.aab out/hiddify-android-market.aab || echo "no aab"
- name: Copy to out unix
if: startsWith(matrix.platform,'linux') || matrix.platform == 'macos' || matrix.platform == 'ios'
run: |
ls -R dist/
mkdir out
mkdir tmp_out
for EXT in $(echo ${{ matrix.targets }} | tr ',' '\n'); do
KEY=TARGET_NAME_${EXT}
FILENAME=${!KEY}
echo "For $EXT ($KEY) filename is ${FILENAME}"
mv dist/*/*.$EXT tmp_out/${FILENAME}.$EXT
ls tmp_out
chmod +x tmp_out/${FILENAME}.$EXT
if [ "${{matrix.platform}}" == "linux" ];then
cp ./.github/help/linux/* tmp_out/
else
cp ./.github/help/mac-windows/* tmp_out/
fi
if [[ "${{matrix.platform}}" == 'ios' ]];then
echo mv tmp_out/${FILENAME}.$EXT out/
mv tmp_out/${FILENAME}.$EXT out/
else
cd tmp_out
# 7z a ${FILENAME}.zip ./
# mv ${FILENAME}.zip ../out/
# [[ $EXT == 'AppImage' ]]&& mv ${FILENAME}.$EXT ../out/ # added for appimage link
mv ${FILENAME}.$EXT ../out/
cd ..
fi
done
- name: Upload Artifact
if: env.UPLOAD_ARTIFACT == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{matrix.platform}}
path: ./out
retention-days: 1
- name: Clean up keychain and provisioning profile
if: ${{ always() && startsWith(matrix.os,'macos')}}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db ||echo ok
rm ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision ||echo ok
update-draft:
permissions: write-all
if: ${{ inputs.upload-artifact }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
- name: Download Artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: "*"
path: ./out/
- name: Display Files Structure
run: ls -R
working-directory: ./out
- name: Delete Current Release Assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: 'draft'
deleteOnlyFromDrafts: false
- name: prepare_release_message
run: |
pip install gitchangelog pystache mustache markdown
prelease=$(curl --silent "https://api.github.com/repos/hiddify/hiddify-next/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
current="${{ github.ref_name }}"
sed 's|RELEASE_TAG|${{ env.TAG_NAME }}|g' ./.github/release_message.md > release.md
echo -e "\n\n<details markdown=1><summary>All changes from $current to the latest commit:</summary>\n\n">>release.md
gitchangelog "${prelease}.." >> release.md 2>&1 || echo "Error in gitchangelog"
echo -e "\n\n</details>">>release.md
- name: Create or Update Draft Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./out/*
name: 'draft'
tag_name: 'draft'
body_path: './release.md'
prerelease: true
upload-release:
permissions: write-all
if: ${{ inputs.upload-artifact && inputs.tag-name != 'draft' }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: "*"
path: ./out/
- name: Display Files Structure
run: |
ls -R ./out
ls -R ./.github/
ls -R ./.git/
mv out/hiddify-android-market.aab hiddify-android-market.aab
- name: prepare_release_message
run: |
sed 's|RELEASE_TAG|${{ env.TAG_NAME }}|g' ./.github/release_message.md >> release.md
- name: Upload Release
uses: softprops/action-gh-release@v1
if: ${{ success() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# prerelease: ${{ env.CHANNEL == 'dev' }}
prerelease: true
tag_name: ${{ env.TAG_NAME }}
body_path: './release.md'
files: ./out/*
- name: Create service_account.json
run: echo '${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}' > service_account.json
- name: Deploy to Google Play Internal Testers
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: service_account.json
packageName: app.hiddify.com
releaseName: ${{ env.TAG_NAME }}
releaseFiles: ./hiddify-android-market.aab
track: 'beta'
upload-to-testflight:
needs: [build]
if: ${{ inputs.upload-artifact && inputs.tag-name != 'draft' }}
#if: ${{ inputs.upload-artifact }}
runs-on: macOS-latest
timeout-minutes: 30
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: "*ios*"
path: ./out/
- uses: Apple-Actions/import-codesign-certs@v2
with:
p12-file-base64: ${{ secrets.APPLE_UPLOAD_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
- uses: Apple-Actions/download-provisioning-profiles@v1
with:
bundle-id: app.hiddify.com
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}
- uses: Apple-Actions/download-provisioning-profiles@v1
with:
bundle-id: app.hiddify.com.SingBoxPacketTunnel
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}
- name: Import Apple Mobile Provisioning Profile
run: |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
echo "${{secrets.APPLE_DIST_PROVISIONING_PROFILES_TARGZ_BASE64}}"|base64 --decode | tar xz -C ~/Library/MobileDevice/Provisioning\ Profiles
#echo "${{secrets.NEW_APPLE_STORE_PROVISIONING_PROFILES_TARXZ_BASE64}}"|base64 --decode | tar xJ -C ~/Library/MobileDevice/Provisioning\ Profiles
- uses: Apple-Actions/upload-testflight-build@v1
with:
app-path: 'out/Hiddify-iOS.ipa'
issuer-id: ${{ secrets.APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.APPSTORE_API_PRIVATE_KEY }}