Skip to content

Build binaries

Build binaries #1

Workflow file for this run

name: Build binaries
on:
workflow_call:
inputs:
ref:
description: 'ref to build eg v0.5.1'
required: false
type: string
npmVersion:
description: 'if provided, also push npm packages with this version'
default: ''
required: false
type: string
workflow_dispatch:
inputs:
ref:
description: 'ref to build eg v0.5.1'
required: false
type: string
npmVersion:
description: 'if provided, also push npm packages with this version'
default: ''
required: false
type: string
jobs:
build:
permissions:
contents: read
packages: read
runs-on: ${{ matrix.build.os }}
strategy:
matrix:
build:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
env:
RUST_BACKTRACE: full
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- uses: ./.github/actions/clean-runner
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
# need to provide a toolchain version because this action cannot read rust-toolchain.toml. See https://github.com/actions-rs/toolchain/issues/126
# note, however, that this does not just install stable but also whatever is in rust-toolchain.toml, which is what we will use
toolchain: stable
# necessary because the toolchain@v1 action would install this target for stable only, whereas this command respects rust-toolchain.toml
- name: Install aarch64-apple-darwin Rust toolchain
if: ${{ matrix.build.target == 'aarch64-apple-darwin' }}
run: rustup target add aarch64-apple-darwin
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install cargo-license
run: cargo install cargo-license
- name: Install protoc
if: ${{ matrix.build.os == 'macos-latest' }} # installed in cross docker image in linux builds
uses: ./.github/actions/install-protoc
- name: Setup just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate notice
run: just notice-file
- name: Compile Mac binaries
if: ${{ matrix.build.os == 'macos-latest' }}
env:
MACOSX_DEPLOYMENT_TARGET: 10.14.0
run: cargo build --release --bins --target ${{ matrix.build.target }}
- name: Compile Linux binaries
if: ${{ matrix.build.os == 'ubuntu-latest' }}
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/restatedev/dev-tools:latest
options: -v ${{ github.workspace }}:/workspace -w /workspace -e ACTIONS_CACHE_URL -e ACTIONS_RUNTIME_TOKEN -e SCCACHE_GHA_ENABLED
run: |
cargo build --release --bins --target ${{ matrix.build.target }}
- name: Sign binaries
if: ${{ matrix.build.os == 'macos-latest' }}
run: |
codesign -s - target/${{ matrix.build.target }}/release/restate-server
codesign -s - target/${{ matrix.build.target }}/release/restate
- name: Move binary
run: cp target/${{ matrix.build.target }}/release/restate-server target/${{ matrix.build.target }}/release/restate .
- name: Create tar
run: tar -cvzf restate.${{ matrix.build.target }}.tar.gz LICENSE NOTICE restate-server restate
- uses: actions/upload-artifact@v3
with:
name: restate.${{ matrix.build.target }}.tar.gz
path: restate.${{ matrix.build.target }}.tar.gz
retention-days: 1
if-no-files-found: error
publish-npm:
name: Publish to NPM
if: ${{ inputs.npmVersion != '' }}
needs: [ build ]
uses: ./.github/workflows/npm.yml
secrets: inherit
with:
version: ${{ inputs.npmVersion }}