Build Windows Release Artifacts #67
This file contains hidden or 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
name: Build Windows Release Artifacts | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Release tag (e.g. v1.2.3)' | |
required: true | |
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 | |
# Disabled since the build was always failing | |
# - target-triple: aarch64-unknown-windows-msvc | |
# product-arch: arm64 | |
steps: | |
- uses: compnerd/gha-setup-swift@main | |
with: | |
tag: 6.1-RELEASE | |
branch: swift-6.1-release | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- 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.release.tag_name || inputs.tag }} ` | |
-p:SwiftFormatBuildDir=${{ github.workspace }}\.build\${{ matrix.target-triple }}\release ` | |
-p:SwiftRedistDir=$SwiftRedistDir ` | |
-p:OutputPath=${{ github.workspace }}\artifacts ` | |
-p:RunWixToolsOutOfProc=true | |
- name: 'Rename MSI file' | |
run: mv artifacts\SwiftFormat.msi artifacts\SwiftFormat.${{ matrix.product-arch }}.msi | |
- 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.${{ matrix.product-arch }}.msi | |
retention-days: 5 | |
upload: | |
name: Upload release artifacts | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: always() | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v5 | |
- uses: actions/download-artifact@v5 | |
with: | |
path: downloaded-artifacts | |
pattern: SwiftFormat.*.msi | |
- name: Display structure of downloaded files | |
run: ls -R downloaded-artifacts | |
- name: Move MSI files to workspace root | |
run: | | |
mv downloaded-artifacts/*.msi ./ | |
rm -rf downloaded-artifacts | |
- name: Display structure of uploadable files | |
run: ls -R . | |
- name: Upload release assets | |
uses: skx/github-action-publish-binaries@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
releaseId: ${{ github.event.release.id }} | |
args: 'SwiftFormat.*.msi' |