68b05b93c4
Injects PKG_CONFIG_ALLOW_CROSS=1 into the static binary build step to ensure correct native dependency resolution during musl target compilation with cargo zigbuild. Also updates the obikmer crate version from 1.1.13 to 1.1.14.
68 lines
2.6 KiB
YAML
68 lines
2.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build-linux-static:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust + zigbuild
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
sudo apt-get update -qq && sudo apt-get install -y -qq jq
|
|
pip install ziglang --quiet --break-system-packages
|
|
$HOME/.cargo/bin/cargo install cargo-zigbuild
|
|
$HOME/.cargo/bin/rustup target add x86_64-unknown-linux-musl
|
|
|
|
- name: Create musl C/C++ wrappers
|
|
run: |
|
|
ZIG=$(python3 -c "import ziglang, os; print(os.path.join(os.path.dirname(ziglang.__file__), 'zig'))")
|
|
printf '#!/bin/sh\nexec "%s" cc -target x86_64-linux-musl "$@"\n' "$ZIG" | sudo tee /usr/local/bin/x86_64-linux-musl-gcc > /dev/null
|
|
printf '#!/bin/sh\nexec "%s" c++ -target x86_64-linux-musl "$@"\n' "$ZIG" | sudo tee /usr/local/bin/x86_64-linux-musl-g++ > /dev/null
|
|
sudo chmod +x /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/x86_64-linux-musl-g++
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src/target
|
|
key: linux-musl-cargo-${{ hashFiles('src/Cargo.lock') }}
|
|
restore-keys: linux-musl-cargo-
|
|
|
|
- name: Build static binary
|
|
env:
|
|
PKG_CONFIG_ALLOW_CROSS: "1"
|
|
run: cargo zigbuild --release --target x86_64-unknown-linux-musl
|
|
|
|
- name: Prepare artifact
|
|
run: |
|
|
mkdir -p /tmp/dist
|
|
cp target/x86_64-unknown-linux-musl/release/obikmer /tmp/dist/obikmer-linux-x86_64
|
|
strip /tmp/dist/obikmer-linux-x86_64
|
|
|
|
- name: Create Gitea release and upload binary
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
release_id=$(curl -s -X POST \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}" | jq -r '.id')
|
|
curl -s -X POST \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$release_id/assets" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@/tmp/dist/obikmer-linux-x86_64"
|