diff --git a/.github/workflows/cargo_bazel_release.yaml b/.github/workflows/cargo_bazel_release.yaml index 113b97ba63..0b8771de01 100644 --- a/.github/workflows/cargo_bazel_release.yaml +++ b/.github/workflows/cargo_bazel_release.yaml @@ -14,9 +14,9 @@ defaults: jobs: validation: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # TODO: Unfortunately it's not obvious how to restrict `workflow_dispatch` to a particular branch # so this step ensures releases are always done off of `main`. - name: Ensure branch is 'main' @@ -31,9 +31,9 @@ jobs: fi builds: needs: validation - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install rust toolchains for host run: | # Detect the current version of rust diff --git a/.github/workflows/formatting.yaml b/.github/workflows/formatting.yaml index ed7b8b003a..39ab45b10b 100644 --- a/.github/workflows/formatting.yaml +++ b/.github/workflows/formatting.yaml @@ -13,7 +13,7 @@ jobs: code-format-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Buildifier run: | wget "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIER_VERSION}/buildifier-linux-amd64" -O buildifier diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6b78d33494..af2ba23079 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,6 +2,13 @@ name: Release on: workflow_dispatch: + merge_group: + pull_request: + branches: + - main + paths: + - version.bzl + - .github/workflows/release.yaml push: branches: - main @@ -17,22 +24,11 @@ env: jobs: validation: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - # TODO: Unfortunately it's not obvious how to restrict `workflow_dispatch` to a particular branch - # so this step ensures releases are always done off of `main`. - - name: Ensure branch is 'main' - run: | - git fetch origin &> /dev/null - branch="$(git rev-parse --abbrev-ref HEAD)" - if [[ "${branch}" != "main" ]]; then - echo "The release branch must be main. Got '${branch}'' instead." >&2 - exit 1 - else - echo "Branch is '${branch}'" - fi + - uses: actions/checkout@v4 - name: Ensure release does not already exist + if: startsWith(github.ref, 'refs/heads/main') == false run: | git fetch origin &> /dev/null version="$(grep 'VERSION =' ${{ github.workspace }}/version.bzl | sed 's/VERSION = "//' | sed 's/"//')" @@ -53,7 +49,7 @@ jobs: - os: macOS-13 env: TARGET: "aarch64-apple-darwin" - - os: ubuntu-20.04 + - os: ubuntu-22.04 env: TARGET: "aarch64-unknown-linux-gnu" - os: windows-2022 @@ -62,20 +58,20 @@ jobs: - os: macOS-13 env: TARGET: "x86_64-apple-darwin" - - os: ubuntu-20.04 + - os: ubuntu-22.04 env: TARGET: "x86_64-pc-windows-gnu" - os: windows-2022 env: TARGET: "x86_64-pc-windows-msvc" - - os: ubuntu-20.04 + - os: ubuntu-22.04 env: TARGET: "x86_64-unknown-linux-gnu" - - os: ubuntu-20.04 + - os: ubuntu-22.04 env: TARGET: "x86_64-unknown-linux-musl" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install rust toolchains for host run: | # Detect the current version of rust @@ -99,6 +95,8 @@ jobs: - name: Setup Windows Bazelrc run: | echo "startup --output_user_root=C:/tmp" > ./user.bazelrc + echo "startup --windows_enable_symlinks" > ./user.bazelrc + echo "build --enable_runfiles" > ./user.bazelrc if: startswith(matrix.os, 'Windows') - name: Build cargo-bazel binaries run: | @@ -117,10 +115,11 @@ jobs: path: ${{ github.workspace }}/crate_universe/target/artifacts/${{ matrix.env.TARGET }} if-no-files-found: error release: + if: startsWith(github.ref, 'refs/heads/main') needs: builds - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: path: ${{ github.workspace }}/crate_universe/target/artifacts diff --git a/crate_universe/tools/cross_installer/BUILD.bazel b/crate_universe/tools/cross_installer/BUILD.bazel index b4ccd82407..18daac0fe0 100644 --- a/crate_universe/tools/cross_installer/BUILD.bazel +++ b/crate_universe/tools/cross_installer/BUILD.bazel @@ -23,11 +23,11 @@ rust_binary( edition = "2021", proc_macro_deps = all_crate_deps(proc_macro = True), rustc_env = { - "CARGO": "$(rootpath @rules_rust//rust/toolchain:current_cargo_files)", - "CROSS_BIN": "$(rootpath :cross)", - "CROSS_CONFIG": "$(rootpath :Cross.toml)", + "CARGO": "$(rlocationpath @rules_rust//rust/toolchain:current_cargo_files)", + "CROSS_BIN": "$(rlocationpath :cross)", + "CROSS_CONFIG_RLOCATION": "$(rlocationpath :Cross.toml)", }, - deps = all_crate_deps(normal = True), + deps = all_crate_deps(normal = True) + ["@rules_rust//rust/runfiles"], ) filegroup( diff --git a/crate_universe/tools/cross_installer/src/main.rs b/crate_universe/tools/cross_installer/src/main.rs index 8d426f9862..9ddd7c5301 100644 --- a/crate_universe/tools/cross_installer/src/main.rs +++ b/crate_universe/tools/cross_installer/src/main.rs @@ -1,5 +1,6 @@ //! A utility for cross compiling binaries using Cross +use runfiles::{rlocation, Runfiles}; use std::path::{Path, PathBuf}; use std::process::{self, Command}; use std::{env, fs}; @@ -22,7 +23,13 @@ struct Options { fn prepare_workspace(workspace_root: &Path) { // Unfortunately, cross runs into issues when cross compiling incrementally. // To avoid this, the workspace must be cleaned - let cargo = env::current_dir().unwrap().join(env!("CARGO")); + let r = Runfiles::create().unwrap(); + let cargo = rlocation!(r, env!("CARGO")).unwrap(); + + if !cargo.exists() { + panic!("Cargo binary not found at {}", cargo.display()); + } + Command::new(cargo) .current_dir(workspace_root) .arg("clean") @@ -32,7 +39,19 @@ fn prepare_workspace(workspace_root: &Path) { /// Execute a build for the provided platform fn execute_cross(working_dir: &Path, target_triple: &str) { - let cross = env::current_dir().unwrap().join(env!("CROSS_BIN")); + let r = Runfiles::create().unwrap(); + let cross = rlocation!(r, env!("CROSS_BIN")).unwrap(); + + if !cross.exists() { + panic!("Cross binary not found at {}", cross.display()); + } + + let cross_config = rlocation!(r, env!("CROSS_CONFIG_RLOCATION")).unwrap(); + + if !cross_config.exists() { + panic!("Cross config not found at {}", cross_config.display()); + } + let status = Command::new(cross) .current_dir(working_dir) .arg("build") @@ -43,6 +62,7 @@ fn execute_cross(working_dir: &Path, target_triple: &str) { .arg(format!("--target={target_triple}")) // https://github.com/cross-rs/cross/issues/1447 .env("CROSS_NO_WARNINGS", "0") + .env("CROSS_CONFIG", cross_config) .status() .unwrap();