yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
0dac20642
master
1name : Release 2 3on : 4workflow_dispatch : 5push : 6# We are not caching the builds so we don't want to run the release workflow for every push to master; 7# The release workflow is only triggered by tags or manual dispatch 8tags : 9- "v20[2-9][0-9].[0-9]*" 10jobs : 11release : 12strategy : 13matrix : 14os : [ linux , macos , windows ] 15config : [ release ] 16platform : [ x86_64 , aarch64 , wasm ] 17test-category : [ smoke ] 18exclude : 19- { os : windows , platform : wasm } 20- { os : macos , platform : wasm } 21include : 22- { 23os : linux , 24platform : x86_64 , 25runs-on : ubuntu-22.04 , 26compiler : gcc , 27} 28- { 29os : linux , 30platform : aarch64 , 31runs-on : ubuntu-24.04-arm , 32compiler : gcc , 33} 34- { 35os : linux , 36platform : wasm , 37runs-on : ubuntu-22.04 , 38compiler : gcc , 39build-slang-llvm : false , 40} 41- { 42os : windows , 43platform : x86_64 , 44arch : amd64 , 45runs-on : windows-latest , 46compiler : cl , 47} 48- { 49os : windows , 50platform : aarch64 , 51arch : amd64_arm64 , 52runs-on : windows-latest , 53compiler : cl , 54extra-cmake-flags : "-DSLANG_ENABLE_CUDA=0" , 55} 56- { 57os : macos , 58platform : x86_64 , 59arch : x86_64 , 60runs-on : macos-latest , 61compiler : clang , 62} 63- { 64os : macos , 65platform : aarch64 , 66arch : arm64 , 67runs-on : macos-latest , 68compiler : clang , 69} 70 71- { build-slang-llvm : false } 72- { os : linux , platform : x86_64 , build-slang-llvm : true } 73- { 74os : windows , 75platform : x86_64 , 76arch : amd64 , 77build-slang-llvm : true , 78} 79- { 80os : macos , 81platform : aarch64 , 82arch : arm64 , 83build-slang-llvm : true , 84} 85fail-fast : false 86runs-on : ${{ matrix.runs-on }} 87container : ${{ matrix.image || '' }} 88 89defaults : 90run : 91shell : bash 92 93steps : 94- uses : actions/checkout@v4 95with : 96submodules : "recursive" 97fetch-depth : "0" 98 99- name : Setup 100uses : ./.github/actions/common-setup 101with : 102os : ${{matrix.os}} 103compiler : ${{matrix.compiler}} 104platform : ${{matrix.platform}} 105config : ${{matrix.config}} 106build-llvm : ${{matrix.build-slang-llvm}} 107 108- name : Build slang generators 109run : | 110cmake --workflow --preset generators --fresh 111mkdir build-platform-generators 112cmake --install build --config Release --component generators --prefix build-platform-generators 113 114- name : Setup Windows dev tools for target architecture 115if : matrix.os == 'windows' 116uses : ilammy/msvc-dev-cmd@v1 117with : 118arch : ${{ matrix.arch }} 119 120- name : Setup macOS dev tools for target architecture 121if : matrix.os == 'macos' 122run : | 123echo "CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}" >> "$GITHUB_ENV" 124 125- name : Build Slang 126run : | 127if [[ "${{ matrix.platform }}" == "wasm" ]]; then 128git clone https://github.com/emscripten-core/emsdk.git 129pushd emsdk 130./emsdk install latest 131./emsdk activate latest 132source ./emsdk_env.sh 133popd 134emcmake cmake -DSLANG_GENERATORS_PATH=build-platform-generators/bin --preset emscripten -DSLANG_SLANG_LLVM_FLAVOR=DISABLE 135cmake --build --preset emscripten --config Release --target slang-wasm 136exit 0 137fi 138 139if [[ "${{ matrix.os }}" == "windows" && "${{ matrix.config }}" != "release" && "${{ matrix.config }}" != "releaseWithDebugInfo" ]]; then 140echo "Please see ci.yml for the steps to make non-release builds work on Windows" >&2 141exit 1 142fi 143 144cmake --preset default --fresh \ 145-DSLANG_GENERATORS_PATH=build-platform-generators/bin \ 146-DSLANG_ENABLE_EXAMPLES=OFF \ 147-DSLANG_ENABLE_RELEASE_LTO=ON \ 148"-DSLANG_SLANG_LLVM_FLAVOR=$( 149[[ "${{matrix.build-slang-llvm}}" = "true" ]] && echo "USE_SYSTEM_LLVM" || echo "DISABLE")" \ 150${{matrix.extra-cmake-flags}} 151 152cmake --build --preset "${{matrix.config}}" 153 154- name : Sign and notarize binaries 155if : matrix.os == 'macos' && startsWith(github.ref, 'refs/tags/v') 156id : notarize 157env : 158BUILD_CERTIFICATE_BASE64 : ${{ secrets.BUILD_CERTIFICATE_BASE64 }} 159P12_PASSWORD : ${{ secrets.P12_PASSWORD }} 160KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }} 161IDENTITY_ID : "Developer ID Application: The Khronos Group, Inc. (TD2656HYNK)" 162AC_PASSWORD : ${{secrets.APPLE_ID_PASSWORD}} 163AC_PROVIDER : ${{secrets.APPLE_ID_PROVIDER}} 164AC_USERNAME : ${{secrets.APPLE_ID_USERNAME}} 165run : | 166brew install Bearer/tap/gon 167security find-identity -v 168brew install coreutils 169# create variables 170CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 171KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db 172# import certificate and provisioning profile from secrets 173echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output "$CERTIFICATE_PATH" 174# create temporary keychain 175security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" 176security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" 177security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" 178# import certificate to keychain 179security import "$CERTIFICATE_PATH" -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" 180security list-keychain -d user -s "$KEYCHAIN_PATH" 181security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${KEYCHAIN_PASSWORD}" "$KEYCHAIN_PATH" 182 183binaries=( 184"${lib_dir}/libslang.dylib" 185"${lib_dir}/libslang-rt.dylib" 186"${lib_dir}/libslang-glslang.dylib" 187"${lib_dir}/libslang-glsl-module.dylib" 188"${lib_dir}/libslang-llvm.dylib" 189"${lib_dir}/libgfx.dylib" 190"${bin_dir}/slangd" 191"${bin_dir}/slangc" 192) 193 194# Sign main binaries 195for b in "${binaries[@]}"; do 196if [[ -f "$b" ]]; then 197echo "Signing binary '$b'..." 198/usr/bin/codesign --force --options runtime -s "${IDENTITY_ID}" "$b" -v 1997z a "slang-macos-dist.zip" "$b" 200fi 201done 202 203timeout 1000 gon --log-level=debug ./extras/macos-notarize.json 204cp slang-macos-dist.zip "slang-macos-dist-${{matrix.platform}}.zip" 205echo "SLANG_NOTARIZED_DIST=slang-macos-dist-${{matrix.platform}}.zip" >> "$GITHUB_OUTPUT" 206 207- name : Package Slang 208id : package 209run : | 210triggering_ref=${{ github.ref_name }} 211if [[ $triggering_ref =~ ^v[0-9] ]]; then 212version=${triggering_ref#v} 213else 214version=$triggering_ref 215fi 216base=slang-${version}-${{matrix.os}}-${{matrix.platform}} 217 218# WASM packaging 219if [[ "${{ matrix.platform }}" == "wasm" ]]; then 220base=slang-${version}-${{matrix.platform}} 221mkdir -p "${base}" 222cp build.em/Release/bin/slang-wasm.wasm "${base}/slang-wasm.wasm" 223cp build.em/Release/bin/slang-wasm.js "${base}/slang-wasm.js" 224cp build.em/Release/bin/interface.d.ts "${base}/interface.d.ts" 225(cd "${base}" && zip -r "../${base}.zip" .) 226echo "SLANG_BINARY_ARCHIVE_ZIP=${base}.zip" >> "$GITHUB_OUTPUT" 227exit 0 228fi 229 230# Package main binaries 231cpack --preset "$config" -G ZIP 232cpack --preset "$config" -G TGZ 233# Package debug info 234cpack --preset "$config-debug-info" -G ZIP 235cpack --preset "$config-debug-info" -G TGZ 236 237# Move main packages 238mv "$(pwd)/build/dist-${config}/slang.zip" "${base}.zip" 239echo "SLANG_BINARY_ARCHIVE_ZIP=${base}.zip" >> "$GITHUB_OUTPUT" 240mv "$(pwd)/build/dist-${config}/slang.tar.gz" "${base}.tar.gz" 241echo "SLANG_BINARY_ARCHIVE_TAR=${base}.tar.gz" >> "$GITHUB_OUTPUT" 242 243# Move debug info packages 244mv "$(pwd)/build/dist-${config}-debug-info/slang-debug-info.zip" "${base}-debug-info.zip" 245echo "SLANG_DEBUG_INFO_ARCHIVE_ZIP=${base}-debug-info.zip" >> "$GITHUB_OUTPUT" 246mv "$(pwd)/build/dist-${config}-debug-info/slang-debug-info.tar.gz" "${base}-debug-info.tar.gz" 247echo "SLANG_DEBUG_INFO_ARCHIVE_TAR=${base}-debug-info.tar.gz" >> "$GITHUB_OUTPUT" 248 249# For some reason, the binaries packed by cpack for macos is modified 250# by cpack and considered damanged by macos. For now we workaround this 251# by repacking all the binaries into the release package. 252if [[ "${{ matrix.os }}" == "macos" ]]; then 253mkdir ./ttmp 254unzip "${base}.zip" -d ./ttmp 255 256# Copy only existing files from build directory 257find ./ttmp/{bin,lib} -type f | while read -r file; do 258src_file="build/$cmake_config/${file#./ttmp/}" 259if [ -f "$src_file" ]; then 260cp "$src_file" "$file" 261fi 262done 263 264rm ${base}.zip 265rm ${base}.tar.gz 266cd ./ttmp 2677z a ../${base}.zip . 268tar -czvf ../${base}.tar.gz . 269cd ../ 270fi 271 272- name : File check 273run : | 274find "build/dist-$config" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file 275 276- name : UploadBinary 277uses : softprops/action-gh-release@v1 278if : startsWith(github.ref, 'refs/tags/v') 279with : 280draft : ${{contains(github.ref, 'draft')}} 281prerelease : ${{contains(github.ref, 'draft')}} 282files : | 283${{ steps.package.outputs.SLANG_BINARY_ARCHIVE_ZIP }} 284${{ steps.package.outputs.SLANG_BINARY_ARCHIVE_TAR }} 285${{ steps.package.outputs.SLANG_DEBUG_INFO_ARCHIVE_ZIP }} 286${{ steps.package.outputs.SLANG_DEBUG_INFO_ARCHIVE_TAR }} 287${{ steps.notarize.outputs.SLANG_NOTARIZED_DIST }} 288env : 289GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 290 291- name : Checkout stdlib reference 292if : matrix.os == 'windows' && matrix.platform == 'x86_64' 293uses : actions/checkout@v4 294with : 295repository : shader-slang/stdlib-reference 296path : docs/stdlib-reference/ 297token : ${{ secrets.UPDATE_STDLIB_REFERENCE_PAT }} 298- name : Update stdlib reference 299if : matrix.os == 'windows' && matrix.platform == 'x86_64' 300shell : powershell 301run : | 302cd docs/ 303ls 304& ".\build_reference.ps1" 305env : 306GITHUB_TOKEN : ${{ secrets.UPDATE_STDLIB_REFERENCE_PAT }}