mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
1a1603f3f3
- bindings/csharp/NibblePoker.BakaShrot.Client: P/Invoke over the DLL's UTF-16 exports, one Client per handle (namespace NibblePoker.BakaShrot). C# 2 and the .NET 2.0 BCL only: net35 (.NET Framework 2.0 and up) and netstandard2.0 (.NET Core 2.0 and up, .NET 5 and up) - No JSON or TOML parsing: ListTopics, ListNodes and Query return the raw JSON string for the caller to parse; settings go to the constructor - The package: the four native libraries under runtimes/<rid>/native/, their THIRD-PARTY.txt under licenses/<rid>/, and a build/net35 .targets copying the right one next to .NET Framework apps (which ignore runtimes/) - CI: a nuget job after the four release builds packs it with the release's version and libraries, checks the listing and keeps it as the bakashrot-nuget artifact - Tests: an NUnit project (net48 and net8.0) against a real server with certificates from `bakashrot cert`, 13 tests - release.py ships BakaShrot.cs in csharp/; docs/client.md, building.md, readme.md, revamp.md (step 14) updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
255 lines
11 KiB
YAML
255 lines
11 KiB
YAML
# On a version tag, or run by hand: the same checks as test.ps1 (Windows
|
|
# and Linux), then a release for each platform (release.py), its archive
|
|
# kept as the run's artifact, the C# client's NuGet package with their four
|
|
# libraries (an artifact too), and the server's Docker image for amd64 and
|
|
# arm64, checked (docker/test.sh), pushed to ghcr.io on a tag only. Gitea
|
|
# Actions runs this file too.
|
|
#
|
|
# Safety: only people with write access can push a tag or run it by hand
|
|
# (no pull_request trigger, so nothing from a fork runs here); the token
|
|
# is read-only except where an image is pushed, after it was built and
|
|
# checked; checkouts don't keep the token on disk, so a build script (a
|
|
# crate's build.rs) can't read it; actions are pinned to their commits;
|
|
# cargo builds only what Cargo.lock says (--locked).
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
IMAGE: ghcr.io/aziascreations/bakashrot-server
|
|
|
|
jobs:
|
|
check:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [windows-latest, ubuntu-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Installs the toolchain rust-toolchain.toml pins.
|
|
- run: rustup toolchain install
|
|
- run: cargo fmt --all -- --check
|
|
- run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
|
|
- run: cargo test --locked --workspace --all-features
|
|
- run: cargo doc --locked --workspace --no-deps --all-features
|
|
env:
|
|
RUSTDOCFLAGS: -D warnings
|
|
|
|
release:
|
|
# Build, package, smoke test, each on its own kind of machine: no
|
|
# cross-compiling, and the smoke test runs where the release will.
|
|
# Linux builds in manylinux 2.28 (glibc 2.28): the programs, the .so
|
|
# and the wheel run on systems that old.
|
|
needs: check
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: windows-x64
|
|
os: windows-latest
|
|
arch: x64
|
|
- platform: windows-arm64
|
|
# aws-lc needs clang-cl there: Visual Studio's, on this image.
|
|
os: windows-11-arm
|
|
arch: arm64
|
|
- platform: linux-x64
|
|
os: ubuntu-latest
|
|
container: quay.io/pypa/manylinux_2_28_x86_64
|
|
- platform: linux-arm64
|
|
os: ubuntu-24.04-arm
|
|
container: quay.io/pypa/manylinux_2_28_aarch64
|
|
runs-on: ${{ matrix.os }}
|
|
container: ${{ matrix.container }}
|
|
timeout-minutes: 60
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Windows: a Python of the machine's architecture (the smoke test
|
|
# loads the DLL into it). Linux: the container's.
|
|
- if: ${{ !matrix.container }}
|
|
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
with:
|
|
python-version: "3.12"
|
|
architecture: ${{ matrix.arch }}
|
|
- if: ${{ matrix.container }}
|
|
run: echo "/opt/python/cp312-cp312/bin" >> "$GITHUB_PATH"
|
|
# rustup, where the image has none (windows-11-arm, the containers).
|
|
- run: |
|
|
if ! command -v rustup; then
|
|
if [ "$RUNNER_OS" = Windows ]; then
|
|
case "$RUNNER_ARCH" in ARM64) host=aarch64-pc-windows-msvc ;; *) host=x86_64-pc-windows-msvc ;; esac
|
|
curl --proto '=https' --tlsv1.2 -sSfo rustup-init.exe "https://static.rust-lang.org/rustup/dist/$host/rustup-init.exe"
|
|
./rustup-init.exe -y --default-toolchain none
|
|
rm rustup-init.exe
|
|
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
|
|
else
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
fi
|
|
fi
|
|
- run: rustup toolchain install
|
|
# Builds with --locked; the archive holds no keys (the smoke test's
|
|
# are in _test/, deleted before archiving).
|
|
- run: python release.py
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: bakashrot-${{ matrix.platform }}
|
|
path: |
|
|
target/dist/*.zip
|
|
target/dist/*.tar.gz
|
|
if-no-files-found: error
|
|
|
|
nuget:
|
|
# The C# client's NuGet package (docs/client.md, "C#"): the four
|
|
# releases' libraries in runtimes/<rid>/native/, packed on Linux
|
|
# (nothing in it is built for a platform), kept as the run's artifact.
|
|
needs: release
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
env:
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
|
DOTNET_NOLOGO: 1
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
with:
|
|
pattern: bakashrot-*
|
|
path: target/releases
|
|
# The .NET SDK, where the image has none (Gitea's runners).
|
|
- run: |
|
|
if ! command -v dotnet; then
|
|
curl --proto '=https' --tlsv1.2 -sSfLo dotnet-install.sh https://dot.net/v1/dotnet-install.sh
|
|
bash dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
|
|
rm dotnet-install.sh
|
|
echo "$HOME/.dotnet" >> "$GITHUB_PATH"
|
|
fi
|
|
- name: Pack
|
|
run: |
|
|
set -euo pipefail
|
|
version=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)
|
|
native="$PWD/target/nuget-native"
|
|
for platform in windows-x64 windows-arm64 linux-x64 linux-arm64; do
|
|
case "$platform" in windows-*) library=bakashrot.dll ;; *) library=libbakashrot.so ;; esac
|
|
rid="${platform/windows/win}"
|
|
archive=$(ls target/releases/bakashrot-$platform/bakashrot-$version-$platform.*)
|
|
mkdir -p target/unpacked "$native/$rid"
|
|
case "$archive" in *.zip) unzip -q "$archive" -d target/unpacked ;; *) tar -xzf "$archive" -C target/unpacked ;; esac
|
|
cp "target/unpacked/bakashrot-$version-$platform/$library" \
|
|
"target/unpacked/bakashrot-$version-$platform/THIRD-PARTY.txt" "$native/$rid/"
|
|
done
|
|
dotnet pack bindings/csharp/NibblePoker.BakaShrot.Client -c Release \
|
|
-p:Version="$version" -p:NativeDir="$native/" -o target/nuget
|
|
# Each library in it, or the package is wrong.
|
|
listing=$(unzip -l target/nuget/NibblePoker.BakaShrot.Client.$version.nupkg)
|
|
for file in runtimes/win-x64/native/bakashrot.dll runtimes/win-arm64/native/bakashrot.dll \
|
|
runtimes/linux-x64/native/libbakashrot.so runtimes/linux-arm64/native/libbakashrot.so \
|
|
build/net35/NibblePoker.BakaShrot.Client.targets lib/net35/NibblePoker.BakaShrot.Client.dll \
|
|
lib/netstandard2.0/NibblePoker.BakaShrot.Client.dll; do
|
|
grep -q " $file\$" <<< "$listing" || { echo "Not in the package: $file"; exit 1; }
|
|
done
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: bakashrot-nuget
|
|
path: target/nuget/*.nupkg
|
|
if-no-files-found: error
|
|
|
|
docker:
|
|
# The server's image, each architecture built on its own kind of
|
|
# machine (no emulation), checked, then pushed as <version>-<arch> on a
|
|
# tag. Run by hand, it's built and checked only. The token can push
|
|
# packages here, but it's only given to `docker login`, after the build
|
|
# and the check (the build runs inside Docker, without it).
|
|
needs: check
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- arch: amd64
|
|
os: ubuntu-latest
|
|
- arch: arm64
|
|
os: ubuntu-24.04-arm
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 60
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- name: Image tag
|
|
env:
|
|
ARCH: ${{ matrix.arch }}
|
|
run: |
|
|
if [ "$GITHUB_REF_TYPE" = tag ]; then version=${GITHUB_REF_NAME#v}; else version=manual; fi
|
|
# What a Docker tag may hold; anything else stops here.
|
|
case "$version" in
|
|
"" | *[!0-9A-Za-z._-]* | [.-]*) echo "Not a usable image tag: $version"; exit 1 ;;
|
|
esac
|
|
echo "TAG=$IMAGE:$version-$ARCH" >> "$GITHUB_ENV"
|
|
- run: docker build -f docker/Dockerfile -t "$TAG" .
|
|
- run: sh docker/test.sh "$TAG"
|
|
- name: Log in to ghcr.io
|
|
if: github.ref_type == 'tag'
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: echo "$TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
|
|
# A package first pushed by hand (with a personal token) only takes
|
|
# this workflow's pushes once the repository has write access in the
|
|
# package's settings ("Manage Actions access").
|
|
- name: Push
|
|
if: github.ref_type == 'tag'
|
|
run: docker push "$TAG"
|
|
- name: Log out
|
|
if: always() && github.ref_type == 'tag'
|
|
run: docker logout ghcr.io
|
|
|
|
docker-index:
|
|
# One image for both architectures: an index of the two as <version>,
|
|
# once the releases passed too, and as latest unless it's a
|
|
# pre-release (a version with a "-": v0.2.0-test2). GitHub reads the
|
|
# source label on an index from its annotations.
|
|
if: github.ref_type == 'tag'
|
|
needs: [docker, release]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
version=${GITHUB_REF_NAME#v}
|
|
case "$version" in
|
|
"" | *[!0-9A-Za-z._-]* | [.-]*) echo "Not a usable image tag: $version"; exit 1 ;;
|
|
esac
|
|
tags="-t $IMAGE:$version"
|
|
case "$version" in *-*) ;; *) tags="$tags -t $IMAGE:latest" ;; esac
|
|
echo "$TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
|
|
# $tags unquoted on purpose: two words each, checked above.
|
|
docker buildx imagetools create $tags \
|
|
--annotation "index:org.opencontainers.image.source=https://github.com/aziascreations/BakaShrot" \
|
|
--annotation "index:org.opencontainers.image.description=BakaShrot server" \
|
|
--annotation "index:org.opencontainers.image.licenses=CC0-1.0" \
|
|
"$IMAGE:$version-amd64" "$IMAGE:$version-arm64"
|
|
docker logout ghcr.io
|