66 - master
77 pull_request :
88 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
926
1027concurrency :
1128 group : ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
1229 cancel-in-progress : true
1330
31+ permissions :
32+ contents : write # for creating release
33+
1434env :
1535 ubuntu_image : " ubuntu:22.04"
1636 VCPKG_BINARY_SOURCES : " clear;x-gha,readwrite"
1737
1838jobs :
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+
1980 ubuntu-22 :
81+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
82+ github.event.inputs.run_type == 'full-ci' }}
2083 runs-on : ubuntu-22.04
2184
2285 strategy :
43106 cmake --build build --config Release -j $(nproc)'
44107
45108 ubuntu-22-arm64 :
109+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
110+ github.event.inputs.run_type == 'full-ci' }}
46111 runs-on : ubuntu-22.04
47112
48113 strategy :
69134 cmake --build build --config Release -j $(nproc)'
70135
71136 ubuntu-22-arm-v7 :
137+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
138+ github.event.inputs.run_type == 'full-ci' }}
72139 runs-on : ubuntu-22.04
73140
74141 strategy :
95162 cmake --build build --config Release -j $(nproc)'
96163
97164 macOS-latest :
165+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
166+ github.event.inputs.run_type == 'full-ci' }}
98167 runs-on : macOS-latest
99168
100169 strategy :
@@ -129,11 +198,6 @@ jobs:
129198 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
130199 cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
131200
132- - name : xcodebuild for swift package
133- id : xcodebuild
134- run : |
135- ./build-xcframework.sh
136-
137201
138202# freeBSD-latest:
139203# runs-on: macos-12
@@ -154,6 +218,8 @@ jobs:
154218# cmake --build build --config Release
155219
156220 ubuntu-22-gcc :
221+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
222+ github.event.inputs.run_type == 'full-ci' }}
157223 runs-on : ubuntu-22.04
158224
159225 strategy :
@@ -182,6 +248,8 @@ jobs:
182248 ctest -L gh --output-on-failure'
183249
184250 ubuntu-22-gcc-arm64 :
251+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
252+ github.event.inputs.run_type == 'full-ci' }}
185253 runs-on : ubuntu-22.04
186254
187255 strategy :
@@ -210,6 +278,8 @@ jobs:
210278 ctest -L gh --output-on-failure'
211279
212280 ubuntu-22-gcc-arm-v7 :
281+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
282+ github.event.inputs.run_type == 'full-ci' }}
213283 runs-on : ubuntu-22.04
214284
215285 strategy :
@@ -238,6 +308,8 @@ jobs:
238308 ctest -L gh --output-on-failure'
239309
240310 ubuntu-22-clang :
311+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
312+ github.event.inputs.run_type == 'full-ci' }}
241313 runs-on : ubuntu-22.04
242314
243315 strategy :
@@ -269,6 +341,8 @@ jobs:
269341 ctest -L gh --output-on-failure'
270342
271343 ubuntu-22-gcc-sanitized :
344+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
345+ github.event.inputs.run_type == 'full-ci' }}
272346 runs-on : ubuntu-22.04
273347
274348 strategy :
@@ -297,6 +371,8 @@ jobs:
297371 ctest -L gh --output-on-failure'
298372
299373 ubuntu-22-cmake-sycl :
374+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
375+ github.event.inputs.run_type == 'full-ci' }}
300376 runs-on : ubuntu-22.04
301377
302378 strategy :
@@ -347,6 +423,8 @@ jobs:
347423 cmake --build . --config Release -j $(nproc)
348424
349425 ubuntu-22-cmake-sycl-fp16 :
426+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
427+ github.event.inputs.run_type == 'full-ci' }}
350428 runs-on : ubuntu-22.04
351429
352430 strategy :
@@ -397,6 +475,8 @@ jobs:
397475 cmake --build . --config Release -j $(nproc)
398476
399477 windows-msys2 :
478+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
479+ github.event.inputs.run_type == 'full-ci' }}
400480 runs-on : windows-latest
401481
402482 strategy :
@@ -441,6 +521,8 @@ jobs:
441521 cmake --build build --config ${{ matrix.build }} -j $(nproc)
442522
443523 windows :
524+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
525+ github.event.inputs.run_type == 'full-ci' }}
444526 runs-on : windows-latest
445527
446528 strategy :
@@ -501,6 +583,8 @@ jobs:
501583 path : build/bin/${{ matrix.build }}
502584
503585 windows-blas :
586+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
587+ github.event.inputs.run_type == 'full-ci' }}
504588 runs-on : windows-latest
505589
506590 strategy :
@@ -574,6 +658,8 @@ jobs:
574658 path : build/bin/${{ matrix.build }}
575659
576660 windows-cublas :
661+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
662+ github.event.inputs.run_type == 'full-ci' }}
577663 runs-on : windows-2019
578664 strategy :
579665 matrix :
@@ -642,6 +728,8 @@ jobs:
642728 path : build/bin/${{ matrix.build }}
643729
644730 emscripten :
731+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
732+ github.event.inputs.run_type == 'full-ci' }}
645733 runs-on : ubuntu-22.04
646734
647735 strategy :
@@ -665,6 +753,7 @@ jobs:
665753
666754 ios-xcode-build :
667755 runs-on : macos-latest
756+ needs : determine-tag
668757
669758 strategy :
670759 matrix :
@@ -707,7 +796,26 @@ jobs:
707796 - name : Build swiftui example
708797 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
709798
799+ - name : Pack artifacts
800+ id : pack_artifacts
801+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
802+ github.event.inputs.create_release == 'true' ||
803+ github.event.inputs.pre_release_tag != '' }}
804+ run : |
805+ zip --symlinks -r whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip build-apple/whisper.xcframework
806+
807+ - name : Upload artifacts
808+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
809+ github.event.inputs.create_release == 'true' ||
810+ github.event.inputs.pre_release_tag != '' }}
811+ uses : actions/upload-artifact@v4
812+ with :
813+ path : whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip
814+ name : whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework
815+
710816 android :
817+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
818+ github.event.inputs.run_type == 'full-ci' }}
711819 runs-on : ubuntu-22.04
712820
713821 steps :
@@ -807,6 +915,8 @@ jobs:
807915# PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
808916
809917 quantize :
918+ if : ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
919+ github.event.inputs.run_type == 'full-ci' }}
810920 runs-on : ubuntu-22.04
811921
812922 steps :
@@ -819,3 +929,69 @@ jobs:
819929 cmake -B build
820930 cmake --build build --config Release
821931 ./build/bin/quantize models/ggml-tiny.en.bin models/ggml-tiny.en-q4_0.bin q4_0
932+
933+ release :
934+ if : ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
935+ github.event.inputs.create_release == 'true' ||
936+ github.event.inputs.pre_release_tag != '' }}
937+
938+ runs-on : ubuntu-latest
939+
940+ needs :
941+ - determine-tag
942+ - ios-xcode-build
943+
944+ steps :
945+ - name : Clone
946+ id : checkout
947+ uses : actions/checkout@v4
948+ with :
949+ fetch-depth : 0
950+
951+ - name : ccache
952+ uses :
hendrikmuhs/[email protected] 953+ with :
954+ key : release
955+ evict-old-files : 1d
956+
957+ # Downloads all the artifacts from the previous jobs
958+ - name : Download artifacts
959+ id : download-artifact
960+ uses : actions/download-artifact@v4
961+ with :
962+ path : ./artifact
963+
964+ - name : Move artifacts
965+ id : move_artifacts
966+ run : mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
967+
968+ - name : Create release
969+ id : create_release
970+ uses : ggml-org/action-create-release@v1
971+ env :
972+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
973+ with :
974+ tag_name : ${{ needs.determine-tag.outputs.tag_name }}
975+ prerelease : ${{ github.event.inputs.pre_release_tag != '' }}
976+
977+ - name : Upload release
978+ id : upload_release
979+ uses : actions/github-script@v3
980+ with :
981+ github-token : ${{secrets.GITHUB_TOKEN}}
982+ script : |
983+ const path = require('path');
984+ const fs = require('fs');
985+ const release_id = '${{ steps.create_release.outputs.id }}';
986+ for (let file of await fs.readdirSync('./artifact/release')) {
987+ if (path.extname(file) === '.zip') {
988+ console.log('uploadReleaseAsset', file);
989+ await github.repos.uploadReleaseAsset({
990+ owner: context.repo.owner,
991+ repo: context.repo.repo,
992+ release_id: release_id,
993+ name: file,
994+ data: await fs.readFileSync(`./artifact/release/${file}`)
995+ });
996+ }
997+ }
0 commit comments