Skip to content

Commit 0be0778

Browse files
authored
GitHub Actions: add cross-platform release and CI workflows
2 parents 04b7c2b + 6cd1d6b commit 0be0778

7 files changed

Lines changed: 2108 additions & 84 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Determine tag name"
2+
description: "Determine the tag name to use for a release"
3+
outputs:
4+
name:
5+
description: "The name of the tag"
6+
value: ${{ steps.tag.outputs.name }}
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Determine tag name
12+
id: tag
13+
shell: bash
14+
run: |
15+
BUILD_NUMBER="$(git rev-list --count HEAD)"
16+
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
17+
18+
# Check if this is a tag push (for release workflow)
19+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
20+
# Extract tag name without refs/tags/ prefix
21+
TAG_NAME="${GITHUB_REF#refs/tags/}"
22+
echo "name=${TAG_NAME}" >> $GITHUB_OUTPUT
23+
elif [[ "${{ env.BRANCH_NAME }}" == "main" ]]; then
24+
# Main branch - use build number
25+
echo "name=v${BUILD_NUMBER}" >> $GITHUB_OUTPUT
26+
else
27+
# Other branches - use branch name + build number + short hash
28+
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
29+
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
30+
fi
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Linux - Setup CUDA Toolkit"
2+
description: "Setup CUDA Toolkit for Linux"
3+
inputs:
4+
cuda_version:
5+
description: "CUDA toolkit version"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Install CUDA Toolkit 12.4
12+
if: ${{ inputs.cuda_version == '12.4' }}
13+
shell: bash
14+
run: |
15+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
16+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
17+
sudo apt-get update
18+
sudo apt-get install -y cuda-toolkit-12-4
19+
echo "/usr/local/cuda-12.4/bin" >> $GITHUB_PATH
20+
echo "/usr/local/cuda-12.4/lib64" >> $GITHUB_PATH
21+
echo "/usr/local/cuda-12.4/lib" >> $GITHUB_PATH
22+
echo "CUDA_PATH=/usr/local/cuda-12.4" >> $GITHUB_ENV
23+
echo "LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "Windows - Setup CUDA Toolkit"
2+
description: "Setup CUDA Toolkit for Windows"
3+
inputs:
4+
cuda_version:
5+
description: "CUDA toolkit version"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Install Cuda Toolkit 12.4
12+
if: ${{ inputs.cuda_version == '12.4' }}
13+
shell: pwsh
14+
run: |
15+
# Create temp directory for downloads
16+
$tempDir = "C:\temp\cuda"
17+
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
18+
19+
# Create CUDA installation directory
20+
$cudaDir = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4"
21+
New-Item -ItemType Directory -Force -Path $cudaDir | Out-Null
22+
23+
# Install unzip if needed
24+
choco install unzip -y
25+
26+
# Change to temp directory
27+
Set-Location $tempDir
28+
29+
# Core CUDA components (version 12.4.99)
30+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_cudart.zip"
31+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_nvcc.zip"
32+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_nvrtc.zip"
33+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_nvtx.zip"
34+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_profiler_api.zip"
35+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.4.99-archive.zip" -OutFile "visual_studio_integration.zip"
36+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_nvprof.zip"
37+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.4.99-archive.zip" -OutFile "cuda_cccl.zip"
38+
39+
# BLAS libraries (libcublas version 12.4.2.65)
40+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.4.2.65-archive.zip" -OutFile "libcublas.zip"
41+
42+
# Random number generation (libcurand version 10.3.5.119)
43+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/libcurand/windows-x86_64/libcurand-windows-x86_64-10.3.5.119-archive.zip" -OutFile "libcurand.zip"
44+
45+
# Linear algebra solver (libcusolver version 11.6.0.99)
46+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/libcusolver/windows-x86_64/libcusolver-windows-x86_64-11.6.0.99-archive.zip" -OutFile "libcusolver.zip"
47+
48+
# FFT library (libcufft version 11.2.0.44)
49+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/libcufft/windows-x86_64/libcufft-windows-x86_64-11.2.0.44-archive.zip" -OutFile "libcufft.zip"
50+
51+
# JPEG decoding (libnvjpeg version 12.3.1.89)
52+
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/redist/libnvjpeg/windows-x86_64/libnvjpeg-windows-x86_64-12.3.1.89-archive.zip" -OutFile "libnvjpeg.zip"
53+
54+
# Verify downloads
55+
$zipCount = (Get-ChildItem -Filter "*.zip" | Measure-Object).Count
56+
if ($zipCount -eq 0) { throw "No zip files downloaded!" }
57+
Write-Host "Downloaded $zipCount zip files successfully"
58+
59+
# Extract all zip files to CUDA directory
60+
Get-ChildItem -Filter "*.zip" | ForEach-Object {
61+
Write-Host "Extracting $($_.Name)..."
62+
Expand-Archive -Path $_.FullName -DestinationPath $cudaDir -Force
63+
}
64+
65+
# Move all contents from archive folders to root while preserving directory structure
66+
Get-ChildItem -Path $cudaDir -Directory | Where-Object Name -like "*-archive" | ForEach-Object {
67+
$archiveDir = $_.FullName
68+
Copy-Item -Path "$archiveDir\*" -Destination $cudaDir -Recurse -Force
69+
Remove-Item -Path $archiveDir -Recurse -Force
70+
}
71+
72+
# Add to PATH
73+
"$cudaDir\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
74+
"$cudaDir\lib\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
75+
76+
# Set environment variables
77+
"CUDA_PATH=$cudaDir" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
78+
"CUDA_PATH_V12_4=$cudaDir" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
79+
80+
# Cleanup temp directory
81+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
82+
83+
Write-Host "CUDA Toolkit 12.4 installation completed!"

