Skip to content

Build for Windows

Build for Windows #50

Workflow file for this run

name: Build for Windows
on:
workflow_dispatch:
inputs:
revision:
description: 'Revision to build (branch, tag, or SHA)'
required: false
default: 'main'
version:
description: 'Version being released'
required: false
default: '0.0.0'
jobs:
build:
name: Build SwiftFormat for Windows
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- target-triple: x86_64-unknown-windows-msvc
product-arch: amd64
- target-triple: aarch64-unknown-windows-msvc
product-arch: arm64
steps:
- uses: compnerd/gha-setup-swift@main
with:
tag: 5.10.1-RELEASE # The 5.10 installer is the first that includes the Swift runtime msm files.
branch: swift-5.10.1-release
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.revision }}
- run: swift build -c release --triple ${{ matrix.target-triple }} -Xswiftc -gnone
- uses: microsoft/[email protected]
- shell: pwsh
run: |
# Bundle the Swift runtime if the version we're using ships with a redistributable
$SwiftExePath = (& where.exe swift.exe)
if (-not ($SwiftExePath -match "(.+)\\Toolchains\\(\d+\.\d+\.\d+)[^\\]*\\.*")) {
throw "Unexpected Swift installation path format"
}
$SwiftInstallRoot = $Matches[1]
$SwiftRuntimeVersion = $Matches[2]
$SwiftRedistDir = "$SwiftInstallRoot\Redistributables\$SwiftRuntimeVersion"
if (-not (Test-Path $SwiftRedistDir)) {
throw "Swift redistributable not found at $SwiftRedistDir"
}
& msbuild -nologo -restore Platforms\Windows\SwiftFormat.wixproj `
-p:Configuration=Release `
-p:ProductArchitecture=${{ matrix.product-arch }} `
-p:ProductVersion=${{ github.event.inputs.version }} `
-p:SwiftFormatBuildDir=${{ github.workspace }}\.build\${{ matrix.target-triple }}\release `
-p:SwiftRedistDir=$SwiftRedistDir `
-p:OutputPath=${{ github.workspace }}\artifacts `
-p:RunWixToolsOutOfProc=true
- name: 'Upload EXE'
uses: actions/upload-artifact@v4
with:
name: swiftformat.${{ matrix.product-arch }}.exe
path: .build/${{ matrix.target-triple }}/release/swiftformat.exe
retention-days: 5
- name: 'Upload MSI'
uses: actions/upload-artifact@v4
with:
name: SwiftFormat.${{ matrix.product-arch }}.msi
path: artifacts\SwiftFormat.msi
retention-days: 5