From 2cdadec9d827de3c9ac93a04fdf3ef7b74981612 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Sat, 5 Oct 2024 02:38:24 -0400 Subject: [PATCH] ci: release for all platforms --- .github/workflows/release.yaml | 32 ++++++++++++++++++++++++++++++++ Cargo.toml | 7 +++++++ rust-toolchain.toml | 2 +- scripts/build-release.sh | 13 +++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml create mode 100755 scripts/build-release.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0bc10ff --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +name: Release +on: + pull_request: + workflow_dispatch: + inputs: + component: + description: The software component to release + required: true + type: choice + options: + - identity-server + +jobs: + build: + name: Build the code for each platform + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4.2.0 + - uses: mlugg/setup-zig@v1.2.1 + with: + version: 0.13.0 + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2.7.3 + # - name: Install mingw + # run: sudo apt-get install -y mingw-w64 + + - name: Install cargo-zigbuild + run: cargo install --locked cargo-zigbuild@0.19.3 + + - name: Cargo zigbuild + run: | + scripts/build-release.sh diff --git a/Cargo.toml b/Cargo.toml index 8762e0f..3782c2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,3 +60,10 @@ opt-level = 1 [profile.dev.package."*"] # Seems to cause crashes on mac on opt-level 3 opt-level = 2 + +# What we use when producing artifacts to distribute +[profile.artifact] +inherits = "release" +lto = true +strip = true +debug = false diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 955d676..d118a7e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,4 +2,4 @@ channel = "1.81.0" # See workspace Cargo.toml components = ["rust-src"] profile = "default" -targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", "aarch64-apple-darwin"] +targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", "aarch64-apple-darwin"] diff --git a/scripts/build-release.sh b/scripts/build-release.sh new file mode 100755 index 0000000..3f20ac5 --- /dev/null +++ b/scripts/build-release.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -eux -o pipefail + +main() { + cargo zigbuild \ + --target x86_64-unknown-linux-musl \ + --target aarch64-unknown-linux-musl \ + --target x86_64-pc-windows-gnu \ + --all +} + +main