6
6
- master
7
7
pull_request :
8
8
types : [opened, synchronize, reopened]
9
+ workflow_dispatch :
10
+ inputs :
11
+ create_release :
12
+ description : ' Create new release'
13
+ required : true
14
+ type : boolean
15
+ pre_release_tag :
16
+ description : ' Pre-release tag name'
17
+ required : false
18
+ type : string
19
+ run_type :
20
+ description : ' Workflow type to run'
21
+ required : true
22
+ type : choice
23
+ options :
24
+ - full-ci
25
+ - release-only
9
26
10
27
concurrency :
11
28
group : ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
12
29
cancel-in-progress : true
13
30
31
+ permissions :
32
+ contents : write # for creating release
33
+
14
34
env :
15
35
ubuntu_image : " ubuntu:22.04"
16
36
VCPKG_BINARY_SOURCES : " clear;x-gha,readwrite"
17
37
18
38
jobs :
39
+ determine-tag :
40
+ runs-on : ubuntu-latest
41
+ outputs :
42
+ tag_name : ${{ steps.tag.outputs.name }}
43
+
44
+ steps :
45
+ - name : Checkout with full history
46
+ uses : actions/checkout@v4
47
+ with :
48
+ fetch-depth : 0
49
+
50
+ - name : Determine tag name
51
+ id : tag
52
+ shell : bash
53
+ run : |
54
+ BUILD_NUMBER=$(git rev-list --count HEAD)
55
+ SHORT_HASH=$(git rev-parse --short=7 HEAD)
56
+ CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
57
+
58
+ echo "Raw values:"
59
+ echo "BUILD_NUMBER: $BUILD_NUMBER"
60
+ echo "SHORT_HASH: $SHORT_HASH"
61
+ echo "BRANCH_NAME: ${{ env.BRANCH_NAME }}"
62
+ echo "CUSTOM_TAG: $CUSTOM_TAG"
63
+
64
+ # Use custom tag if provided
65
+ if [[ -n "$CUSTOM_TAG" ]]; then
66
+ echo "Using custom tag"
67
+ TAG_NAME="${CUSTOM_TAG}"
68
+ elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
69
+ echo "Using master branch format"
70
+ TAG_NAME="b${BUILD_NUMBER}"
71
+ else
72
+ echo "Using non-master branch format"
73
+ SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
74
+ TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}"
75
+ fi
76
+
77
+ echo "Final tag name: $TAG_NAME"
78
+ echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
79
+
19
80
ubuntu-22 :
81
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
20
82
runs-on : ubuntu-22.04
21
83
22
84
strategy :
43
105
cmake --build build --config Release -j $(nproc)'
44
106
45
107
ubuntu-22-arm64 :
108
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
46
109
runs-on : ubuntu-22.04
47
110
48
111
strategy :
69
132
cmake --build build --config Release -j $(nproc)'
70
133
71
134
ubuntu-22-arm-v7 :
135
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
72
136
runs-on : ubuntu-22.04
73
137
74
138
strategy :
95
159
cmake --build build --config Release -j $(nproc)'
96
160
97
161
macOS-latest :
162
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
98
163
runs-on : macOS-latest
99
164
100
165
strategy :
@@ -129,11 +194,6 @@ jobs:
129
194
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
130
195
cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
131
196
132
- - name : xcodebuild for swift package
133
- id : xcodebuild
134
- run : |
135
- ./build-xcframework.sh
136
-
137
197
138
198
# freeBSD-latest:
139
199
# runs-on: macos-12
@@ -154,6 +214,7 @@ jobs:
154
214
# cmake --build build --config Release
155
215
156
216
ubuntu-22-gcc :
217
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
157
218
runs-on : ubuntu-22.04
158
219
159
220
strategy :
@@ -182,6 +243,7 @@ jobs:
182
243
ctest -L gh --output-on-failure'
183
244
184
245
ubuntu-22-gcc-arm64 :
246
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
185
247
runs-on : ubuntu-22.04
186
248
187
249
strategy :
@@ -210,6 +272,7 @@ jobs:
210
272
ctest -L gh --output-on-failure'
211
273
212
274
ubuntu-22-gcc-arm-v7 :
275
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
213
276
runs-on : ubuntu-22.04
214
277
215
278
strategy :
@@ -238,6 +301,7 @@ jobs:
238
301
ctest -L gh --output-on-failure'
239
302
240
303
ubuntu-22-clang :
304
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
241
305
runs-on : ubuntu-22.04
242
306
243
307
strategy :
@@ -269,6 +333,7 @@ jobs:
269
333
ctest -L gh --output-on-failure'
270
334
271
335
ubuntu-22-gcc-sanitized :
336
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
272
337
runs-on : ubuntu-22.04
273
338
274
339
strategy :
@@ -297,6 +362,7 @@ jobs:
297
362
ctest -L gh --output-on-failure'
298
363
299
364
ubuntu-22-cmake-sycl :
365
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
300
366
runs-on : ubuntu-22.04
301
367
302
368
strategy :
@@ -347,6 +413,7 @@ jobs:
347
413
cmake --build . --config Release -j $(nproc)
348
414
349
415
ubuntu-22-cmake-sycl-fp16 :
416
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
350
417
runs-on : ubuntu-22.04
351
418
352
419
strategy :
@@ -397,6 +464,7 @@ jobs:
397
464
cmake --build . --config Release -j $(nproc)
398
465
399
466
windows-msys2 :
467
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
400
468
runs-on : windows-latest
401
469
402
470
strategy :
@@ -441,6 +509,7 @@ jobs:
441
509
cmake --build build --config ${{ matrix.build }} -j $(nproc)
442
510
443
511
windows :
512
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
444
513
runs-on : windows-latest
445
514
446
515
strategy :
@@ -501,6 +570,7 @@ jobs:
501
570
path : build/bin/${{ matrix.build }}
502
571
503
572
windows-blas :
573
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
504
574
runs-on : windows-latest
505
575
506
576
strategy :
@@ -574,6 +644,7 @@ jobs:
574
644
path : build/bin/${{ matrix.build }}
575
645
576
646
windows-cublas :
647
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
577
648
runs-on : windows-2019
578
649
strategy :
579
650
matrix :
@@ -642,6 +713,7 @@ jobs:
642
713
path : build/bin/${{ matrix.build }}
643
714
644
715
emscripten :
716
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
645
717
runs-on : ubuntu-22.04
646
718
647
719
strategy :
@@ -665,6 +737,7 @@ jobs:
665
737
666
738
ios-xcode-build :
667
739
runs-on : macos-latest
740
+ needs : determine-tag
668
741
669
742
strategy :
670
743
matrix :
@@ -707,7 +780,25 @@ jobs:
707
780
- name : Build swiftui example
708
781
run : xcodebuild -project examples/whisper.swiftui/whisper.swiftui.xcodeproj -scheme WhisperCppDemo -configuration ${{ matrix.build }} -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
709
782
783
+ - name : Pack artifacts
784
+ id : pack_artifacts
785
+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
786
+ github.event.inputs.create_release == 'true' ||
787
+ github.event.inputs.pre_release_tag != '' }}
788
+ run : |
789
+ zip --symlinks -r whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip build-apple/whisper.xcframework
790
+
791
+ - name : Upload artifacts
792
+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
793
+ github.event.inputs.create_release == 'true' ||
794
+ github.event.inputs.pre_release_tag != '' }}
795
+ uses : actions/upload-artifact@v4
796
+ with :
797
+ path : whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip
798
+ name : whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework
799
+
710
800
android :
801
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
711
802
runs-on : ubuntu-22.04
712
803
713
804
steps :
@@ -807,6 +898,7 @@ jobs:
807
898
# PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
808
899
809
900
quantize :
901
+ if : ${{ github.event_name == 'push' || github.event.inputs.run_type == 'full-ci' }}
810
902
runs-on : ubuntu-22.04
811
903
812
904
steps :
@@ -819,3 +911,69 @@ jobs:
819
911
cmake -B build
820
912
cmake --build build --config Release
821
913
./build/bin/quantize models/ggml-tiny.en.bin models/ggml-tiny.en-q4_0.bin q4_0
914
+
915
+ release :
916
+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
917
+ github.event.inputs.create_release == 'true' ||
918
+ github.event.inputs.pre_release_tag != '' }}
919
+
920
+ runs-on : ubuntu-latest
921
+
922
+ needs :
923
+ - determine-tag
924
+ - ios-xcode-build
925
+
926
+ steps :
927
+ - name : Clone
928
+ id : checkout
929
+ uses : actions/checkout@v4
930
+ with :
931
+ fetch-depth : 0
932
+
933
+ - name : ccache
934
+ uses :
hendrikmuhs/[email protected]
935
+ with :
936
+ key : release
937
+ evict-old-files : 1d
938
+
939
+ # Downloads all the artifacts from the previous jobs
940
+ - name : Download artifacts
941
+ id : download-artifact
942
+ uses : actions/download-artifact@v4
943
+ with :
944
+ path : ./artifact
945
+
946
+ - name : Move artifacts
947
+ id : move_artifacts
948
+ run : mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
949
+
950
+ - name : Create release
951
+ id : create_release
952
+ uses : ggml-org/action-create-release@v1
953
+ env :
954
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
955
+ with :
956
+ tag_name : ${{ needs.determine-tag.outputs.tag_name }}
957
+ prerelease : ${{ github.event.inputs.pre_release_tag != '' }}
958
+
959
+ - name : Upload release
960
+ id : upload_release
961
+ uses : actions/github-script@v3
962
+ with :
963
+ github-token : ${{secrets.GITHUB_TOKEN}}
964
+ script : |
965
+ const path = require('path');
966
+ const fs = require('fs');
967
+ const release_id = '${{ steps.create_release.outputs.id }}';
968
+ for (let file of await fs.readdirSync('./artifact/release')) {
969
+ if (path.extname(file) === '.zip') {
970
+ console.log('uploadReleaseAsset', file);
971
+ await github.repos.uploadReleaseAsset({
972
+ owner: context.repo.owner,
973
+ repo: context.repo.repo,
974
+ release_id: release_id,
975
+ name: file,
976
+ data: await fs.readFileSync(`./artifact/release/${file}`)
977
+ });
978
+ }
979
+ }
0 commit comments