Skip to content

Commit

Permalink
Update release process to support current app layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Dec 14, 2022
1 parent e296efd commit fdd3b66
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/build_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ jobs:
target: "aarch64-unknown-linux-gnu"
lib-cache-key: turbo-lib-cross-${{ inputs.release_branch }}
rustflags: 'RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc"'
setup: "sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
setup: "sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
- host: windows-latest
target: x86_64-pc-windows-gnu
lib-cache-key: turbo-lib-cross-${{ inputs.release_branch }}
setup: "mv cli/libturbo/turbo-windows_windows_amd64_v1/lib/turbo.exe cli/libturbo/turbo-windows_windows_amd64_v1/lib/libturbo.a && mv cli/libturbo/turbo-windows_windows_amd64_v1/lib/turbo.h cli/libturbo/turbo-windows_windows_amd64_v1/lib/libturbo.h && rustup set default-host x86_64-pc-windows-gnu"
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:
# https://github.com/actions/download-artifact#download-all-artifacts
name: ${{ matrix.settings.lib-cache-key }}
# Optional, a directory where to extract artifact(s), defaults to the current directory
path: shim/libturbo
path: cli/libturbo
# Optional, choose how to exit the action if no artifact is found
# can be one of:
# "fail", "warn", "ignore"
Expand All @@ -94,8 +95,9 @@ jobs:
# uses: actions/download-artifact@v3
# with:
# name: ${{ matrix.settings.lib-cache-key }}
# path: shim/libturbo
# path: cli/libturbo
- name: Build Setup
shell: bash
if: ${{ matrix.settings.setup }}
run: ${{ matrix.settings.setup }}

Expand All @@ -110,8 +112,8 @@ jobs:
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: shim-${{ matrix.settings.target }}
path: shim/target/${{ matrix.settings.target }}/release/turbo*
name: turbo-${{ matrix.settings.target }}
path: target/${{ matrix.settings.target }}/release/turbo*

final-publish:
name: "Publish To NPM"
Expand Down Expand Up @@ -146,37 +148,37 @@ jobs:
- name: Download Apple ARM64 Artifacts
uses: actions/download-artifact@v3
with:
name: shim-aarch64-apple-darwin
name: turbo-aarch64-apple-darwin
path: cli/dist-darwin-arm64

- name: Download Ubuntu ARM64 Artifacts
uses: actions/download-artifact@v3
with:
name: shim-aarch64-unknown-linux-gnu
name: turbo-aarch64-unknown-linux-gnu
path: cli/dist-linux-arm64

- name: Download Windows ARM64 (Ships as x86_64) Artifacts
uses: actions/download-artifact@v3
with:
name: shim-x86_64-pc-windows-gnu
name: turbo-x86_64-pc-windows-gnu
path: cli/dist-windows-arm64

- name: Download Ubuntu x86_64 Artifacts
uses: actions/download-artifact@v3
with:
name: shim-x86_64-unknown-linux-gnu
name: turbo-x86_64-unknown-linux-gnu
path: cli/dist-linux-amd64

- name: Download Apple x86_64 Artifacts
uses: actions/download-artifact@v3
with:
name: shim-x86_64-apple-darwin
name: turbo-x86_64-apple-darwin
path: cli/dist-darwin-amd64

- name: Download Windows x86_64 Artifacts
uses: actions/download-artifact@v3
with:
name: shim-x86_64-pc-windows-gnu
name: turbo-x86_64-pc-windows-gnu
path: cli/dist-windows-amd64

- name: Perform Release
Expand All @@ -189,5 +191,5 @@ jobs:
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: shim-combined
name: turbo-combined
path: cli/dist
50 changes: 31 additions & 19 deletions crates/turborepo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,32 @@ use std::{
};

fn main() {
let is_release = matches!(env::var("PROFILE"), Ok(profile) if profile == "release");
let lib_search_path = if is_release && env::var("RELEASE_TURBO_CLI") == Ok("true".to_string()) {
let is_ci_release = matches!(env::var("PROFILE"), Ok(profile) if profile == "release")
&& env::var("RELEASE_TURBO_CLI")
.map(|val| val == "true")
.unwrap_or(false);
let lib_search_path = if is_ci_release {
expect_release_lib()
} else {
build_debug_libturbo()
};
println!("cargo:rerun-if-changed={}", lib_search_path);
println!("cargo:rustc-link-search={}", lib_search_path);
println!(
"cargo:rerun-if-changed={}",
lib_search_path.to_string_lossy()
);
println!(
"cargo:rustc-link-search={}",
lib_search_path.to_string_lossy()
);
println!("cargo:rustc-link-lib=turbo");

let target = build_target::target().unwrap();
let bindings = bindgen::Builder::default()
.header(header_path(&target.os))
.header(
lib_search_path
.join("libturbo.h")
.to_string_lossy(),
)
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
Expand All @@ -39,7 +52,9 @@ fn main() {
}
}

fn expect_release_lib() -> String {
fn expect_release_lib() -> PathBuf {
// We expect all artifacts to be in the cli path
let mut dir = cli_path();
let target = build_target::target().unwrap();
let platform = match target.os {
build_target::Os::MacOs => "darwin",
Expand All @@ -52,19 +67,16 @@ fn expect_release_lib() -> String {
build_target::Arch::X86_64 => "amd64_v1",
_ => panic!("unsupported target {}", target.triple),
};
let mut dir = PathBuf::from("libturbo");
dir.push("libturbo");
// format is ${BUILD_ID}_${OS}_${ARCH}. Build id is, for goreleaser reasons,
// turbo-${OS}
dir.push(format!("turbo-{platform}_{platform}_{arch}"));
dir.push("lib");
dir.to_string_lossy().to_string()
dir
}

fn build_debug_libturbo() -> String {
let cli_path = env::var_os("CARGO_WORKSPACE_DIR")
.map(PathBuf::from)
.unwrap()
.join("cli");
fn build_debug_libturbo() -> PathBuf {
let cli_path = cli_path();
let target = build_target::target().unwrap();
let mut cmd = Command::new("make");
cmd.current_dir(&cli_path);
Expand Down Expand Up @@ -97,12 +109,12 @@ fn build_debug_libturbo() -> String {
.success(),
"failed to build turbo static library"
);
cli_path.to_string_lossy().to_string()
cli_path
}

fn header_path(target: &build_target::Os) -> &'static str {
match target {
build_target::Os::Windows => "../../cli/turbo.h",
_ => "../../cli/libturbo.h",
}
fn cli_path() -> PathBuf {
env::var_os("CARGO_WORKSPACE_DIR")
.map(PathBuf::from)
.unwrap()
.join("cli")
}

0 comments on commit fdd3b66

Please sign in to comment.