Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions .github/workflows/cargo_bazel_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 20 additions & 21 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/"//')"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions crate_universe/tools/cross_installer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 22 additions & 2 deletions crate_universe/tools/cross_installer/src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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();

Expand Down