.github/workflows/ci.yml

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
env:
13+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
14+
CARGO_PROFILE_RELEASE_LTO: thin
15+
CUDA_COMPUTE_CAP: "86"
16+
17+
jobs:
18+
linux-cpu-x64:
19+
runs-on: ubuntu-22.04
20+
21+
steps:
22+
- name: Clone
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Install Rust
28+
uses: dtolnay/rust-toolchain@stable
29+
with:
30+
targets: x86_64-unknown-linux-gnu
31+
32+
- name: Install system dependencies
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y build-essential
36+
37+
- name: Build
38+
run: |
39+
cargo build --release --features mkl --target x86_64-unknown-linux-gnu
40+
41+
- name: Get version info
42+
id: version
43+
run: |
44+
SHORT_HASH=$(git rev-parse --short=7 HEAD)
45+
echo "version=${SHORT_HASH}" >> $GITHUB_OUTPUT
46+
47+
- name: Pack artifacts
48+
run: |
49+
mkdir -p release
50+
tar -czvf vecBox-${{ steps.version.outputs.version }}-bin-linux-cpu-x86_64.tar.gz -C target/x86_64-unknown-linux-gnu/release vecBox
51+
52+
- name: Upload artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
path: vecBox-${{ steps.version.outputs.version }}-bin-linux-cpu-x86_64.tar.gz
56+
name: vecBox-bin-linux-cpu-x86_64.tar.gz
57+
58+
linux-cuda-x64:
59+
runs-on: ubuntu-22.04
60+
61+
steps:
62+
- name: Clone
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
67+
- name: Install Rust
68+
uses: dtolnay/rust-toolchain@stable
69+
with:
70+
targets: x86_64-unknown-linux-gnu
71+
72+
- name: Setup CUDA
73+
uses: ./.github/actions/linux-setup-cuda
74+
with:
75+
cuda_version: '12.4'
76+
77+
- name: Install system dependencies
78+
run: |
79+
sudo apt-get update
80+
sudo apt-get install -y build-essential
81+
82+
- name: Build
83+
run: |
84+
cargo build --release --features cuda --target x86_64-unknown-linux-gnu
85+
86+
- name: Get version info
87+
id: version
88+
run: |
89+
SHORT_HASH=$(git rev-parse --short=7 HEAD)
90+
echo "version=${SHORT_HASH}" >> $GITHUB_OUTPUT
91+
92+
- name: Pack artifacts
93+
run: |
94+
mkdir -p release
95+
tar -czvf vecBox-${{ steps.version.outputs.version }}-bin-linux-cuda-x86_64.tar.gz -C target/x86_64-unknown-linux-gnu/release vecBox
96+
97+
- name: Upload artifacts
98+
uses: actions/upload-artifact@v4
99+
with:
100+
path: vecBox-${{ steps.version.outputs.version }}-bin-linux-cuda-x86_64.tar.gz
101+
name: vecBox-bin-linux-cuda-x86_64.tar.gz
102+
103+
windows-cpu-x64:
104+
runs-on: windows-2025
105+
106+
steps:
107+
- name: Clone
108+
uses: actions/checkout@v4
109+
with:
110+
fetch-depth: 0
111+
112+
- name: Install Rust
113+
uses: dtolnay/rust-toolchain@stable
114+
with:
115+
targets: x86_64-pc-windows-msvc
116+
117+
- name: Build
118+
run: |
119+
cargo build --release --features mkl --target x86_64-pc-windows-msvc
120+
121+
- name: Get version info
122+
id: version
123+
shell: pwsh
124+
run: |
125+
$shortHash = git rev-parse --short=7 HEAD
126+
echo "version=$shortHash" >> $env:GITHUB_OUTPUT
127+
128+
- name: Pack artifacts
129+
shell: pwsh
130+
run: |
131+
Compress-Archive -Path target/x86_64-pc-windows-msvc/release/vecBox.exe -DestinationPath vecBox-${{ steps.version.outputs.version }}-bin-win-cpu-x64.zip
132+
133+
- name: Upload artifacts
134+
uses: actions/upload-artifact@v4
135+
with:
136+
path: vecBox-${{ steps.version.outputs.version }}-bin-win-cpu-x64.zip
137+
name: vecBox-bin-win-cpu-x64.zip
138+
139+
windows-cuda-x64:
140+
runs-on: windows-2022
141+
142+
env:
143+
CUDA_PATH: 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4'
144+
CUDA_HOME: 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4'
145+
CUDA_TOOLKIT_ROOT_DIR: 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4'
146+
CUDA_COMPUTE_CAP: '86'
147+
148+
steps:
149+
- name: Clone
150+
uses: actions/checkout@v4
151+
with:
152+
fetch-depth: 0
153+
154+
- name: Install Rust
155+
uses: dtolnay/rust-toolchain@stable
156+
with:
157+
targets: x86_64-pc-windows-msvc
158+
159+
- name: Setup CUDA
160+
uses: ./.github/actions/windows-setup-cuda
161+
with:
162+
cuda_version: '12.4'
163+
164+
- name: Build
165+
shell: cmd
166+
run: |
167+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
168+
set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin;%PATH%
169+
cargo build --release --features cuda --target x86_64-pc-windows-msvc
170+
171+
- name: Get version info
172+
id: version
173+
shell: pwsh
174+
run: |
175+
$shortHash = git rev-parse --short=7 HEAD
176+
echo "version=$shortHash" >> $env:GITHUB_OUTPUT
177+
178+
- name: Pack artifacts
179+
shell: pwsh
180+
run: |
181+
Compress-Archive -Path target/x86_64-pc-windows-msvc/release/vecBox.exe -DestinationPath vecBox-${{ steps.version.outputs.version }}-bin-win-cuda-x64.zip
182+
183+
- name: Upload artifacts
184+
uses: actions/upload-artifact@v4
185+
with:
186+
path: vecBox-${{ steps.version.outputs.version }}-bin-win-cuda-x64.zip
187+
name: vecBox-bin-win-cuda-x64.zip
188+
189+
macos-arm64:
190+
runs-on: macos-14
191+
192+
steps:
193+
- name: Clone
194+
uses: actions/checkout@v4
195+
with:
196+
fetch-depth: 0
197+
198+
- name: Install Rust
199+
uses: dtolnay/rust-toolchain@stable
200+
with:
201+
targets: aarch64-apple-darwin
202+
203+
- name: Build
204+
run: |
205+
cargo build --release --features metal --target aarch64-apple-darwin
206+
207+
- name: Get version info
208+
id: version
209+
run: |
210+
SHORT_HASH=$(git rev-parse --short=7 HEAD)
211+
echo "version=${SHORT_HASH}" >> $GITHUB_OUTPUT
212+
213+
- name: Pack artifacts
214+
run: |
215+
mkdir -p release
216+
tar -czvf vecBox-${{ steps.version.outputs.version }}-bin-macos-arm64.tar.gz -C target/aarch64-apple-darwin/release vecBox
217+
218+
- name: Upload artifacts
219+
uses: actions/upload-artifact@v4
220+
with:
221+
path: vecBox-${{ steps.version.outputs.version }}-bin-macos-arm64.tar.gz
222+
name: vecBox-bin-macos-arm64.tar.gz
223+
224+
macos-x64:
225+
runs-on: macos-15-intel
226+
227+
steps:
228+
- name: Clone
229+
uses: actions/checkout@v4
230+
with:
231+
fetch-depth: 0
232+
233+
- name: Install Rust
234+
uses: dtolnay/rust-toolchain@stable
235+
with:
236+
targets: x86_64-apple-darwin
237+
238+
- name: Build
239+
run: |
240+
cargo build --release --features accelerate --target x86_64-apple-darwin
241+
242+
- name: Get version info
243+
id: version
244+
run: |
245+
SHORT_HASH=$(git rev-parse --short=7 HEAD)
246+
echo "version=${SHORT_HASH}" >> $GITHUB_OUTPUT
247+
248+
- name: Pack artifacts
249+
run: |
250+
mkdir -p release
251+
tar -czvf vecBox-${{ steps.version.outputs.version }}-bin-macos-x64.tar.gz -C target/x86_64-apple-darwin/release vecBox
252+
253+
- name: Upload artifacts
254+
uses: actions/upload-artifact@v4
255+
with:
256+
path: vecBox-${{ steps.version.outputs.version }}-bin-macos-x64.tar.gz
257+
name: vecBox-bin-macos-x64.tar.gz

0 commit comments

Comments
 (0)