danbev commited on
Commit
7272681
·
unverified ·
1 Parent(s): 5fe3033

ci : add should_release variable (#3288)

Browse files

* 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

Files changed (1) hide show
  1. .github/workflows/build.yml +22 -18
.github/workflows/build.yml CHANGED
@@ -43,6 +43,7 @@ jobs:
43
  runs-on: ubuntu-latest
44
  outputs:
45
  tag_name: ${{ steps.tag.outputs.name }}
 
46
 
47
  steps:
48
  - name: Checkout with full history
@@ -57,6 +58,7 @@ jobs:
57
  BUILD_NUMBER=$(git rev-list --count HEAD)
58
  SHORT_HASH=$(git rev-parse --short=7 HEAD)
59
  CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
 
60
 
61
  echo "Raw values:"
62
  echo "BUILD_NUMBER: $BUILD_NUMBER"
@@ -67,21 +69,31 @@ jobs:
67
  if [[ "${{ github.ref_type }}" == "tag" ]]; then
68
  echo "Using pushed tag name"
69
  TAG_NAME="${{ github.ref_name }}"
70
- # Use custom tag if provided
71
  elif [[ -n "$CUSTOM_TAG" ]]; then
72
  echo "Using custom tag"
73
  TAG_NAME="${CUSTOM_TAG}"
 
 
 
 
 
74
  elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
75
  echo "Using master branch format"
76
  TAG_NAME="b${BUILD_NUMBER}"
 
77
  else
78
  echo "Using non-master branch format"
79
  SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
80
  TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}"
 
81
  fi
82
 
83
  echo "Final tag name: $TAG_NAME"
 
84
  echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
 
 
85
 
86
  ubuntu-22:
87
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
@@ -584,6 +596,7 @@ jobs:
584
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
585
  github.event.inputs.run_type == 'full-ci' }}
586
  runs-on: windows-latest
 
587
 
588
  strategy:
589
  matrix:
@@ -667,9 +680,7 @@ jobs:
667
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-bin-${{ matrix.arch }}.zip"
668
 
669
  - 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 != '' }}
673
  uses: actions/upload-artifact@v4
674
  with:
675
  name: whisper-bin-${{ matrix.arch }}.zip
@@ -755,9 +766,7 @@ jobs:
755
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-blas-bin-${{ matrix.arch }}.zip"
756
 
757
  - 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 != '' }}
761
  uses: actions/upload-artifact@v4
762
  with:
763
  name: whisper-blas-bin-${{ matrix.arch }}.zip
@@ -767,6 +776,7 @@ jobs:
767
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
768
  github.event.inputs.run_type == 'full-ci' }}
769
  runs-on: windows-2022
 
770
  strategy:
771
  fail-fast: false
772
  matrix:
@@ -965,9 +975,7 @@ jobs:
965
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip"
966
 
967
  - 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 != '' }}
971
  uses: actions/upload-artifact@v4
972
  with:
973
  name: whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip
@@ -1044,16 +1052,11 @@ jobs:
1044
 
1045
  - name: Pack artifacts
1046
  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 != '' }}
1050
  run: |
1051
  zip --symlinks -r whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip build-apple/whisper.xcframework
1052
 
1053
  - 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 != '' }}
1057
  uses: actions/upload-artifact@v4
1058
  with:
1059
  path: whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip
@@ -1233,7 +1236,6 @@ jobs:
1233
  release:
1234
  if: ${{ github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || startsWith(github.ref, 'refs/tags/v') }}
1235
 
1236
-
1237
  runs-on: ubuntu-latest
1238
 
1239
  needs:
@@ -1275,6 +1277,7 @@ jobs:
1275
  with:
1276
  tag_name: ${{ needs.determine-tag.outputs.tag_name }}
1277
  prerelease: ${{ github.event.inputs.pre_release_tag != '' }}
 
1278
 
1279
  - name: Upload release
1280
  id: upload_release
@@ -1301,7 +1304,8 @@ jobs:
1301
  coreml-base-en:
1302
  if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
1303
  github.event.inputs.create_release == 'true' ||
1304
- github.event.inputs.pre_release_tag != '' }}
 
1305
  runs-on: macos-latest
1306
  needs: determine-tag
1307
 
 
43
  runs-on: ubuntu-latest
44
  outputs:
45
  tag_name: ${{ steps.tag.outputs.name }}
46
+ should_release: ${{ steps.tag.outputs.should_release }}
47
 
48
  steps:
