yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

aidanfnvUse GitHub runners for Windows releases, disable CUDA for aarch64 (#8613)0dac20642

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