diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20b0ecd..4fb84c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,12 +49,6 @@ jobs: os: ubuntu-22.04 generator: Unix Makefiles vcpkg_root: - - id: macOS - triplet: arm64-osx - compiler: clang - os: macOS-latest - generator: Unix Makefiles - vcpkg_root: /usr/local/share/vcpkg - id: windows-x64-vs triplet: x64-windows compiler: vs @@ -87,12 +81,12 @@ jobs: vcpkg_root: C:/vcpkg cache: C:/Users/runneradmin/AppData/Local/vcpkg/archives - runs-on: ${{matrix.os}} + runs-on: &runs-on ${{matrix.os}} - env: + env: &env VCPKG_ROOT: ${{matrix.vcpkg_root}} - steps: + steps: &build-steps - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 with: persist-credentials: false @@ -135,11 +129,29 @@ jobs: restore-keys: | ${{matrix.id}}- + # Use Visual Studio's own vcvarsall.bat: the StepSecurity action that + # wraps it requires a paid subscription in private repositories. - name: Configure Visual Studio if: matrix.compiler == 'vs' - uses: step-security/msvc-dev-cmd@22c98154b708dbd743e6f27a933cf6ceba3305c4 # v1 - with: - arch: ${{matrix.arch}} + shell: pwsh + run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $vcvarsall = & $vswhere -latest -products * -find VC\Auxiliary\Build\vcvarsall.bat | + Select-Object -First 1 + if (!$vcvarsall) { throw "vcvarsall.bat not found" } + $script = "$env:RUNNER_TEMP\vcvars.cmd" + "@call `"$vcvarsall`" ${{matrix.arch}} >&2 && set" | Set-Content -Encoding ascii $script + $vars = cmd.exe /d /c $script + if ($LASTEXITCODE -ne 0 -or !($vars -match '^VSCMD_ARG_TGT_ARCH=')) { + throw "vcvarsall.bat ${{matrix.arch}} failed" + } + foreach ($var in $vars) { + $name, $value = $var -split '=', 2 + if ($name -and $null -ne $value -and + [Environment]::GetEnvironmentVariable($name) -cne $value) { + "$name=$value" >> $env:GITHUB_ENV + } + } - name: Install MSYS2 if: matrix.compiler == 'mingw' @@ -304,3 +316,26 @@ jobs: with: name: ${{env.version}}-${{matrix.id}} path: ${{github.workspace}}/dist + + # macOS minutes cost about six times as much as Windows minutes, which + # quickly exhausts the included usage of private repositories. Their + # portable changes are covered on other platforms, so private repositories + # build on macOS only when the workflow is run manually. + build-macos: + name: build + if: ${{ !github.event.repository.private || github.event_name == 'workflow_dispatch' }} + strategy: + matrix: + include: + - id: macOS + triplet: arm64-osx + compiler: clang + os: macOS-latest + generator: Unix Makefiles + vcpkg_root: /usr/local/share/vcpkg + + runs-on: *runs-on + + env: *env + + steps: *build-steps diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 633965b..a296556 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,6 +12,8 @@ on: jobs: analyze: name: Analyze + # Code scanning of private repositories requires GitHub Code Security. + if: ${{ !github.event.repository.private }} runs-on: ubuntu-latest permissions: actions: read diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a3c3d6..bd76435 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -371,10 +371,28 @@ jobs: NASM_VERSION: "3.02" NASM_SHA256: 161d0bfaff53c2f9e9f3e69fd0672323ebabafd1268976a5cec11be92a19aee7 steps: + # Use Visual Studio's own vcvarsall.bat: the StepSecurity action that + # wraps it requires a paid subscription in private repositories. - name: Configure Visual Studio - uses: step-security/msvc-dev-cmd@22c98154b708dbd743e6f27a933cf6ceba3305c4 # v1 - with: - arch: ${{matrix.vs_arch}} + shell: pwsh + run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $vcvarsall = & $vswhere -latest -products * -find VC\Auxiliary\Build\vcvarsall.bat | + Select-Object -First 1 + if (!$vcvarsall) { throw "vcvarsall.bat not found" } + $script = "$env:RUNNER_TEMP\vcvars.cmd" + "@call `"$vcvarsall`" ${{matrix.vs_arch}} >&2 && set" | Set-Content -Encoding ascii $script + $vars = cmd.exe /d /c $script + if ($LASTEXITCODE -ne 0 -or !($vars -match '^VSCMD_ARG_TGT_ARCH=')) { + throw "vcvarsall.bat ${{matrix.vs_arch}} failed" + } + foreach ($var in $vars) { + $name, $value = $var -split '=', 2 + if ($name -and $null -ne $value -and + [Environment]::GetEnvironmentVariable($name) -cne $value) { + "$name=$value" >> $env:GITHUB_ENV + } + } # Python setup - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7