49
  - name: Checkout with full history
 
58
  BUILD_NUMBER=$(git rev-list --count HEAD)
59
  SHORT_HASH=$(git rev-parse --short=7 HEAD)
60
  CUSTOM_TAG="${{ github.event.inputs.pre_release_tag }}"
61
+ SHOULD_RELEASE="false"
62
 
63
  echo "Raw values:"
64
  echo "BUILD_NUMBER: $BUILD_NUMBER"
 
69
  if [[ "${{ github.ref_type }}" == "tag" ]]; then
70
  echo "Using pushed tag name"
71
  TAG_NAME="${{ github.ref_name }}"
72
+ SHOULD_RELEASE="true"
73
  elif [[ -n "$CUSTOM_TAG" ]]; then
74
  echo "Using custom tag"
75
  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}"
81
  elif [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
82
  echo "Using master branch format"
83
  TAG_NAME="b${BUILD_NUMBER}"
84
+ SHOULD_RELEASE="false"
85
  else
86
  echo "Using non-master branch format"
87
  SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
88
  TAG_NAME="${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}"
89
+ SHOULD_RELEASE="false"
90
  fi
91
 
92
  echo "Final tag name: $TAG_NAME"
93
+ echo "Should release: $SHOULD_RELEASE"
94
  echo "name=$TAG_NAME" >> $GITHUB_OUTPUT
95
+ echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
96
+
97
 
98
  ubuntu-22:
99
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
 
596
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
597
  github.event.inputs.run_type == 'full-ci' }}
598
  runs-on: windows-latest
599
+ needs: determine-tag
600
 
601
  strategy:
602
  matrix:
 
680
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-bin-${{ matrix.arch }}.zip"
681
 
682
  - name: Upload binaries
683
+ if: matrix.sdl2 == 'ON' && ${{ needs.determine-tag.outputs.should_release }}
 
 
684
  uses: actions/upload-artifact@v4
685
  with:
686
  name: whisper-bin-${{ matrix.arch }}.zip
 
766
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-blas-bin-${{ matrix.arch }}.zip"
767
 
768
  - name: Upload binaries
769
+ if: matrix.blas == 'ON' && matrix.sdl2 == 'ON' && ${{ needs.determine-tag.outputs.should_release }}
 
 
770
  uses: actions/upload-artifact@v4
771
  with:
772
  name: whisper-blas-bin-${{ matrix.arch }}.zip
 
776
  if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' ||
777
  github.event.inputs.run_type == 'full-ci' }}
778
  runs-on: windows-2022
779
+ needs: determine-tag
780
  strategy:
781
  fail-fast: false
782
  matrix:
 
975
  Compress-Archive -Path "build/bin/${{ matrix.build }}" -DestinationPath "whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip"
976
 
977
  - name: Upload binaries
978
+ if: ${{ needs.determine-tag.outputs.should_release }}
 
 
979
  uses: actions/upload-artifact@v4
980
  with:
981
  name: whisper-cublas-${{ matrix.cuda-toolkit }}-bin-${{ matrix.arch }}.zip
 
1052
 
1053
  - name: Pack artifacts
1054
  id: pack_artifacts
 
 
 
1055
  run: |
1056
  zip --symlinks -r whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip build-apple/whisper.xcframework
1057
 
1058
  - name: Upload artifacts
1059
+ if: ${{ needs.determine-tag.outputs.should_release }}
 
 
1060
  uses: actions/upload-artifact@v4
1061
  with:
1062
  path: whisper-${{ needs.determine-tag.outputs.tag_name }}-xcframework.zip
 
1236
  release:
1237
  if: ${{ github.event.inputs.create_release == 'true' || github.event.inputs.pre_release_tag != '' || startsWith(github.ref, 'refs/tags/v') }}
1238
 
 
1239
  runs-on: ubuntu-latest
1240
 
1241
  needs:
 
1277
  with:
1278
  tag_name: ${{ needs.determine-tag.outputs.tag_name }}
1279
  prerelease: ${{ github.event.inputs.pre_release_tag != '' }}
1280
+ draft: true
1281
 
1282
  - name: Upload release
1283
  id: upload_release
 
1304
  coreml-base-en:
1305
  if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
1306
  github.event.inputs.create_release == 'true' ||
1307
+ github.event.inputs.pre_release_tag != '' ||
1308
+ startsWith(github.ref, 'refs/tags/v') }}
1309
  runs-on: macos-latest
1310
  needs: determine-tag
1311