154 lines
4.9 KiB
YAML
154 lines
4.9 KiB
YAML
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
upload:
|
|
description: 'Upload built assets to the git.jutty.dev package registry'
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
linux:
|
|
description: 'Build Linux binaries'
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
windows:
|
|
description: 'Build Windows binary'
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: docker
|
|
if: ${{ inputs.linux }}
|
|
timeout-minutes: 20
|
|
container:
|
|
image: rust:slim
|
|
steps:
|
|
- name: Set up action dependencies
|
|
run: |
|
|
apt-get install --no-install-recommends --update -y nodejs git nix
|
|
echo experimental-features = nix-command flakes >> /etc/nix/nix.conf
|
|
nix profile install nixpkgs#just # trixie is on nix 2.26
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- name: Cleanup checkout action dependencies
|
|
run: apt-get purge -y nodejs git
|
|
|
|
- name: Set up CI user
|
|
run: useradd -m ci && chown -R ci /nix .
|
|
|
|
- name: Set up Rust toolchain
|
|
run: |
|
|
rust_version=$(sed -nE 's/^rust-version = "(.*)"$/\1/p' Cargo.toml)
|
|
|
|
su ci -c "
|
|
rustup default '$rust_version'
|
|
rustup toolchain install nightly
|
|
rustup component add llvm-tools
|
|
rustup component add --toolchain nightly rustfmt clippy
|
|
rustup target add \
|
|
x86_64-unknown-linux-musl \
|
|
x86_64-unknown-linux-gnu
|
|
"
|
|
|
|
- name: Assess
|
|
run: /root/.nix-profile/bin/just ci-nix "$PATH" verify
|
|
|
|
- name: Build x64 Linux glibc release binary
|
|
run: /root/.nix-profile/bin/just ci-nix "$PATH" release-build-gnu
|
|
|
|
- name: Build x64 Linux musl release binary
|
|
run: /root/.nix-profile/bin/just ci-nix "$PATH" release-build-musl
|
|
|
|
- name: Calculate SHA-256 hashes
|
|
run: /root/.nix-profile/bin/just ci-nix "$PATH" shasum
|
|
|
|
- name: Publish x64 Linux musl binary to git.jutty.dev registry
|
|
if: ${{ inputs.upload }}
|
|
run: |
|
|
version=$(./target/x86_64-unknown-linux-musl/release/en --version)
|
|
api_root=https://git.jutty.dev/api
|
|
url=$api_root/packages/jutty/generic/en/$version/en-x64-linux-musl
|
|
|
|
curl -fsSL \
|
|
--user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \
|
|
--upload-file target/x86_64-unknown-linux-musl/release/en $url
|
|
|
|
- name: Publish x64 Linux glibc binary to git.jutty.dev registry
|
|
if: ${{ inputs.upload }}
|
|
run: |
|
|
version=$(./target/x86_64-unknown-linux-gnu/release/en --version)
|
|
api_root=https://git.jutty.dev/api
|
|
url=$api_root/packages/jutty/generic/en/$version/en-x64-linux-gnu
|
|
|
|
curl -fsSL \
|
|
--user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \
|
|
--upload-file target/x86_64-unknown-linux-gnu/release/en $url
|
|
|
|
publish-windows:
|
|
runs-on: docker
|
|
if: ${{ inputs.windows }}
|
|
timeout-minutes: 20
|
|
container:
|
|
image: messense/cargo-xwin
|
|
env:
|
|
XWIN_CACHE_DIR: /tmp
|
|
steps:
|
|
- name: Install action dependencies
|
|
run: |
|
|
apt-get install --no-install-recommends --update -y nodejs git nix
|
|
echo experimental-features = nix-command flakes >> /etc/nix/nix.conf
|
|
nix profile install nixpkgs#just # trixie is on nix 2.26
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- name: Cleanup checkout action dependencies
|
|
run: apt-get purge -y nodejs git
|
|
|
|
- name: Set up CI user
|
|
run: useradd -m ci && chown -R ci /nix .
|
|
|
|
- name: Set up Rust toolchain
|
|
run: |
|
|
rust_version=$(grep '^rust-version' Cargo.toml | cut -d \" -f 2)
|
|
|
|
su ci -c "
|
|
rustup default '$rust_version'
|
|
rustup target add x86_64-pc-windows-msvc
|
|
"
|
|
|
|
- name: Cache MSVC CRT and SDK
|
|
run: cargo-xwin cache xwin
|
|
|
|
- name: Run Windows tests
|
|
run: /root/.nix-profile/bin/just ci-nix "$PATH" test-windows
|
|
|
|
- name: Build x64 Windows MSVC release binary
|
|
run: |
|
|
rm -v /usr/bin/clang
|
|
/root/.nix-profile/bin/just ci-nix "$PATH" release-build-msvc
|
|
|
|
- name: Calculate SHA-256 hashes
|
|
run: /root/.nix-profile/bin/just shasum
|
|
|
|
- name: Publish x64 Windows MSVC binary to git.jutty.dev registry
|
|
if: ${{ inputs.upload }}
|
|
run: |
|
|
version=$(./target/x86_64-unknown-linux-musl/release/en --version)
|
|
api_root=https://git.jutty.dev/api
|
|
url=$api_root/packages/jutty/generic/en/$version/en-x64-windows-msvc
|
|
|
|
curl -fsSL \
|
|
--user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \
|
|
--upload-file target/x86_64-pc-windows-msvc/release/en.exe $url
|