|
| 1 | +name: "CI: Release" |
| 2 | + |
| 3 | +description: Manually-triggered release workflow. Must have a release note in the draft state and the release commit tagged. |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + component: |
| 9 | + description: "Component to release" |
| 10 | + required: true |
| 11 | + type: choice |
| 12 | + options: |
| 13 | + - cuda-core |
| 14 | + - cuda-bindings |
| 15 | + - cuda-python |
| 16 | + - all |
| 17 | + git-tag: |
| 18 | + description: "The release git tag" |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + run-id: |
| 22 | + description: "The GHA run ID that generated validated artifacts" |
| 23 | + required: true |
| 24 | + type: string |
| 25 | + build-ctk-ver: |
| 26 | + type: string |
| 27 | + required: true |
| 28 | + wheel-dst: |
| 29 | + description: "Which wheel index to publish to?" |
| 30 | + required: true |
| 31 | + type: choice |
| 32 | + options: |
| 33 | + - testpypi |
| 34 | + - pypi |
| 35 | + |
| 36 | +defaults: |
| 37 | + run: |
| 38 | + shell: bash --noprofile --norc -xeuo pipefail {0} |
| 39 | + |
| 40 | +jobs: |
| 41 | + check-tag: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Check if draft exists for the tag |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + run: | |
| 48 | + tags= |
| 49 | + for i in $(gh release list -R ${{ github.repository }} --json tagName --jq '.[]| .tagName'); do |
| 50 | + tags+=( $i ) |
| 51 | + done |
| 52 | + is_draft= |
| 53 | + for i in $(gh release list -R ${{ github.repository }} --json isDraft --jq '.[]| .isDraft'); do |
| 54 | + is_draft+=( $i ) |
| 55 | + done |
| 56 | +
|
| 57 | + found=0 |
| 58 | + for idx in ${!tags[@]}; do |
| 59 | + if [[ "${tags[$idx]}" == "${{ inputs.git-tag }}" ]]; then |
| 60 | + echo "found ${{ inputs.git-tag }}" |
| 61 | + found=1 |
| 62 | + if [[ "${is_draft[$idx]}" != "true" ]]; then |
| 63 | + echo "the release note is not in draft state" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + break |
| 67 | + fi |
| 68 | + done |
| 69 | + if [[ "$found" == 0 ]]; then |
| 70 | + echo "the release is not yet tagged" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +
|
| 74 | + upload-archive: |
| 75 | + name: Upload source archive |
| 76 | + permissions: |
| 77 | + contents: write |
| 78 | + needs: |
| 79 | + - check-tag |
| 80 | + secrets: inherit |
| 81 | + uses: |
| 82 | + ./.github/workflows/release-upload.yml |
| 83 | + with: |
| 84 | + git-tag: ${{ inputs.git-tag }} |
| 85 | + |
| 86 | + publish-wheels: |
| 87 | + name: Publish wheels |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: |
| 90 | + - check-tag |
| 91 | + environment: |
| 92 | + name: ${{ inputs.wheel-dst }} |
| 93 | + url: https://${{ (inputs.wheel-dst == 'testpypi' && 'test.') || '' }}pypi.org/p/${{ inputs.component }}/ |
| 94 | + permissions: |
| 95 | + id-token: write |
| 96 | + steps: |
| 97 | + - name: Download component wheels |
| 98 | + env: |
| 99 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + run: | |
| 101 | + gh run download ${{ inputs.run-id }} -p "${{ inputs.component }}*" -R ${{ github.repository }} |
| 102 | + mkdir dist |
| 103 | + for p in ${{ inputs.component }}* |
| 104 | + do |
| 105 | + mv ${p}/*.whl dist/ |
| 106 | + done |
| 107 | + rmdir ${{ inputs.component }}* |
| 108 | +
|
| 109 | + - name: Publish package distributions to PyPI |
| 110 | + if: ${{ inputs.wheel-dst == 'pypi' }} |
| 111 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 112 | + |
| 113 | + - name: Publish package distributions to TestPyPI |
| 114 | + if: ${{ inputs.wheel-dst == 'testpypi' }} |
| 115 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 116 | + with: |
| 117 | + repository-url: https://test.pypi.org/legacy/ |
| 118 | + |
| 119 | + # TODO: add another job to make the release leave the draft state? |
0 commit comments