checkout own repo, too, so that gh can tag releases #22
Workflow file for this run
This file contains 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
# | |
# .github/workflows/build-swiftshader.yml | |
# | |
# SPDX-FileCopyrightText: 2024-2025 Jens A. Koch. | |
# SPDX-License-Identifier: MIT | |
# | |
# This file is part of https://github.com/jakoch/rasterizers | |
# | |
name: "Build on Windows: Swiftshader" | |
on: | |
# You can manually run this workflow. | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- main | |
# This workflow runs on schedule: every Sunday at 1 am. | |
#schedule: | |
# - cron: "0 1 * * 0" | |
# "contents: write" allows the action to create a release | |
# this is required by the release step, which uses "gh release create" | |
permissions: | |
contents: write | |
# improve CI concurrency by automatically cancelling outdated jobs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# --------------------------------------------------------------------------------------- | |
build-on-windows-swiftshader: | |
# --------------------------------------------------------------------------------------- | |
name: "Swiftshader - Win VC17" | |
# https://github.com/actions/runner-images | |
# Installed Software: https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md | |
runs-on: windows-2025 | |
env: | |
BUILD_DIR: ${{github.workspace}}\swiftshader\build | |
INSTALL_DIR: ${{github.workspace}}\swiftshader\install | |
defaults: | |
run: | |
shell: cmd | |
steps: | |
- name: 🤘 Checkout Code | |
uses: actions/checkout@v4 # https://github.com/actions/checkout | |
- name: 🤘 Checkout Code | |
uses: actions/checkout@v4 # https://github.com/actions/checkout | |
with: | |
repository: google/swiftshader | |
path: swiftshader | |
- name: 🛠️ Setup Visual Studio Developer Command Prompt | |
uses: ilammy/msvc-dev-cmd@v1 | |
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md#visual-studio-enterprise-2022 | |
#- name: 🛠️ Setup Visual Studio Developer Command Prompt | |
# run: call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
# shell: cmd | |
# https://community.chocolatey.org/packages/cmake | |
- name: 🔽 Install CMake | |
run: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' --no-progress | |
# Reminder: This step requires that the CMakePresets for CI contain | |
# "CMAKE_CXX_COMPILER_LAUNCHER": "sccache". | |
- name: 🎯 Setup Build Cache | |
uses: hendrikmuhs/ccache-action@v1 # https://github.com/hendrikmuhs/ccache-action | |
with: | |
variant: sccache | |
key: swift-build-${{ github.ref }} | |
restore-keys: | | |
swift-build-${{ github.ref }} | |
swift-build- | |
- name: 🖋️ CMake ➔ Configure | |
run: | | |
cmake -S swiftshader -B ${{ env.BUILD_DIR }} ^ | |
-G Ninja ^ | |
-DCMAKE_BUILD_TYPE=Release ^ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^ | |
-DSWIFTSHADER_BUILD_VULKAN=ON ^ | |
-DSWIFTSHADER_BUILD_EGL=OFF ^ | |
-DSWIFTSHADER_BUILD_GLESv2=OFF ^ | |
-DSWIFTSHADER_BUILD_GLES_CM=OFF ^ | |
-DSWIFTSHADER_BUILD_PVR=OFF ^ | |
-DSWIFTSHADER_BUILD_TESTS=OFF | |
- name: 🙏 CMake ➔ Build | |
run: | | |
cmake --build ${{ env.BUILD_DIR }} --parallel --config Release --target vk_swiftshader | |
#- name: CMake ➔ Install | |
# run: | | |
# cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }} --verbose | |
- name: ❔ CHECK folders, to see if everything is present (after building & installing) | |
run: | | |
dir /S /B ${{ env.BUILD_DIR }} | |
# dir /S /B ${{ env.INSTALL_DIR }} | |
# Change back to INSTALL_DIR, when i figured out how to "cmake install" this crap. | |
# Well, after build, there is a folder "Windows"... lets package only that. | |
- name: 📝 Get Version of SwiftShader Library (Maj.Min.Patch.Rev) | |
shell: pwsh | |
run: | | |
$libraryPath = "${{ env.BUILD_DIR }}\Windows\vk_swiftshader.dll" | |
$versionInfo = (Get-Item $libraryPath).VersionInfo | |
$fileVersionRaw = $versionInfo.FileVersionRaw | |
Write-Output "FileVersionRaw: $fileVersionRaw" | |
echo "SWIFTSHADER_VERSION=$fileVersionRaw" >> $env:GITHUB_ENV | |
# Versioning Pattern: "swiftshader-win64-5.0.0.0-a2s8ad3.zip" | |
- name: 🏷️ Versionize Artifact | |
shell: pwsh | |
run: | | |
echo "SWIFTSHADER_ARTIFACT_NAME=swiftshader-win64-${{ env.SWIFTSHADER_VERSION }}" >> $env:GITHUB_ENV | |
echo "SWIFTSHADER_ARTIFACT_ZIPFILE=swiftshader-win64-${{ env.SWIFTSHADER_VERSION }}" >> $env:GITHUB_ENV | |
- name: 📦 Package Artifact | |
run: | | |
7z a -tzip -mx9 "${{ env.SWIFTSHADER_ARTIFACT_ZIPFILE }}" "${{ env.BUILD_DIR }}\Windows\*" | |
- name: 📦 🚀 Upload Artifact | |
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact | |
with: | |
name: ${{ env.SWIFTSHADER_ARTIFACT_NAME }} | |
path: ${{ env.SWIFTSHADER_ARTIFACT_ZIPFILE }} | |
compression-level: 0 | |
retention-days: 3 | |
# This is a date based version for repeatable releases (date.run.run_attempt). | |
- name: 🏷️ Set Rolling Release Version for Tag | |
shell: pwsh | |
run: | | |
echo "RELEASE_VERSION_TAG=$(Get-Date -Format 'yyyyMMdd').${{ github.run_number }}.${{ github.run_attempt }}" >> $env:GITHUB_ENV | |
# Step 1: Create a new release tag, or update(append) release notes if it exists. | |
- name: 📦 🚀 Create or Update Release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
run: | | |
$tag = "${{ env.RELEASE_VERSION_TAG }}" | |
$new_notes = "• Swiftshader for Windows (x64, VC17) ${{ env.SWIFTSHADER_VERSION }}`n" | |
if (gh release view $tag *> $null) { | |
echo "✅ Release $tag already exists. Appending new notes." | |
$existing_notes = gh release view $tag --json body --jq ".body" | |
$updated_notes = "$existing_notes`n$new_notes" | |
gh release edit $tag --notes "$updated_notes" | |
} else { | |
echo "🚀 Creating new release: $tag" | |
gh release create $tag ` | |
--title "$tag" ` | |
--notes "$new_notes" ` | |
--latest | |
} | |
# Step 2: Upload the artifact to the release tag. | |
- name: 📦 🔼 Upload Release Artifact | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
run: | | |
gh release upload "${{ env.RELEASE_VERSION_TAG }}" "${{ env.SWIFTSHADER_ARTIFACT_ZIPFILE }}" | |