Skip to content

Commit

Permalink
ci: build & upload binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Dec 19, 2024
1 parent 35ec903 commit 5248733
Showing 1 changed file with 114 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: build

on:
push:
branches:
- main
tags:
- '*'
# For testing:
pull_request:

permissions: {}

defaults:
run:
# Enable fail-fast behavior
shell: bash -e {0}

env:
# Disable incremental compilation for faster from-scratch builds
CARGO_INCREMENTAL: 0
RUSTFLAGS: "--cfg tokio_unstable"

jobs:
build-and-upload:
strategy:
matrix:
include:
- platform: x86_64-unknown-linux-gnu
runner: [self-hosted, Linux, X64]
suffix: x86-linux
- platform: x86_64-pc-windows-gnu
runner: [self-hosted, Linux, X64]
suffix: x86-windows
- platform: x86_64-apple-darwin
runner: [self-hosted, Linux, X64]
suffix: x86-mac
- platform: aarch64-apple-darwin
runner: [self-hosted, Linux, ARM64]
suffix: aarch64-max
runs-on: ${{ matrix.runner }}
container:
image: rust:1.82.0
steps:
- uses: actions/checkout@v4
- name: Setup Cross-Compiling Environment
name: bash
run: |
# Install required components for each platform
apt-get update
if [[ "${{ matrix.platform }}" == "x86_64-pc-windows-gnu" ]]; then
echo "Installing Windows components"
apt-get install -y gcc-mingw-w64-x86-64
elif [[ "${{ matrix.platform }}" == "x86_64-unknown-linux-gnu" ]]; then
echo "Installing Linux components"
apt-get install -y gcc-x86-64-linux-gnu libc6-dev-amd64-cross
elif [[ "${{ matrix.platform }}" == "x86_64-apple-darwin" || "${{ matrix.platform }}" == "aarch64-apple-darwin" ]]; then
echo "Installing macOS components"
apt-get install -y clang libssl-dev wget xz-utils cmake patch libxml2-dev llvm-dev uuid-dev curl unzip
# Install osxcross
git config --global --add safe.directory '*'
git clone https://github.com/tpoechtrager/osxcross /root/osxcross
cd /root/osxcross
wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz
mv MacOSX11.3.sdk.tar.xz tarballs/
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
export PATH="/root/osxcross/target/bin:$PATH"
fi
# Install targets
rustup target add ${{ matrix.platform }}
mkdir -p /root/.cargo && \
echo '\
[target.x86_64-unknown-linux-gnu]\n\
linker = "x86_64-linux-gnu-gcc"\n\
\n\
[target.x86_64-pc-windows-gnu]\n\
linker = "x86_64-w64-mingw32-gcc"\n\
\n\
[target.x86_64-apple-darwin]\n\
linker = "x86_64-apple-darwin20.4-clang"\n\
ar = "x86_64-apple-darwin20.4-ar"\n\
\n\
[target.aarch64-apple-darwin]\n\
linker = "aarch64-apple-darwin20.4-clang"\n\
ar = "aarch64-apple-darwin20.4-ar"\n\
' > /root/.cargo/config.toml
- name: Build
env:
# Expose correct target since we're building cross-platform
OVERRIDE_TARGET: ${{ matrix.platform }}
run: cargo build --bin rivet --release --target ${{ matrix.platform }}
- name: Upload artifacts
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_AWS_SECRET_ACCESS_KEY }}
run: |
apt-get install -y awscli
COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
BINARY_NAME="rivet-${{ matrix.suffix }}"
if [[ "${{ matrix.platform }}" == "x86_64-pc-windows-gnu" ]]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
aws s3 cp \
target/${{ matrix.platform }}/release/rivet \
s3://rivet-releases/rivet/${COMMIT_SHA_SHORT}/${BINARY_NAME} \
--region auto \
--endpoint-url https://2a94c6a0ced8d35ea63cddc86c2681e7.r2.cloudflarestorage.com/rivet-releases

0 comments on commit 5248733

Please sign in to comment.