Skip to content

Upload CLI binaries #149

Upload CLI binaries

Upload CLI binaries #149

Workflow file for this run

name: Upload CLI binaries
on:
release:
types:
- created
env:
TAG: ${{ github.event.release.tag_name }} # had some issue using this directly on windows
jobs:
linux:
runs-on: ubuntu-20.04
strategy:
fail-fast: false # we don't want to cancel building binaries for other targets just because one fails
matrix:
target:
[
x86_64-unknown-linux-gnu,
i686-unknown-linux-gnu,
aarch64-unknown-linux-gnu,
armv7-unknown-linux-gnueabihf,
x86_64-unknown-linux-musl,
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Node
uses: actions/setup-node@v4
with:
node-version: "18"
- id: "auth"
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gcc-multilib # required to build for 32-bit arch
- name: Install aarch64-unknown-linux-gnu linker
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: sudo apt install -y gcc-aarch64-linux-gnu
- name: Install armv7-unknown-linux-gnueabihf linker
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
run: sudo apt install -y gcc-arm-linux-gnueabihf
- name: Install musl gcc
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
run: sudo apt install -y musl-tools
- name: Build
run: |
rustup target add ${{ matrix.target }}
cargo build -p tmc-langs-cli --release --target ${{ matrix.target }}
npm --prefix ./crates/bindings/tmc-langs-node install
- name: Build for node
if: ${{ matrix.target != 'x86_64-unknown-linux-musl' }}
run: npm --prefix ./crates/bindings/tmc-langs-node run build -- --release --target ${{ matrix.target }}
- name: Deploy
run: gsutil cp ./target/${{ matrix.target }}/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-${{ matrix.target }}-$TAG
- name: Deploy for node
if: ${{ matrix.target != 'x86_64-unknown-linux-musl' }}
run: gsutil cp ./crates/bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-${{ matrix.target }}-$TAG.node
windows:
runs-on: windows-2022
strategy:
fail-fast: false # we don't want to cancel building binaries for other targets just because one fails
matrix:
target: [i686-pc-windows-msvc, x86_64-pc-windows-msvc]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Node
uses: actions/setup-node@v4
with:
node-version: "18"
- id: "auth"
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v2
- name: Build
run: |
git config --system core.longpaths true # allow long paths from git deps
rustup target add ${{ matrix.target }}
$env:RUSTFLAGS="-C target-feature=+crt-static" # crt-static is set with RUSTFLAGS to statically link MSVCRT (VCRUNTIME140.dll)
cargo build -p tmc-langs-cli --release --target ${{ matrix.target }}
cd ./crates/bindings/tmc-langs-node && npm install && npm run build -- --release --target ${{ matrix.target }}
- name: Deploy
run: |
$env:python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
$env:CLOUDSDK_PYTHON="C:\hostedtoolcache\windows\Python\$env:python_version\x64\python"
gsutil cp ./target/${{ matrix.target }}/release/tmc-langs-cli.exe gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-${{ matrix.target }}-$Env:TAG.exe
gsutil cp ./crates/bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-${{ matrix.target }}-$Env:TAG.node
macos:
runs-on: macos-12
strategy:
fail-fast: false # we don't want to cancel building binaries for other targets just because one fails
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Node
uses: actions/setup-node@v4
with:
node-version: "18"
- id: "auth"
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- uses: actions/setup-python@v5
with:
python-version: "3.11" # gsutil doesn't support >3.11
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v2
- name: Cargo build
run: |
rustup target add ${{ matrix.target }}
cargo build -p tmc-langs-cli --release --target ${{ matrix.target }}
npm --prefix ./crates/bindings/tmc-langs-node install
npm run --prefix ./crates/bindings/tmc-langs-node build -- --release
- name: Sign
run: codesign --force -s - target/${{ matrix.target }}/release/tmc-langs-cli
- name: Deploy
run: |
gsutil cp ./target/${{ matrix.target }}/release/tmc-langs-cli gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-cli-${{ matrix.target }}-$TAG
gsutil cp ./crates/bindings/tmc-langs-node/ts/functions.node gs://${{ secrets.GCP_BUCKET }}/tmc-langs-rust/tmc-langs-${{ matrix.target }}-$TAG.node