|
11 | 11 | onnxruntime_branch: |
12 | 12 | type: string |
13 | 13 | default: "main" |
| 14 | + promote_to_stable: |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + description: 'Promote this build to stable release' |
14 | 18 | push: |
15 | 19 | branches: |
16 | 20 | - main |
@@ -117,3 +121,71 @@ jobs: |
117 | 121 | name: Release ${{ steps.get_tag.outputs.next_tag }} |
118 | 122 | files: | |
119 | 123 | artifacts/*.whl |
| 124 | +
|
| 125 | + promote_to_stable: |
| 126 | + permissions: |
| 127 | + contents: write |
| 128 | + if: inputs.promote_to_stable == true |
| 129 | + needs: [build_and_upload_wheel_mac, build_and_upload_wheel_linux] |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - name: Checkout repository |
| 133 | + uses: actions/checkout@v4 |
| 134 | + with: |
| 135 | + fetch-depth: 0 |
| 136 | + ref: ${{ inputs.onnxruntime_branch || github.ref }} |
| 137 | + |
| 138 | + - name: Download all wheel artifacts |
| 139 | + uses: actions/download-artifact@v4 |
| 140 | + with: |
| 141 | + path: artifacts/ |
| 142 | + |
| 143 | + - name: Get current commit info |
| 144 | + id: commit_info |
| 145 | + run: | |
| 146 | + commit_sha=${{ github.sha }} |
| 147 | + echo "commit_sha=$commit_sha" >> $GITHUB_OUTPUT |
| 148 | + short_sha=$(git rev-parse --short $commit_sha) |
| 149 | + echo "short_sha=$short_sha" >> $GITHUB_OUTPUT |
| 150 | + commit_message=$(git log -1 --pretty=format:"%s" $commit_sha) |
| 151 | + echo "commit_message=$commit_message" >> $GITHUB_OUTPUT |
| 152 | +
|
| 153 | + - name: Delete existing stable release |
| 154 | + env: |
| 155 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + run: | |
| 157 | + # Delete tag locally and remotely |
| 158 | + git tag -d stable 2>/dev/null || true |
| 159 | + git push origin :refs/tags/stable 2>/dev/null || true |
| 160 | +
|
| 161 | + # Delete existing release |
| 162 | + release_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 163 | + "https://api.github.com/repos/${{ github.repository }}/releases/tags/stable" \ |
| 164 | + | jq -r '.id // empty') |
| 165 | +
|
| 166 | + if [ ! -z "$release_id" ] && [ "$release_id" != "null" ]; then |
| 167 | + curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 168 | + "https://api.github.com/repos/${{ github.repository }}/releases/$release_id" |
| 169 | + fi |
| 170 | +
|
| 171 | + - name: Create stable tag and release |
| 172 | + run: | |
| 173 | + commit_sha=${{ steps.commit_info.outputs.commit_sha }} |
| 174 | + git tag stable $commit_sha |
| 175 | + git push origin stable |
| 176 | +
|
| 177 | + - name: Create Stable Release |
| 178 | + uses: softprops/action-gh-release@v1 |
| 179 | + env: |
| 180 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 181 | + with: |
| 182 | + tag_name: stable |
| 183 | + name: "Stable Release" |
| 184 | + body: | |
| 185 | + This is the latest stable release of onnxruntime. |
| 186 | +
|
| 187 | + **Promoted from:** ${{ steps.commit_info.outputs.short_sha }} |
| 188 | + **Commit:** ${{ steps.commit_info.outputs.commit_message }} |
| 189 | + **Build:** [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 190 | + files: | |
| 191 | + artifacts/**/*.whl |
0 commit comments