@@ -23,56 +23,38 @@ jobs:
2323 name : Create Release
2424 runs-on : ubuntu-latest
2525 outputs :
26- upload_url : ${{ steps.finalize.outputs.upload_url }}
27- release_exists : ${{ steps.release_info.outputs.exists }}
26+ tag_name : ${{ steps.release_info.outputs.tag_name }}
2827 steps :
2928 - name : Check if release exists
3029 id : release_info
3130 env :
32- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3332 TAG_NAME : ${{ github.event.inputs.tag || github.ref_name }}
3433 shell : bash
3534 run : |
36- api_url="https://api.github.com/repos/${{ github.repository }}/releases/tags/${TAG_NAME}"
37- response_path="${RUNNER_TEMP}/release_info.json"
38- status_code=$(curl -sS -o "${response_path}" -w "%{http_code}" \
39- -H "Authorization: Bearer ${GITHUB_TOKEN}" \
40- -H "Accept: application/vnd.github+json" \
41- "${api_url}")
42- if [[ "${status_code}" == "200" ]]; then
43- upload_url=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1], "r", encoding="utf-8")).get("upload_url", ""))' \
44- "${response_path}")
35+ echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
36+ if gh release view "${TAG_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
4537 echo "exists=true" >> "$GITHUB_OUTPUT"
46- echo "upload_url=${upload_url}" >> "$GITHUB_OUTPUT"
4738 else
4839 echo "exists=false" >> "$GITHUB_OUTPUT"
4940 fi
5041
5142 - name : Create Release
52- id : create_release
5343 if : steps.release_info.outputs.exists != 'true'
54- uses : actions/create-release@v1
5544 env :
56- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57- with :
58- tag_name : ${{ github.event.inputs.tag || github.ref_name }}
59- release_name : Release ${{ github.event.inputs.tag || github.ref_name }}
60- draft : false
61- prerelease : false
62-
63- - name : Finalize release metadata
64- id : finalize
45+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46+ TAG_NAME : ${{ steps.release_info.outputs.tag_name }}
47+ shell : bash
6548 run : |
66- upload_url= "${{ steps.create_release.outputs.upload_url }}"
67- if [ "${{ steps.release_info.outputs.exists }}" = "true" ]; then
68- upload_url= "${{ steps.release_info.outputs.upload_url }}"
69- fi
70- echo "upload_url=${upload_url}" >> "$GITHUB_OUTPUT "
49+ gh release create "${TAG_NAME}" \
50+ --repo "${GITHUB_REPOSITORY}" \
51+ --target "${GITHUB_SHA}" \
52+ --title "Release ${TAG_NAME}" \
53+ --notes " "
7154
7255 build-release :
7356 name : Build Release Binaries
7457 needs : create-release
75- if : needs.create-release.outputs.release_exists != 'true'
7658 runs-on : ${{ matrix.os }}
7759 strategy :
7860 matrix :
@@ -101,10 +83,13 @@ jobs:
10183 steps :
10284 - name : Checkout code
10385 uses : actions/checkout@v4
86+ with :
87+ ref : ${{ needs.create-release.outputs.tag_name }}
10488
10589 - name : Install Rust toolchain
106- uses : dtolnay/rust-toolchain@stable
90+ uses : dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
10791 with :
92+ toolchain : stable
10893 targets : ${{ matrix.target }}
10994
11095 - name : Build release binary
@@ -139,30 +124,38 @@ jobs:
139124 $hash = (Get-FileHash -Algorithm SHA256 $artifactPath).Hash.ToLower()
140125 "$hash ${{ matrix.asset_name }}" | Out-File -FilePath $checksumPath -Encoding ascii
141126
127+ - name : Prepare release asset
128+ shell : bash
129+ run : |
130+ cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" \
131+ "target/${{ matrix.target }}/release/${{ matrix.asset_name }}"
132+
142133 - name : Attest release binary
143134 uses : actions/attest-build-provenance@v2
144135 with :
145136 subject-path : ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
146137
147138 - name : Upload Release Asset
148- uses : actions/upload-release-asset@v1
149139 env :
150- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
151- with :
152- upload_url : ${{ needs.create-release.outputs.upload_url }}
153- asset_path : ./target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
154- asset_name : ${{ matrix.asset_name }}
155- asset_content_type : application/octet-stream
140+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141+ TAG_NAME : ${{ needs.create-release.outputs.tag_name }}
142+ shell : bash
143+ run : |
144+ gh release upload "${TAG_NAME}" \
145+ "./target/${{ matrix.target }}/release/${{ matrix.asset_name }}" \
146+ --repo "${GITHUB_REPOSITORY}" \
147+ --clobber
156148
157149 - name : Upload checksum asset
158- uses : actions/upload-release-asset@v1
159150 env :
160- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
161- with :
162- upload_url : ${{ needs.create-release.outputs.upload_url }}
163- asset_path : ./target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256
164- asset_name : ${{ matrix.asset_name }}.sha256
165- asset_content_type : text/plain
151+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
152+ TAG_NAME : ${{ needs.create-release.outputs.tag_name }}
153+ shell : bash
154+ run : |
155+ gh release upload "${TAG_NAME}" \
156+ "./target/${{ matrix.target }}/release/${{ matrix.asset_name }}.sha256" \
157+ --repo "${GITHUB_REPOSITORY}" \
158+ --clobber
166159
167160 # publish-crate:
168161 # name: Publish to crates.io
@@ -173,7 +166,7 @@ jobs:
173166 # uses: actions/checkout@v4
174167
175168 # - name: Install Rust toolchain
176- # uses: dtolnay/rust-toolchain@stable
169+ # uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
177170
178171 # - name: Publish to crates.io
179172 # run: cargo publish --token ${{ secrets.CARGO_TOKEN }}
0 commit comments