Skip to content

Commit 1f602c0

Browse files
committed
Add GitHub Actions for ci and release
1 parent 17b0a25 commit 1f602c0

2 files changed

Lines changed: 198 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
# Build-checks every push and pull request. Does not publish anything —
4+
# releases are handled by release.yml on version tags.
5+
on:
6+
push:
7+
branches: ['**']
8+
tags-ignore: ['**'] # tags are handled by release.yml
9+
pull_request:
10+
11+
# A newer push to the same branch/PR cancels an in-flight run.
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
macos-metal:
18+
name: macOS Metal (arm64)
19+
runs-on: macos-15
20+
steps:
21+
- uses: actions/checkout@v6
22+
- name: Verify Metal sources embed cleanly
23+
run: make check-metal-sources
24+
- name: Build executables
25+
run: make
26+
- name: Build shared library
27+
run: make shared
28+
- name: Build test binary
29+
run: make ds4_test
30+
31+
linux-cuda-x86_64:
32+
name: Linux CUDA (x86_64)
33+
runs-on: ubuntu-24.04
34+
steps:
35+
- uses: actions/checkout@v6
36+
- name: Install CUDA toolkit
37+
run: |
38+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
39+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
40+
sudo apt-get update
41+
sudo apt-get install -y --no-install-recommends cuda-toolkit-12-8
42+
- name: Build shared library (CUDA)
43+
run: |
44+
export PATH="/usr/local/cuda/bin:$PATH"
45+
make shared
46+
- name: Build CPU-only variant
47+
run: |
48+
make clean
49+
make cpu
50+
make shared-cpu
51+
52+
linux-cuda-arm64:
53+
name: Linux CUDA (arm64/sbsa)
54+
runs-on: ubuntu-24.04-arm
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Install CUDA toolkit
58+
run: |
59+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/sbsa/cuda-keyring_1.1-1_all.deb
60+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
61+
sudo apt-get update
62+
sudo apt-get install -y --no-install-recommends cuda-toolkit-12-8
63+
- name: Build shared library (CUDA)
64+
run: |
65+
export PATH="/usr/local/cuda/bin:$PATH"
66+
make shared
67+
- name: Build CPU-only variant
68+
run: |
69+
make clean
70+
make cpu
71+
make shared-cpu

.github/workflows/release.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
# Build the libds4 FFI shared library for each supported platform and attach
4+
# the results to a GitHub Release. Triggered by pushing a version tag, e.g.:
5+
#
6+
# git tag v1.2.3 && git push nm v1.2.3
7+
#
8+
on:
9+
push:
10+
tags:
11+
- 'v*'
12+
13+
permissions:
14+
contents: write # needed to create the Release and upload assets
15+
16+
env:
17+
# The Makefile defaults NATIVE_CPU_FLAG to -march=native / -mcpu=native,
18+
# which bakes in the *CI runner's* CPU. A binary tuned that way can crash
19+
# with SIGILL on an older/different CPU, so release artifacts use a portable
20+
# baseline instead. Raise these if you only target newer hardware.
21+
CPU_FLAG_X86: -march=x86-64-v3 # AVX2-era x86_64 baseline
22+
CPU_FLAG_ARM64_MACOS: -mcpu=apple-m1 # Apple Silicon baseline
23+
CPU_FLAG_ARM64_LINUX: -mcpu=neoverse-v2 # Grace / GB10 (DGX Spark)
24+
# CUDA toolkit apt package suffix from NVIDIA's ubuntu2404 repo.
25+
CUDA_PKG_VERSION: 12-8
26+
27+
jobs:
28+
macos-metal-arm64:
29+
name: macOS Metal (arm64)
30+
runs-on: macos-15
31+
steps:
32+
- uses: actions/checkout@v6
33+
34+
- name: Build libds4 (Metal)
35+
run: make shared NATIVE_CPU_FLAG="$CPU_FLAG_ARM64_MACOS"
36+
37+
- name: Package
38+
run: |
39+
PKG="libds4-${GITHUB_REF_NAME}-macos-arm64-metal"
40+
mkdir -p "$PKG"
41+
cp libds4.dylib ds4.h LICENSE "$PKG/"
42+
tar -czf "$PKG.tar.gz" "$PKG"
43+
44+
- uses: actions/upload-artifact@v4
45+
with:
46+
name: libds4-macos-arm64-metal
47+
path: libds4-*-macos-arm64-metal.tar.gz
48+
49+
linux-cuda-x86_64:
50+
name: Linux CUDA (x86_64)
51+
runs-on: ubuntu-24.04
52+
steps:
53+
- uses: actions/checkout@v6
54+
55+
- name: Install CUDA toolkit
56+
run: |
57+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
58+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
59+
sudo apt-get update
60+
sudo apt-get install -y --no-install-recommends "cuda-toolkit-${CUDA_PKG_VERSION}"
61+
62+
- name: Build libds4 (CUDA)
63+
run: |
64+
export PATH="/usr/local/cuda/bin:$PATH"
65+
make shared NATIVE_CPU_FLAG="$CPU_FLAG_X86"
66+
67+
- name: Package
68+
run: |
69+
PKG="libds4-${GITHUB_REF_NAME}-linux-x86_64-cuda"
70+
mkdir -p "$PKG"
71+
cp libds4.so ds4.h LICENSE "$PKG/"
72+
tar -czf "$PKG.tar.gz" "$PKG"
73+
74+
- uses: actions/upload-artifact@v4
75+
with:
76+
name: libds4-linux-x86_64-cuda
77+
path: libds4-*-linux-x86_64-cuda.tar.gz
78+
79+
linux-cuda-arm64:
80+
name: Linux CUDA (arm64/sbsa)
81+
runs-on: ubuntu-24.04-arm
82+
steps:
83+
- uses: actions/checkout@v6
84+
85+
- name: Install CUDA toolkit
86+
run: |
87+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/sbsa/cuda-keyring_1.1-1_all.deb
88+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
89+
sudo apt-get update
90+
sudo apt-get install -y --no-install-recommends "cuda-toolkit-${CUDA_PKG_VERSION}"
91+
92+
- name: Build libds4 (CUDA)
93+
run: |
94+
export PATH="/usr/local/cuda/bin:$PATH"
95+
make shared NATIVE_CPU_FLAG="$CPU_FLAG_ARM64_LINUX"
96+
97+
- name: Package
98+
run: |
99+
PKG="libds4-${GITHUB_REF_NAME}-linux-arm64-cuda"
100+
mkdir -p "$PKG"
101+
cp libds4.so ds4.h LICENSE "$PKG/"
102+
tar -czf "$PKG.tar.gz" "$PKG"
103+
104+
- uses: actions/upload-artifact@v4
105+
with:
106+
name: libds4-linux-arm64-cuda
107+
path: libds4-*-linux-arm64-cuda.tar.gz
108+
109+
release:
110+
name: Publish GitHub Release
111+
needs: [macos-metal-arm64, linux-cuda-x86_64, linux-cuda-arm64]
112+
runs-on: ubuntu-latest
113+
steps:
114+
- uses: actions/download-artifact@v8
115+
with:
116+
path: artifacts
117+
merge-multiple: true
118+
119+
- name: Generate checksums
120+
run: |
121+
cd artifacts
122+
sha256sum * > SHA256SUMS
123+
124+
- uses: softprops/action-gh-release@v3
125+
with:
126+
files: artifacts/*
127+
generate_release_notes: true

0 commit comments

Comments
 (0)