Skip to content

v0.0.11 fix: improve EventLoop header receiving, colo selection, and … #42

v0.0.11 fix: improve EventLoop header receiving, colo selection, and …

v0.0.11 fix: improve EventLoop header receiving, colo selection, and … #42

Workflow file for this run

name: Build cfnat C multi-platform
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build-linux-glibc:
name: Build ${{ matrix.name }} glibc dynamic
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 6
matrix:
include:
- name: linux-amd64
artifact: cfnat-linux-amd64
packages: gcc libc6-dev
cc: gcc
cflags: ""
- name: linux-386
artifact: cfnat-linux-386
packages: gcc-i686-linux-gnu libc6-dev-i386-cross
cc: i686-linux-gnu-gcc
cflags: ""
- name: linux-armv5
artifact: cfnat-linux-armv5
packages: gcc-arm-linux-gnueabi libc6-dev-armel-cross
cc: arm-linux-gnueabi-gcc
cflags: "-march=armv5te"
- name: linux-armv6
artifact: cfnat-linux-armv6
packages: gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
cc: arm-linux-gnueabihf-gcc
cflags: "-marm -march=armv6 -mfpu=vfp -mfloat-abi=hard"
- name: linux-armv7
artifact: cfnat-linux-armv7
packages: gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
cc: arm-linux-gnueabihf-gcc
cflags: "-marm -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
- name: linux-arm64
artifact: cfnat-linux-arm64
packages: gcc-aarch64-linux-gnu libc6-dev-arm64-cross
cc: aarch64-linux-gnu-gcc
cflags: ""
- name: linux-mips
artifact: cfnat-linux-mips
packages: gcc-mips-linux-gnu libc6-dev-mips-cross
cc: mips-linux-gnu-gcc
cflags: ""
- name: linux-mipsel
artifact: cfnat-linux-mipsel
packages: gcc-mipsel-linux-gnu libc6-dev-mipsel-cross
cc: mipsel-linux-gnu-gcc
cflags: ""
- name: linux-mips64
artifact: cfnat-linux-mips64
packages: gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross
cc: mips64-linux-gnuabi64-gcc
cflags: ""
- name: linux-mips64el
artifact: cfnat-linux-mips64el
packages: gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross
cc: mips64el-linux-gnuabi64-gcc
cflags: ""
- name: linux-ppc64
artifact: cfnat-linux-ppc64
packages: gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross
cc: powerpc64-linux-gnu-gcc
cflags: ""
- name: linux-ppc64le
artifact: cfnat-linux-ppc64le
packages: gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross
cc: powerpc64le-linux-gnu-gcc
cflags: ""
- name: linux-riscv64
artifact: cfnat-linux-riscv64
packages: gcc-riscv64-linux-gnu libc6-dev-riscv64-cross
cc: riscv64-linux-gnu-gcc
cflags: ""
- name: linux-s390x
artifact: cfnat-linux-s390x
packages: gcc-s390x-linux-gnu libc6-dev-s390x-cross
cc: s390x-linux-gnu-gcc
cflags: ""
env:
SOURCE_FILE: cfnat.c
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Install cross compiler
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
${{ matrix.packages }} \
file \
ca-certificates
- name: Build Linux glibc dynamic
shell: bash
run: |
set -euo pipefail
mkdir -p dist
if [ ! -f "$SOURCE_FILE" ]; then
echo "SOURCE_FILE '$SOURCE_FILE' not found" >&2
exit 1
fi
${{ matrix.cc }} -O2 -pipe -std=c11 \
-Wall -Wextra -Wno-unused-parameter ${{ matrix.cflags }} \
"$SOURCE_FILE" -o "dist/${{ matrix.artifact }}" \
-pthread -s
file "dist/${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
if-no-files-found: error
build-linux-musl:
name: Build ${{ matrix.name }} musl static
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 6
matrix:
include:
- name: linux-amd64-musl
artifact: cfnat-linux-amd64-musl
zig_target: x86_64-linux-musl
cflags: ""
- name: linux-386-musl
artifact: cfnat-linux-386-musl
zig_target: x86-linux-musl
cflags: ""
- name: linux-armv6-musl
artifact: cfnat-linux-armv6-musl
zig_target: arm-linux-musleabihf
cflags: "-mcpu=arm1176jzf_s"
- name: linux-armv7-musl
artifact: cfnat-linux-armv7-musl
zig_target: arm-linux-musleabihf
cflags: "-mcpu=cortex_a7"
- name: linux-arm64-musl
artifact: cfnat-linux-arm64-musl
zig_target: aarch64-linux-musl
cflags: ""
- name: linux-mips-musl
artifact: cfnat-linux-mips-musl
zig_target: mips-linux-musleabi
cflags: ""
- name: linux-mipsel-musl
artifact: cfnat-linux-mipsel-musl
zig_target: mipsel-linux-musleabi
cflags: ""
- name: linux-riscv64-musl
artifact: cfnat-linux-riscv64-musl
zig_target: riscv64-linux-musl
cflags: ""
env:
SOURCE_FILE: cfnat.c
ZIG_VERSION: 0.15.1
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Setup Zig
shell: bash
run: |
set -euo pipefail
case "$(uname -m)" in
x86_64)
zig_arch="x86_64"
;;
aarch64|arm64)
zig_arch="aarch64"
;;
*)
echo "Unsupported runner arch: $(uname -m)" >&2
exit 1
;;
esac
zig_dir="zig-${zig_arch}-linux-${ZIG_VERSION}"
zig_url="https://ziglang.org/download/${ZIG_VERSION}/${zig_dir}.tar.xz"
curl -fsSL "$zig_url" -o zig.tar.xz
tar -xf zig.tar.xz
echo "$PWD/$zig_dir" >> "$GITHUB_PATH"
- name: Install common tools
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
file \
ca-certificates
- name: Build Linux musl static
shell: bash
run: |
set -euo pipefail
mkdir -p dist
if [ ! -f "$SOURCE_FILE" ]; then
echo "SOURCE_FILE '$SOURCE_FILE' not found" >&2
exit 1
fi
zig version
zig cc -target ${{ matrix.zig_target }} -O2 -pipe -std=c11 \
-Wall -Wextra -Wno-unused-parameter ${{ matrix.cflags }} \
"$SOURCE_FILE" -o "dist/${{ matrix.artifact }}" \
-pthread -static -s
file "dist/${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
if-no-files-found: error
build-windows:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: windows-amd64
artifact: cfnat-windows-amd64.exe
packages: gcc-mingw-w64-x86-64
cc: x86_64-w64-mingw32-gcc
- name: windows-386
artifact: cfnat-windows-386.exe
packages: gcc-mingw-w64-i686
cc: i686-w64-mingw32-gcc
env:
SOURCE_FILE: cfnat.c
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Install MinGW-w64
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
${{ matrix.packages }} \
file \
ca-certificates
- name: Build Windows Win7+
shell: bash
run: |
set -euo pipefail
mkdir -p dist
if [ ! -f "$SOURCE_FILE" ]; then
echo "SOURCE_FILE '$SOURCE_FILE' not found" >&2
exit 1
fi
${{ matrix.cc }} \
-O2 -pipe -std=c11 -D_WIN32_WINNT=0x0601 \
-finput-charset=UTF-8 -fexec-charset=UTF-8 \
-Wall -Wextra -Wno-unused-parameter \
"$SOURCE_FILE" -o "dist/${{ matrix.artifact }}" \
-lws2_32 -ldnsapi -lwininet -lwinpthread -static -s
file "dist/${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
if-no-files-found: error
build-macos:
name: Build ${{ matrix.name }}
runs-on: macos-14
strategy:
fail-fast: false
matrix:
include:
- name: macos-amd64
artifact: cfnat-darwin-amd64
arch: x86_64
minver: "10.13"
- name: macos-arm64
artifact: cfnat-darwin-arm64
arch: arm64
minver: "11.0"
env:
SOURCE_FILE: cfnat.c
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Build macOS
shell: bash
run: |
set -euo pipefail
mkdir -p dist
if [ ! -f "$SOURCE_FILE" ]; then
echo "SOURCE_FILE '$SOURCE_FILE' not found" >&2
exit 1
fi
clang \
-O2 -pipe -std=c11 \
-Wall -Wextra -Wno-unused-parameter \
-arch ${{ matrix.arch }} -mmacosx-version-min=${{ matrix.minver }} \
"$SOURCE_FILE" -o "dist/${{ matrix.artifact }}" \
-pthread
strip "dist/${{ matrix.artifact }}" || true
file "dist/${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
if-no-files-found: error
release:
name: Publish release
needs:
- build-linux-glibc
- build-linux-musl
- build-windows
- build-macos
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
- name: Assemble release files
shell: bash
run: |
set -euo pipefail
mkdir -p release
find dist -maxdepth 3 -type f -print0 | while IFS= read -r -d '' file; do
name="$(basename "$file")"
cp "$file" "release/$name"
done
echo "Release contents:"
find release -maxdepth 1 -type f -exec ls -lh {} \;
- name: Create checksums
shell: bash
run: |
set -euo pipefail
cd release
sha256sum * > sha256sums.txt
- name: Upload GitHub Release
uses: softprops/action-gh-release@v3
with:
files: release/*