|
9 | 9 | - crate_universe/tools/cross_installer/** |
10 | 10 | - version.bzl |
11 | 11 | - .github/workflows/release.yaml |
| 12 | + - .github/workflows/release_prep.sh |
12 | 13 | push: |
13 | 14 | branches: |
14 | 15 | - main |
@@ -121,205 +122,79 @@ jobs: |
121 | 122 | TARGET: "${{ matrix.env.TARGET }}" |
122 | 123 | - uses: actions/upload-artifact@v4 |
123 | 124 | with: |
| 125 | + # The artifact name MUST be the target triple — release_prep.sh |
| 126 | + # locates each binary at ${GITHUB_WORKSPACE}/<triple>/. |
124 | 127 | name: "${{ matrix.env.TARGET }}" |
125 | 128 | path: ${{ github.workspace }}/crate_universe/target/artifacts/${{ matrix.env.TARGET }} |
126 | 129 | if-no-files-found: error |
127 | | - archive: |
128 | | - needs: builds |
| 130 | + |
| 131 | + # Create and push the version tag at the current main commit. The release |
| 132 | + # job's reusable workflow (release_ruleset.yaml) checks out at this tag, so |
| 133 | + # it must exist before that job runs. |
| 134 | + tag: |
| 135 | + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main')) |
| 136 | + needs: [validation, builds] |
129 | 137 | runs-on: ubuntu-22.04 |
| 138 | + permissions: |
| 139 | + contents: write |
130 | 140 | outputs: |
131 | | - release_version: ${{ steps.version.outputs.release_version }} |
132 | | - archive_sha256_base64: ${{ steps.archive.outputs.archive_sha256_base64 }} |
| 141 | + tag: ${{ steps.create_tag.outputs.tag }} |
133 | 142 | steps: |
134 | 143 | - uses: actions/checkout@v4 |
135 | | - - uses: actions/download-artifact@v4 |
136 | 144 | with: |
137 | | - path: ${{ github.workspace }}/crate_universe/target/artifacts |
138 | | - - name: Detect the current version |
139 | | - id: version |
140 | | - run: | |
141 | | - version="$(grep 'VERSION =' ${{ github.workspace }}/version.bzl | grep -o '[[:digit:].]\+')" |
142 | | - echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV |
143 | | - echo "release_version=${version}" >> $GITHUB_OUTPUT |
144 | | - - name: Comment out module overrides in .bazelrc files |
145 | | - run: | |
146 | | - # Find all .bazelrc files and comment out rules_rust module overrides |
147 | | - find . -name "*.bazelrc" -type f | while read -r file; do |
148 | | - if grep -q "^common --override_module=rules_rust=" "$file"; then |
149 | | - echo "Commenting out module override in: $file" |
150 | | - sed -i 's/^common --override_module=rules_rust=/# &/' "$file" |
151 | | - fi |
152 | | - done |
153 | | - - name: Create the rules archive |
154 | | - id: archive |
| 145 | + fetch-depth: 0 |
| 146 | + - name: Create and push tag |
| 147 | + id: create_tag |
155 | 148 | run: | |
156 | | - # Update urls and sha256 values |
157 | | - bazel ${BAZEL_STARTUP_FLAGS[@]} run //crate_universe/tools/urls_generator \ |
158 | | - -- --artifacts-dir="${ARTIFACTS_DIR}" --url-prefix="${URL_PREFIX}" |
159 | | -
|
160 | | - bazel clean |
161 | | -
|
162 | | - # Build an archive of the repo contents. |
163 | | - # `examples/hello_world` is included for the BCR presubmit; it must appear before --exclude="examples" |
164 | | - tar -czf ${{ github.workspace }}/.github/rules_rust.tar.gz \ |
165 | | - -C ${{ github.workspace }} \ |
166 | | - --exclude=".git" \ |
167 | | - --exclude=".github" \ |
168 | | - --exclude="crate_universe/target" \ |
169 | | - examples/hello_world \ |
170 | | - --exclude="examples" \ |
171 | | - . |
172 | | -
|
173 | | - # Save the sha256 checksum of the distro archive to the environment and output |
174 | | - sha256_base64="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_rust.tar.gz | awk '{ print $1 }' | xxd -r -p | base64)" |
175 | | - echo "ARCHIVE_SHA256_BASE64=${sha256_base64}" >> $GITHUB_ENV |
176 | | - echo "archive_sha256_base64=${sha256_base64}" >> $GITHUB_OUTPUT |
177 | | - env: |
178 | | - CARGO_BAZEL_GENERATOR_URL: file://${{ github.workspace }}/crate_universe/target/artifacts/x86_64-unknown-linux-gnu/cargo-bazel |
179 | | - ARTIFACTS_DIR: ${{ github.workspace }}/crate_universe/target/artifacts |
180 | | - URL_PREFIX: https://github.com/${{ github.repository_owner }}/rules_rust/releases/download/${{ env.RELEASE_VERSION }} |
| 149 | + set -euo pipefail |
| 150 | + version="$(grep 'VERSION =' ${{ github.workspace }}/version.bzl | sed 's/VERSION = "//' | sed 's/"//')" |
| 151 | + git config user.name "github-actions[bot]" |
| 152 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 153 | + # Pin the tag to the resolved SHA so a concurrent merge to main |
| 154 | + # can't shift the release contents out from under us. |
| 155 | + git tag -a "${version}" -m "rules_rust ${version}" "${{ github.sha }}" |
| 156 | + git push origin "${version}" |
| 157 | + echo "tag=${version}" >> $GITHUB_OUTPUT |
181 | 158 |
|
182 | | - # Upload the archive for review in PRs or manual recovery if release fails |
183 | | - - uses: actions/upload-artifact@v4 |
184 | | - with: |
185 | | - name: "rules_rust.tar.gz" |
186 | | - path: ${{ github.workspace }}/.github/rules_rust.tar.gz |
187 | | - if-no-files-found: error |
| 159 | + # Build the source archive, attest its provenance under the BCR-trusted |
| 160 | + # release_ruleset builder ID, and publish the GitHub release. The actual |
| 161 | + # build runs in .github/workflows/release_prep.sh (hardcoded path in |
| 162 | + # release_ruleset.yaml). |
188 | 163 | release: |
189 | | - if: startsWith(github.ref, 'refs/heads/main') |
190 | | - needs: [archive] |
191 | | - runs-on: ubuntu-22.04 |
192 | | - steps: |
193 | | - - uses: actions/checkout@v4 |
194 | | - - uses: actions/download-artifact@v4 |
195 | | - with: |
196 | | - path: ${{ github.workspace }}/artifacts |
197 | | - - name: Set release version |
198 | | - run: | |
199 | | - echo "RELEASE_VERSION=${{ needs.archive.outputs.release_version }}" >> $GITHUB_ENV |
200 | | - echo "ARCHIVE_SHA256_BASE64=${{ needs.archive.outputs.archive_sha256_base64 }}" >> $GITHUB_ENV |
201 | | - - name: Generate release notes |
202 | | - run: | |
203 | | - # Generate the release notes |
204 | | - sed 's#{version}#${{ env.RELEASE_VERSION }}#g' ${{ github.workspace }}/.github/release_notes.template \ |
205 | | - | sed 's#{sha256_base64}#${{ env.ARCHIVE_SHA256_BASE64 }}#g' \ |
206 | | - > ${{ github.workspace }}/.github/release_notes.txt |
207 | | - - name: Create release |
208 | | - uses: softprops/action-gh-release@v1 |
209 | | - id: rules_rust_release |
210 | | - env: |
211 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
212 | | - with: |
213 | | - generate_release_notes: true |
214 | | - tag_name: ${{ env.RELEASE_VERSION }} |
215 | | - body_path: ${{ github.workspace }}/.github/release_notes.txt |
216 | | - target_commitish: ${{ github.base_ref }} |
217 | | - |
218 | | - - name: "Upload the rules archive" |
219 | | - uses: actions/upload-release-asset@v1 |
220 | | - env: |
221 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
222 | | - with: |
223 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
224 | | - asset_name: rules_rust-${{ env.RELEASE_VERSION }}.tar.gz |
225 | | - asset_path: ${{ github.workspace }}/artifacts/rules_rust.tar.gz/rules_rust.tar.gz |
226 | | - asset_content_type: application/gzip |
| 164 | + needs: tag |
| 165 | + permissions: |
| 166 | + contents: write |
| 167 | + id-token: write |
| 168 | + attestations: write |
| 169 | + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@e5ab8fc4c23cb13783fad499e8bd865fd9f6d669 # v7.6.0 |
| 170 | + with: |
| 171 | + # Tests already ran on the PR that bumped version.bzl. Override the |
| 172 | + # `bazel test //...` default — rules_rust's full suite can't fit on a |
| 173 | + # single ubuntu-latest runner. |
| 174 | + bazel_test_command: "bazel info release" |
| 175 | + release_files: | |
| 176 | + rules_rust-*.tar.gz |
| 177 | + cargo-bazel-aarch64-apple-darwin |
| 178 | + cargo-bazel-aarch64-pc-windows-msvc.exe |
| 179 | + cargo-bazel-aarch64-unknown-linux-gnu |
| 180 | + cargo-bazel-aarch64-unknown-linux-musl |
| 181 | + cargo-bazel-s390x-unknown-linux-gnu |
| 182 | + cargo-bazel-x86_64-apple-darwin |
| 183 | + cargo-bazel-x86_64-pc-windows-gnu.exe |
| 184 | + cargo-bazel-x86_64-pc-windows-msvc.exe |
| 185 | + cargo-bazel-x86_64-unknown-linux-gnu |
| 186 | + cargo-bazel-x86_64-unknown-linux-musl |
| 187 | + prerelease: false |
| 188 | + tag_name: ${{ needs.tag.outputs.tag }} |
227 | 189 |
|
228 | | - # There must be a upload action for each platform triple we create |
229 | | - - name: "Upload aarch64-apple-darwin" |
230 | | - uses: actions/upload-release-asset@v1 |
231 | | - env: |
232 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
233 | | - with: |
234 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
235 | | - asset_name: cargo-bazel-aarch64-apple-darwin |
236 | | - asset_path: ${{ github.workspace }}/artifacts/aarch64-apple-darwin/cargo-bazel |
237 | | - asset_content_type: application/octet-stream |
238 | | - - name: "Upload aarch64-pc-windows-msvc" |
239 | | - uses: actions/upload-release-asset@v1 |
240 | | - env: |
241 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
242 | | - with: |
243 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
244 | | - asset_name: cargo-bazel-aarch64-pc-windows-msvc.exe |
245 | | - asset_path: ${{ github.workspace }}/artifacts/aarch64-pc-windows-msvc/cargo-bazel.exe |
246 | | - asset_content_type: application/octet-stream |
247 | | - - name: "Upload aarch64-unknown-linux-gnu" |
248 | | - uses: actions/upload-release-asset@v1 |
249 | | - env: |
250 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
251 | | - with: |
252 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
253 | | - asset_name: cargo-bazel-aarch64-unknown-linux-gnu |
254 | | - asset_path: ${{ github.workspace }}/artifacts/aarch64-unknown-linux-gnu/cargo-bazel |
255 | | - asset_content_type: application/octet-stream |
256 | | - - name: "Upload s390x-unknown-linux-gnu" |
257 | | - uses: actions/upload-release-asset@v1 |
258 | | - env: |
259 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
260 | | - with: |
261 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
262 | | - asset_name: cargo-bazel-s390x-unknown-linux-gnu |
263 | | - asset_path: ${{ github.workspace }}/artifacts/s390x-unknown-linux-gnu/cargo-bazel |
264 | | - asset_content_type: application/octet-stream |
265 | | - - name: "Upload x86_64-apple-darwin" |
266 | | - uses: actions/upload-release-asset@v1 |
267 | | - env: |
268 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
269 | | - with: |
270 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
271 | | - asset_name: cargo-bazel-x86_64-apple-darwin |
272 | | - asset_path: ${{ github.workspace }}/artifacts/x86_64-apple-darwin/cargo-bazel |
273 | | - asset_content_type: application/octet-stream |
274 | | - - name: "Upload x86_64-pc-windows-gnu" |
275 | | - uses: actions/upload-release-asset@v1 |
276 | | - env: |
277 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
278 | | - with: |
279 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
280 | | - asset_name: cargo-bazel-x86_64-pc-windows-gnu.exe |
281 | | - asset_path: ${{ github.workspace }}/artifacts/x86_64-pc-windows-gnu/cargo-bazel.exe |
282 | | - asset_content_type: application/octet-stream |
283 | | - - name: "Upload x86_64-pc-windows-msvc" |
284 | | - uses: actions/upload-release-asset@v1 |
285 | | - env: |
286 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
287 | | - with: |
288 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
289 | | - asset_name: cargo-bazel-x86_64-pc-windows-msvc.exe |
290 | | - asset_path: ${{ github.workspace }}/artifacts/x86_64-pc-windows-msvc/cargo-bazel.exe |
291 | | - asset_content_type: application/octet-stream |
292 | | - - name: "Upload x86_64-unknown-linux-gnu" |
293 | | - uses: actions/upload-release-asset@v1 |
294 | | - env: |
295 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
296 | | - with: |
297 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
298 | | - asset_name: cargo-bazel-x86_64-unknown-linux-gnu |
299 | | - asset_path: ${{ github.workspace }}/artifacts/x86_64-unknown-linux-gnu/cargo-bazel |
300 | | - asset_content_type: application/octet-stream |
301 | | - - name: "Upload x86_64-unknown-linux-musl" |
302 | | - uses: actions/upload-release-asset@v1 |
303 | | - env: |
304 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
305 | | - with: |
306 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
307 | | - asset_name: cargo-bazel-x86_64-unknown-linux-musl |
308 | | - asset_path: ${{ github.workspace }}/artifacts/x86_64-unknown-linux-musl/cargo-bazel |
309 | | - asset_content_type: application/octet-stream |
310 | | - - name: "Upload aarch64-unknown-linux-musl" |
311 | | - uses: actions/upload-release-asset@v1 |
312 | | - env: |
313 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
314 | | - with: |
315 | | - upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} |
316 | | - asset_name: cargo-bazel-aarch64-unknown-linux-musl |
317 | | - asset_path: ${{ github.workspace }}/artifacts/aarch64-unknown-linux-musl/cargo-bazel |
318 | | - asset_content_type: application/octet-stream |
319 | 190 | publish: |
320 | | - needs: [archive, release] |
| 191 | + needs: [tag, release] |
| 192 | + permissions: |
| 193 | + contents: write |
| 194 | + id-token: write |
| 195 | + attestations: write |
321 | 196 | uses: ./.github/workflows/publish.yaml |
322 | 197 | with: |
323 | | - release_version: ${{ needs.archive.outputs.release_version }} |
| 198 | + release_version: ${{ needs.tag.outputs.tag }} |
324 | 199 | secrets: |
325 | 200 | BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }} |
0 commit comments