Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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