diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a0e496f69b..cf3c375e5d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -119,20 +119,34 @@ jobs: name: "${{ matrix.env.TARGET }}" path: ${{ github.workspace }}/crate_universe/target/artifacts/${{ matrix.env.TARGET }} if-no-files-found: error - release: - if: startsWith(github.ref, 'refs/heads/main') + archive: needs: builds runs-on: ubuntu-22.04 + outputs: + release_version: ${{ steps.version.outputs.release_version }} + archive_sha256_base64: ${{ steps.archive.outputs.archive_sha256_base64 }} steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: path: ${{ github.workspace }}/crate_universe/target/artifacts - name: Detect the current version + id: version run: | version="$(grep 'VERSION =' ${{ github.workspace }}/version.bzl | grep -o '[[:digit:].]\+')" echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV + echo "release_version=${version}" >> $GITHUB_OUTPUT + - name: Comment out module overrides in .bazelrc files + run: | + # Find all .bazelrc files and comment out rules_rust module overrides + find . -name "*.bazelrc" -type f | while read -r file; do + if grep -q "^common --override_module=rules_rust=" "$file"; then + echo "Commenting out module override in: $file" + sed -i 's/^common --override_module=rules_rust=/# &/' "$file" + fi + done - name: Create the rules archive + id: archive run: | # Update urls and sha256 values bazel ${BAZEL_STARTUP_FLAGS[@]} run //crate_universe/tools/urls_generator \ @@ -151,20 +165,34 @@ jobs: --exclude="examples" \ . - # Save the sha256 checksum of the distro archive to the environment + # Save the sha256 checksum of the distro archive to the environment and output sha256_base64="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_rust.tar.gz | awk '{ print $1 }' | xxd -r -p | base64)" echo "ARCHIVE_SHA256_BASE64=${sha256_base64}" >> $GITHUB_ENV + echo "archive_sha256_base64=${sha256_base64}" >> $GITHUB_OUTPUT env: CARGO_BAZEL_GENERATOR_URL: file://${{ github.workspace }}/crate_universe/target/artifacts/x86_64-unknown-linux-gnu/cargo-bazel ARTIFACTS_DIR: ${{ github.workspace }}/crate_universe/target/artifacts URL_PREFIX: https://github.com/${{ github.repository_owner }}/rules_rust/releases/download/${{ env.RELEASE_VERSION }} - # Upload the artifact in case creating a release fails so all artifacts can then be manually recovered. + # Upload the archive for review in PRs or manual recovery if release fails - uses: actions/upload-artifact@v4 with: name: "rules_rust.tar.gz" path: ${{ github.workspace }}/.github/rules_rust.tar.gz if-no-files-found: error + release: + if: startsWith(github.ref, 'refs/heads/main') + needs: [archive] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + path: ${{ github.workspace }}/artifacts + - name: Set release version + run: | + echo "RELEASE_VERSION=${{ needs.archive.outputs.release_version }}" >> $GITHUB_ENV + echo "ARCHIVE_SHA256_BASE64=${{ needs.archive.outputs.archive_sha256_base64 }}" >> $GITHUB_ENV - name: Generate release notes run: | # Generate the release notes @@ -189,7 +217,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: rules_rust-${{ env.RELEASE_VERSION }}.tar.gz - asset_path: ${{ github.workspace }}/.github/rules_rust.tar.gz + asset_path: ${{ github.workspace }}/artifacts/rules_rust.tar.gz/rules_rust.tar.gz asset_content_type: application/gzip # There must be a upload action for each platform triple we create @@ -200,7 +228,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-aarch64-apple-darwin - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/aarch64-apple-darwin/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/aarch64-apple-darwin/cargo-bazel asset_content_type: application/octet-stream - name: "Upload aarch64-pc-windows-msvc" uses: actions/upload-release-asset@v1 @@ -209,7 +237,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-aarch64-pc-windows-msvc.exe - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/aarch64-pc-windows-msvc/cargo-bazel.exe + asset_path: ${{ github.workspace }}/artifacts/aarch64-pc-windows-msvc/cargo-bazel.exe asset_content_type: application/octet-stream - name: "Upload aarch64-unknown-linux-gnu" uses: actions/upload-release-asset@v1 @@ -218,7 +246,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-aarch64-unknown-linux-gnu - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/aarch64-unknown-linux-gnu/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/aarch64-unknown-linux-gnu/cargo-bazel asset_content_type: application/octet-stream - name: "Upload s390x-unknown-linux-gnu" uses: actions/upload-release-asset@v1 @@ -227,7 +255,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-s390x-unknown-linux-gnu - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/s390x-unknown-linux-gnu/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/s390x-unknown-linux-gnu/cargo-bazel asset_content_type: application/octet-stream - name: "Upload x86_64-apple-darwin" uses: actions/upload-release-asset@v1 @@ -236,7 +264,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-x86_64-apple-darwin - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/x86_64-apple-darwin/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/x86_64-apple-darwin/cargo-bazel asset_content_type: application/octet-stream - name: "Upload x86_64-pc-windows-gnu" uses: actions/upload-release-asset@v1 @@ -245,7 +273,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-x86_64-pc-windows-gnu.exe - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/x86_64-pc-windows-gnu/cargo-bazel.exe + asset_path: ${{ github.workspace }}/artifacts/x86_64-pc-windows-gnu/cargo-bazel.exe asset_content_type: application/octet-stream - name: "Upload x86_64-pc-windows-msvc" uses: actions/upload-release-asset@v1 @@ -254,7 +282,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-x86_64-pc-windows-msvc.exe - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/x86_64-pc-windows-msvc/cargo-bazel.exe + asset_path: ${{ github.workspace }}/artifacts/x86_64-pc-windows-msvc/cargo-bazel.exe asset_content_type: application/octet-stream - name: "Upload x86_64-unknown-linux-gnu" uses: actions/upload-release-asset@v1 @@ -263,7 +291,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-x86_64-unknown-linux-gnu - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/x86_64-unknown-linux-gnu/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/x86_64-unknown-linux-gnu/cargo-bazel asset_content_type: application/octet-stream - name: "Upload x86_64-unknown-linux-musl" uses: actions/upload-release-asset@v1 @@ -272,7 +300,7 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-x86_64-unknown-linux-musl - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/x86_64-unknown-linux-musl/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/x86_64-unknown-linux-musl/cargo-bazel asset_content_type: application/octet-stream - name: "Upload aarch64-unknown-linux-musl" uses: actions/upload-release-asset@v1 @@ -281,5 +309,5 @@ jobs: with: upload_url: ${{ steps.rules_rust_release.outputs.upload_url }} asset_name: cargo-bazel-aarch64-unknown-linux-musl - asset_path: ${{ github.workspace }}/crate_universe/target/artifacts/aarch64-unknown-linux-musl/cargo-bazel + asset_path: ${{ github.workspace }}/artifacts/aarch64-unknown-linux-musl/cargo-bazel asset_content_type: application/octet-stream