Merge pull request #46 from N-Storm/dev #122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of mfaktc. | |
# Copyright (c) 2025 NStorm (https://github.com/N-Storm) | |
# Copyright (c) 2009-2011 Oliver Weihe ([email protected]) | |
# | |
# mfaktc is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# mfaktc is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with mfaktc. If not, see <http://www.gnu.org/licenses/>. | |
# | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
name: mfaktc CI | |
on: | |
push: | |
paths-ignore: | |
- '**/*.txt' | |
- 'COPYING' | |
- '.gitignore' | |
pull_request: | |
paths-ignore: | |
- '**/*.txt' | |
- 'COPYING' | |
- '.gitignore' | |
types: | |
- 'opened' | |
- 'reopened' | |
- 'synchronize' | |
- 'ready_for_review' | |
workflow_dispatch: | |
jobs: | |
# Begin job "build-linux" | |
build-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
# If set to true, all jobs within the same matrix (such as Linux or | |
# Windows builds) will be aborted at the same time if any one job fails. | |
fail-fast: false | |
matrix: | |
sys: | |
# Specified version combination must exist as CUDA container image from Nvidia: nvcr.io/nvidia/cuda:${{ matrix.sys.cuda_version }}-devel-${{ matrix.sys.ct_os }} | |
# Available versions can be found here: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda/tags (note that only Ubuntu distros are supported by this action) | |
- { cuda_version: '12.9.0', ct_os: 'ubuntu24.04' } | |
- { cuda_version: '12.8.1', ct_os: 'ubuntu24.04' } | |
# - { cuda_version: '12.8.0', ct_os: 'ubuntu24.04' } | |
- { cuda_version: '12.6.3', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.6.2', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.6.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.6.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.5.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.5.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.4.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.4.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.3.2', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.3.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.3.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.2.2', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.2.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.1.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.1.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '12.0.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '12.0.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '11.8.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '11.7.1', ct_os: 'ubuntu22.04' } | |
# - { cuda_version: '11.7.0', ct_os: 'ubuntu22.04' } | |
- { cuda_version: '11.6.2', ct_os: 'ubuntu20.04' } | |
# - { cuda_version: '11.6.1', ct_os: 'ubuntu20.04' } | |
# - { cuda_version: '11.6.0', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.5.2', ct_os: 'ubuntu20.04' } | |
# - { cuda_version: '11.5.1', ct_os: 'ubuntu20.04' } | |
# - { cuda_version: '11.5.0', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.4.3', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.3.1', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.2.2', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.1.1', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '11.0.3', ct_os: 'ubuntu20.04' } | |
- { cuda_version: '10.2', ct_os: 'ubuntu18.04' } | |
- { cuda_version: '9.2', ct_os: 'ubuntu18.04' } | |
- { cuda_version: '8.0', ct_os: 'ubuntu16.04' } | |
env: | |
# We can't use GitHub direct container support on old Ubuntu versions, | |
# because actions will fail due to an old glibc version. | |
# A workaround is to use 'docker exec' to run build-related actions in | |
# a separately launched Docker container, while generic actions will run | |
# on the host runner. | |
CONTAINER: "nvcr.io/nvidia/cuda:${{ matrix.sys.cuda_version }}-devel-${{ matrix.sys.ct_os }}" | |
steps: | |
- name: Start Docker container | |
run: | | |
docker pull $CONTAINER | |
docker run --name build-container -d -v ${GITHUB_WORKSPACE}:/workspace $CONTAINER tail -f /dev/null | |
- name: Update GPG keys for CUDA repo on Ubuntu 16.04 | |
if: matrix.sys.ct_os == 'ubuntu16.04' | |
env: | |
SCRIPT: apt-key add /workspace/3bf863cc.pub | |
run: | | |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub | |
docker exec build-container bash -c "$SCRIPT" | |
- name: Update and install dependencies inside container | |
id: packages | |
env: | |
SCRIPT: | | |
apt-get update | |
apt-get -y full-upgrade | |
apt-get install -y build-essential curl git make python3 sudo unzip wget zip | |
run: docker exec build-container bash -c "$SCRIPT" | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Prepare sources and gather info | |
id: prepare | |
env: | |
SCRIPT: | | |
cd /workspace | |
git config --global --add safe.directory /workspace | |
bash .github/workflows/scripts/build_helper.sh ${{ matrix.sys.cuda_version }} | |
run: | | |
docker exec build-container bash -c "$SCRIPT" | |
cat .github/workflows/scripts/build_helper.sh.out >> $GITHUB_OUTPUT | |
- name: Build from sources | |
env: | |
SCRIPT: cd /workspace/src && make -j$(nproc) | |
run: docker exec build-container bash -c "$SCRIPT" | |
- name: Prepare ZIP archive with description | |
env: | |
SCRIPT: | | |
cd /workspace | |
zip -9 -j ${{ steps.prepare.outputs.BASE_NAME }}.zip Changelog.txt COPYING mfaktc mfaktc.ini README.txt | |
echo "[${{ steps.prepare.outputs.BASE_NAME }}.zip](https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/${{ steps.prepare.outputs.BASE_NAME }}.zip) | \ | |
${{ matrix.sys.cuda_version }} | ${{ steps.prepare.outputs.CC_MIN }}-${{ steps.prepare.outputs.CC_MAX }} | ${{ steps.prepare.outputs.OS_VER }} | \ | |
${{ steps.prepare.outputs.COMPILER_VER }} | ${{ steps.prepare.outputs.NVCC_VER }}" > ${{ steps.prepare.outputs.BASE_NAME }}.txt | |
run: docker exec build-container bash -c "$SCRIPT" | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.prepare.outputs.BASE_NAME }} | |
path: ${{ steps.prepare.outputs.BASE_NAME }}.* | |
# End job "build-linux" | |
# Begin job "build-win" | |
build-win: | |
# Build should work with windows-2022 images as well, but the resulting binaries | |
# are nearly identical. So let's target the image that will be supported longer term. | |
runs-on: windows-2025 | |
strategy: | |
# If set to true, all jobs within the same matrix (such as Linux or | |
# Windows builds) will be aborted at the same time if any one job fails. | |
fail-fast: false | |
matrix: | |
# Available CUDA versions can be viewed at the Jimver/cuda-toolkit action sources: | |
# https://github.com/Jimver/cuda-toolkit/blob/v0.2.24/src/links/windows-links.ts | |
sys: | |
- { cuda_version: '12.9.0' } | |
- { cuda_version: '12.8.1' } | |
- { cuda_version: '12.6.3' } | |
- { cuda_version: '12.5.1' } | |
- { cuda_version: '12.4.1' } | |
- { cuda_version: '12.3.2' } | |
- { cuda_version: '12.2.2' } | |
- { cuda_version: '12.1.1' } | |
- { cuda_version: '12.0.1' } | |
- { cuda_version: '11.8.0' } | |
- { cuda_version: '11.7.1' } | |
- { cuda_version: '11.6.2' } | |
- { cuda_version: '11.5.2' } | |
- { cuda_version: '11.4.4' } | |
- { cuda_version: '11.3.1' } | |
- { cuda_version: '11.2.2' } | |
- { cuda_version: '11.1.1' } | |
- { cuda_version: '11.0.1' } | |
- { cuda_version: '10.0.130' } | |
- { cuda_version: '9.2.148' } | |
- { cuda_version: '8.0.61' } | |
env: | |
MSVC_PKG_VC140: Microsoft.VisualStudio.Component.VC.140 | |
MSVC_PKG_VC141: Microsoft.VisualStudio.Component.VC.v141.x86.x64 | |
MSVC_SETUP_CMD: '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" modify --passive --norestart --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"' | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Install CUDA Toolkit | |
id: cuda-toolkit | |
uses: Jimver/[email protected] | |
with: | |
cuda: ${{ matrix.sys.cuda_version }} | |
sub-packages: ${{ startsWith(matrix.sys.cuda_version, '8.') && '[]' || '[ "nvcc", "cudart" ]' }} | |
use-local-cache: false | |
use-github-cache: false | |
- name: Configure path to CUDA | |
shell: powershell | |
run: | | |
[System.Environment]::SetEnvironmentVariable('PATH', "$env:CUDA_PATH\bin;$env:PATH", 'User') | |
- name: Prepare sources and gather info | |
id: prepare | |
shell: bash | |
run: | | |
bash .github/workflows/scripts/build_helper.sh ${{ matrix.sys.cuda_version }} | |
cat .github/workflows/scripts/build_helper.sh.out >> $GITHUB_OUTPUT | |
- name: Build from sources with MSVC | |
shell: cmd | |
run: | | |
${{ env.MSVC_ADD_PKG_CMD }} | |
"${{ env.VCVARS_PATH }}" x64 ${{ env.VCVARS_VER }} & cd src & copy mfaktc.ini .. & make SHELL="powershell.exe" -j%NUMBER_OF_PROCESSORS% -f Makefile.win & cl /? 2>&1 | findstr /C:"Version" > clversion.log & echo Build finished | |
env: | |
VCVARS_PATH: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat' | |
# vcvars_ver=14.X enables previous versions of MSVC build environments (MSVC 2015: 14.0, MSVC 2017: 14.16, MSVC 2019: 14.29) | |
VCVARS_VER: >- | |
${{ ( | |
steps.prepare.outputs.CUDA_VER_MAJOR <= 9 && '-vcvars_ver=14.0' | |
|| steps.prepare.outputs.CUDA_VER_MAJOR == 10 && '-vcvars_ver=14.16' | |
|| steps.prepare.outputs.CUDA_VER_MAJOR == 11 && steps.prepare.outputs.CUDA_VER_MINOR <= 2 && '-vcvars_ver=14.29' | |
|| '' | |
) }} | |
# windows-2022/2025 images come with the MSVC 2019 component (named VC142 internally) installed, | |
# but older versions need to be installed by running '${MSVC_SETUP_CMD} --add PKG_NAME' | |
# ${MSVC_PKG_VC140} is required for 14.0 (MSVC 2015), and ${MSVC_PKG_VC141} for 14.16 (MSVC 2017) | |
MSVC_ADD_PKG_CMD: >- | |
${{ ( | |
steps.prepare.outputs.CUDA_VER_MAJOR <= 9 && format('{0} --add {1}', env.MSVC_SETUP_CMD, env.MSVC_PKG_VC140) | |
|| steps.prepare.outputs.CUDA_VER_MAJOR == 10 && format('{0} --add {1}', env.MSVC_SETUP_CMD, env.MSVC_PKG_VC141) | |
|| 'REM No component to install' | |
) }} | |
- name: Prepare build archive with description | |
shell: bash | |
# We can't get the actual compiler (cl.exe) version in the helper script, because it might not be installed during the 'prepare' stage. | |
# COMPILER_VER from that stage contains the MSVC version, but not the compiler version, which has its own version number. | |
# So a little hack was added to log the cl version during the build stage, and now we extract and use it in the report along with the MSVC version. | |
run: | | |
[ -f src/clversion.log ] && CL_VER="$(grep -Eoe 'Version [\.0-9]+ ' src/clversion.log | cut -d' ' -f2)" | |
[ -z "$CL_VER" ] && CL_VER='Unknown' | |
tar -a -c -f "${{ steps.prepare.outputs.BASE_NAME }}.zip" Changelog.txt COPYING mfaktc-win-64.exe mfaktc.ini README.txt | |
echo "[${{ steps.prepare.outputs.BASE_NAME }}.zip](https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/${{ steps.prepare.outputs.BASE_NAME }}.zip) | \ | |
${{ matrix.sys.cuda_version }} | ${{ steps.prepare.outputs.CC_MIN }}-${{ steps.prepare.outputs.CC_MAX }} | ${{ steps.prepare.outputs.OS_VER }} | \ | |
${CL_VER} (${{ steps.prepare.outputs.COMPILER_VER }}) | ${{ steps.prepare.outputs.NVCC_VER }}" > ${{ steps.prepare.outputs.BASE_NAME }}.txt | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.prepare.outputs.BASE_NAME }} | |
path: ${{ steps.prepare.outputs.BASE_NAME }}.* | |
# End job "build-win" | |
# Begin job "upload-release" | |
upload-release: | |
# This job expects the Git tag name to begin with the version specified by | |
# MFAKTC_VERSION in params.h | |
# Otherwise, the job will fail because there is a version conflict between Git | |
# and params.h that must be resolved. | |
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') | |
needs: [ build-linux, build-win ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
base_name: mfaktc-${{ github.ref_name }}*-cuda*/mfaktc-${{ github.ref_name }}*-cuda* | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Prepare asset list and release notes | |
id: makeinfo | |
run: | | |
if ! compgen -G "${base_name}.txt" > /dev/null 2>&1; then | |
echo "::error ::Could not find release notes with mask ${base_name}.txt" | |
echo "::error ::Ensure the Git tag name begins with the version specified by MFAKTC_VERSION in src/params.h" | |
exit 1 | |
fi | |
{ | |
echo "Binary releases (automated builds) as follows." | |
echo "Compute Capability (CC) in the table means minimum and maximum versions supported." | |
echo "CC versions are listed without the separator. For example, '90' means devices with compute capability 9.0 can run that build." | |
echo | |
echo "File | CUDA version | Compute Capability | Build OS | Compiler version | NVCC version" | |
echo "--- | --- | --- | --- | --- | ---" | |
sort -Vr ${base_name}.txt | |
} > RELEASE_NOTES.txt | |
{ | |
echo 'RELEASE_FILES<<EOF' | |
printf '%s\n' "${base_name}.zip" | sort -Vr | |
echo 'EOF' | |
} > $GITHUB_OUTPUT | |
( echo "$GITHUB_REF_NAME" | grep -qsP "v?\d+(?:\.\d+(?:\.\d+)?(?:-\d+)?|\b)(-(?:alpha|beta|pre))" && echo "PRERELEASE=true" || echo "PRERELEASE=false" ) >> $GITHUB_OUTPUT | |
- name: Create and upload release package | |
uses: softprops/[email protected] | |
with: | |
fail_on_unmatched_files: false | |
files: | | |
${{ steps.makeinfo.outputs.RELEASE_FILES }} | |
preserve_order: true | |
prerelease: ${{ steps.makeinfo.outputs.PRERELEASE }} | |
generate_release_notes: true | |
body_path: RELEASE_NOTES.txt | |
make_latest: true | |
# End job "upload-release" |