Skip to content

Commit 35034c5

Browse files
authored
ci : add should_release variable (ggml-org#3288)
* ci : add should_release variable This commit adds a `should_release` variable to the GitHub Actions workflow to determine if a release should be created based on the tag or branch conditions. The motivation for this that it simplifies the logic for deciding whether to upload artifacts or not, making it easier to maintain if we need to change the conditions in the future. * ci : set release draft to true
1 parent 897b071 commit 35034c5

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
runs-on: ubuntu-latest
4444
outputs:
4545
tag_name: ${{ steps.tag.outputs.name }}
46+
should_release: ${{ steps.tag.outputs.should_release }}
4647

4748
steps:
4849
- name: Checkout with full history
@@ -57,6 +58,7 @@ jobs:
5758
BUILD_NUMBER=$(git rev-list --count HEAD)
5859
SHORT_HASH=$(git rev-parse --short=7 HEAD)
5960
CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
61+
SHOULD_RELEASE="false"
6062
6163
echo "Raw values:"
6264
echo "BUILD_NUMBER: $BUILD_NUMBER"
@@ -67,21 +69,31 @@ jobs:
6769
if [[ "${{ github.ref_type }}" == "tag" ]]; then
6870
echo "Using pushed tag name"
6971
TAG_NAME="${{ github.ref_name }}"
70-
# Use custom tag if provided
72+
SHOULD_RELEASE="true"
7173
elif [[ -n "$CUSTOM_TAG" ]]; then
7274
echo "Using custom tag"
7375
TAG_NAME="${CUSTOM_TAG}"
76+
SHOULD_RELEASE="true"
77+
elif [[ "${{ github.event.inputs.create_release }}" == "true" ]]; then
78+
echo "Manual release requested"
79+
SHOULD_RELEASE="true"
80+
TAG_NAME="b${BUILD_NUMBER}"
7481
elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
7582
echo "Using master branch format"
7683
TAG_NAME="b${BUILD_NUMBER}"
84+
SHOULD_RELEASE="false"
7785
else
7886
echo "Using non-master branch format"
7987
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
8088
TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}"
89+
SHOULD_RELEASE="false"
8190
fi
8291
8392
echo "Final tag name: $TAG_NAME"
93+
echo "Should release: $SHOULD_RELEASE"
8494
echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
95+
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
96+
8597
8698
ubuntu-22:
8799
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
@@ -584,6 +596,7 @@ jobs:
584596
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
585597
github.event.inputs.run_type == 'full-ci' }}
586598
runs-on: windows-latest
599+
needs: determine-tag
587600

588601
strategy:
589602
matrix:
@@ -667,9 +680,7 @@ jobs:
667680
Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-bin-${{ matrix.arch }}.zip"
668681
669682
- name: Upload binaries
670-
if: matrix.sdl2 == 'ON' && ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
671-
github.event.inputs.create_release == 'true' ||
672-
github.event.inputs.pre_release_tag != '' }}
683+
if: matrix.sdl2 == 'ON' && ${{ needs.determine-tag.outputs.should_release }}
673684
uses: actions/upload-artifact@v4
674685
with:
675686
name: whisper-bin-${{ matrix.arch }}.zip
@@ -755,9 +766,7 @@ jobs:
755766
Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-blas-bin-${{ matrix.arch }}.zip"
756767
757768
- name: Upload binaries
758-
if: matrix.blas == 'ON' && matrix.sdl2 == 'ON' && ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
759-
github.event.inputs.create_release == 'true' ||
760-
github.event.inputs.pre_release_tag != '' }}
769+
if: matrix.blas == 'ON' && matrix.sdl2 == 'ON' && ${{ needs.determine-tag.outputs.should_release }}
761770
uses: actions/upload-artifact@v4
762771
with:
763772
name: whisper-blas-bin-${{ matrix.arch }}.zip
@@ -767,6 +776,7 @@ jobs:
767776
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
768777
github.event.inputs.run_type == 'full-ci' }}
769778
runs-on: windows-2022
779+
needs: determine-tag
770780
strategy:
771781
fail-fast: false
772782
matrix:
@@ -965,9 +975,7 @@ jobs:
965975
Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip"
966976
967977
- name: Upload binaries
968-
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
969-
github.event.inputs.create_release == 'true' ||
970-
github.event.inputs.pre_release_tag != '' }}
978+
if: ${{ needs.determine-tag.outputs.should_release }}
971979
uses: actions/upload-artifact@v4
972980
with:
973981
name: whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip
@@ -1044,16 +1052,11 @@ jobs:
10441052

10451053
- name: Pack artifacts
10461054
id: pack_artifacts
1047-
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
1048-
github.event.inputs.create_release == 'true' ||
1049-
github.event.inputs.pre_release_tag != '' }}
10501055
run: |
10511056
zip --symlinks -r whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip build-apple/whisper.xcframework
10521057
10531058
- name: Upload artifacts
1054-
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
1055-
github.event.inputs.create_release == 'true' ||
1056-
github.event.inputs.pre_release_tag != '' }}
1059+
if: ${{ needs.determine-tag.outputs.should_release }}
10571060
uses: actions/upload-artifact@v4
10581061
with:
10591062
path: whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip
@@ -1233,7 +1236,6 @@ jobs:
12331236
release:
12341237
if: ${{ github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || startsWith(github.ref, 'refs/tags/v') }}
12351238

1236-
12371239
runs-on: ubuntu-latest
12381240

12391241
needs:
@@ -1275,6 +1277,7 @@ jobs:
12751277
with:
12761278
tag_name: ${{ needs.determine-tag.outputs.tag_name }}
12771279
prerelease: ${{ github.event.inputs.pre_release_tag != '' }}
1280+
draft: true
12781281

12791282
- name: Upload release
12801283
id: upload_release
@@ -1301,7 +1304,8 @@ jobs:
13011304
coreml-base-en:
13021305
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
13031306
github.event.inputs.create_release == 'true' ||
1304-
github.event.inputs.pre_release_tag != '' }}
1307+
github.event.inputs.pre_release_tag != '' ||
1308+
startsWith(github.ref, 'refs/tags/v') }}
13051309
runs-on: macos-latest
13061310
needs: determine-tag
13071311

0 commit comments

Comments
 (0)