Skip to content

Commit

Permalink
Changes to support two binaries (#3192)
Browse files Browse the repository at this point in the history
Group effort from Turbo team.

 - Adds an action to build a go binary
 - Updates rust wrapper to package go binary in npm package
 - Switches Linux builds of rust binary to statically link musl, allowing alpine containers to work
  • Loading branch information
Greg Soltis committed Jan 6, 2023
1 parent 86474aa commit 616805d
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 78 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build_go_binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build Go Binary

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

on:
workflow_dispatch:
inputs:
release_branch:
description: "Staging branch to run release from"

jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.release_branch }}
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Test
run: pnpm -- turbo run test --filter=cli --color

darwin:
needs: [smoke-test]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.release_branch }}
- run: git fetch origin --tags
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Build Artifacts
run: cd cli && make build-go-turbo-darwin
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: turbo-go-darwin-${{ inputs.release_branch }}
path: cli/dist-darwin

# compiles linux and windows in a container
cross:
needs: [smoke-test]
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/vercel/turbo-cross:v1.18.5
steps:
- uses: actions/checkout@v3
with:
ref: "${{ inputs.release_branch }}"
- run: git fetch origin --tags
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Build Artifacts
run: cd cli && make build-go-turbo-cross
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: turbo-go-cross-${{ inputs.release_branch }}
path: cli/dist-cross
119 changes: 41 additions & 78 deletions .github/workflows/build_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,24 @@ jobs:
settings:
- host: macos-latest
target: "x86_64-apple-darwin"
lib-cache-key: turbo-lib-darwin-${{ inputs.release_branch }}
container-options: "--rm"
- host: macos-latest
target: "aarch64-apple-darwin"
lib-cache-key: turbo-lib-darwin-${{ inputs.release_branch }}
container-options: "--rm"
- host: ubuntu-latest
container: ubuntu:xenial
container-options: "--platform=linux/amd64 --rm"
container-setup: "apt-get update && apt-get install -y curl"
target: "x86_64-unknown-linux-gnu"
lib-cache-key: turbo-lib-cross-${{ inputs.release_branch }}
container-setup: "apt-get update && apt-get install -y curl musl-tools"
target: "x86_64-unknown-linux-musl"
setup: "apt-get install -y build-essential clang-5.0 lldb-5.0 llvm-5.0-dev libclang-5.0-dev"
- host: ubuntu-latest
container: ubuntu:xenial
container-options: "--rm"
container-setup: "apt-get update && apt-get install -y curl"
target: "aarch64-unknown-linux-gnu"
lib-cache-key: turbo-lib-cross-${{ inputs.release_branch }}
rustflags: 'RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc"'
setup: "apt-get install -y build-essential clang-5.0 lldb-5.0 llvm-5.0-dev libclang-5.0-dev gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
target: "aarch64-unknown-linux-musl"
rustflags: 'CC_aarch64_unknown_linux_musl=clang AR_aarch64_unknown_linux_musl=llvm-ar RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"'
setup: "sudo apt-get install -y build-essential musl-tools clang llvm 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"
setup: "rustup set default-host x86_64-pc-windows-gnu"
container-options: "--rm"
runs-on: ${{ matrix.settings.host }}
container:
Expand Down Expand Up @@ -76,41 +69,6 @@ jobs:
# path: ~/.cargo/git
# key: ${{ matrix.settings.target }}-cargo-index

- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
# Optional, workflow file name or ID
# If not specified, will be inferred from run_id (if run_id is specified), or will be the current workflow
workflow: build_go_lib.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion:
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
# Or a workflow status:
# "completed", "in_progress", "queued"
# Use the empty string ("") to ignore status or conclusion in the search
workflow_conclusion: success
# Optional, will use the specified branch. Defaults to all branches
branch: ${{ inputs.release_branch }}
# Optional, uploaded artifact name,
# will download all artifacts if not specified
# and extract them into respective subdirectories
# 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: cli/libturbo
# Optional, choose how to exit the action if no artifact is found
# can be one of:
# "fail", "warn", "ignore"
# default fail
if_no_artifact_found: fail

# TODO: re-enable this instead of the above when this runs together with the go library build
# - name: Download Cross-compiled Artifacts
# uses: actions/download-artifact@v3
# with:
# name: ${{ matrix.settings.lib-cache-key }}
# path: cli/libturbo
- name: Build Setup
shell: bash
if: ${{ matrix.settings.setup }}
Expand Down Expand Up @@ -155,41 +113,46 @@ jobs:
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Download Apple ARM64 Artifacts
uses: actions/download-artifact@v3
with:
name: turbo-aarch64-apple-darwin
path: cli/dist-darwin-arm64

- name: Download Ubuntu ARM64 Artifacts
uses: actions/download-artifact@v3
with:
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: turbo-x86_64-pc-windows-gnu
path: cli/dist-windows-arm64

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

- name: Download Apple x86_64 Artifacts
uses: actions/download-artifact@v3
- name: Move Rust artifacts into place
run: |
mv rust-artifacts/turbo-aarch64-apple-darwin cli/dist-darwin-arm64
mv rust-artifacts/turbo-aarch64-unknown-linux-musl cli/dist-linux-arm64
cp -r rust-artifacts/turbo-x86_64-pc-windows-gnu cli/dist-windows-arm64
mv rust-artifacts/turbo-x86_64-unknown-linux-musl cli/dist-linux-amd64
mv rust-artifacts/turbo-x86_64-apple-darwin cli/dist-darwin-amd64
mv rust-artifacts/turbo-x86_64-pc-windows-gnu cli/dist-windows-amd64
- name: Download Go artifacts
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
name: turbo-x86_64-apple-darwin
path: cli/dist-darwin-amd64
github_token: ${{secrets.TURBOBOT}}
workflow: build_go_binary.yml
workflow_conclusion: success
branch: ${{ inputs.release_branch }}
path: go-artifacts
skip_unpack: false
if_no_artifact_found: fail

- name: Download Windows x86_64 Artifacts
uses: actions/download-artifact@v3
with:
name: turbo-x86_64-pc-windows-gnu
path: cli/dist-windows-amd64
- name: Move Go artifacts into place
run: |
mv go-artifacts/turbo-go-cross-${{ inputs.release_branch }}/turbo_linux_amd64_v1/bin/* cli/dist-linux-amd64
chmod a+x cli/dist-linux-amd64/bin/*
mv go-artifacts/turbo-go-cross-${{ inputs.release_branch }}/turbo_linux_arm64/bin/* cli/dist-linux-arm64
chmod a+x cli/dist-linux-arm64/bin/*
mv go-artifacts/turbo-go-cross-${{ inputs.release_branch }}/turbo_windows_amd64_v1/bin/* cli/dist-windows-amd64
chmod a+x cli/dist-windows-amd64/bin/*
mv go-artifacts/turbo-go-cross-${{ inputs.release_branch }}/turbo_windows_arm64/bin/* cli/dist-windows-arm64
chmod a+x cli/dist-windows-arm64/bin/*
mv go-artifacts/turbo-go-darwin-${{ inputs.release_branch }}/turbo_darwin_amd64_v1/bin/* cli/dist-darwin-amd64
chmod a+x cli/dist-darwin-amd64/bin/*
mv go-artifacts/turbo-go-darwin-${{ inputs.release_branch }}/turbo_darwin_arm64/bin/* cli/dist-darwin-arm64
chmod a+x cli/dist-darwin-arm64/bin/*
- name: Perform Release
run: cd cli && make publish-turbo
Expand Down

0 comments on commit 616805d

Please sign in to comment.