Skip to content

Commit 5b19b88

Browse files
committed
Add Windows release artifacts
1 parent afc957a commit 5b19b88

4 files changed

Lines changed: 196 additions & 1 deletion

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Windows Release Build
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-windows:
12+
name: Build Static Windows ${{ matrix.arch-display-name }} Binary and Installer
13+
runs-on: windows-${{ matrix.windows-version }}
14+
env:
15+
SWIFT_VERSION: development
16+
SWIFT_BUILD: DEVELOPMENT-SNAPSHOT-2026-01-09-a
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- windows-version: 2025
22+
windows-display-name: "Server 2025"
23+
arch: amd64
24+
arch-display-name: AMD64
25+
wix-platform: x64
26+
target-triple: x86_64-unknown-windows-msvc
27+
- windows-version: "11-arm"
28+
windows-display-name: "11 ARM"
29+
arch: arm64
30+
arch-display-name: ARM64
31+
wix-platform: arm64
32+
target-triple: aarch64-unknown-windows-msvc
33+
steps:
34+
- name: Enable long path support
35+
run: reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
36+
- name: Set up Swift
37+
uses: compnerd/gha-setup-swift@main
38+
with:
39+
swift-version: ${{ env.SWIFT_VERSION }}
40+
swift-build: ${{ env.SWIFT_BUILD }}
41+
build_arch: ${{ matrix.arch }}
42+
- name: Checkout
43+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
44+
with:
45+
persist-credentials: false
46+
- name: Build static executable
47+
shell: pwsh
48+
env:
49+
SWIFTLINT_STATIC_WINDOWS_BUILD: 1
50+
run: |
51+
$sdk = Join-Path (Split-Path -Path $env:SDKROOT -Parent) 'WindowsExperimental.sdk'
52+
$archDir = ('${{ matrix.target-triple }}'.Split('-')[0])
53+
$staticLibDir = Join-Path $sdk (Join-Path 'usr\lib\swift_static\windows' $archDir)
54+
Copy-Item -Path (Join-Path $staticLibDir 'libcurl.lib') -Destination (Join-Path $staticLibDir 'curl.lib') -Force
55+
Copy-Item -Path (Join-Path $staticLibDir 'libxml2s.lib') -Destination (Join-Path $staticLibDir 'xml2.lib') -Force
56+
swift build `
57+
-c release `
58+
--product swiftlint `
59+
--triple ${{ matrix.target-triple }} `
60+
-debug-info-format none `
61+
-Xswiftc -static-stdlib `
62+
-Xswiftc -sdk `
63+
-Xswiftc $sdk `
64+
-Xlinker /LIBPATH:"$staticLibDir"
65+
- name: Prepare artifacts directory
66+
shell: pwsh
67+
run: |
68+
New-Item -ItemType Directory -Path artifacts -Force | Out-Null
69+
Copy-Item ".build/${{ matrix.target-triple }}/release/swiftlint.exe" "artifacts/swiftlint.exe" -Force
70+
- name: Create portable zip
71+
shell: pwsh
72+
run: |
73+
Compress-Archive -Path "artifacts/swiftlint.exe" -DestinationPath "artifacts/swiftlint-portable-${{ matrix.arch }}.zip" -Force
74+
- name: Setup MSBuild
75+
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
76+
- name: Build WiX MSI
77+
shell: pwsh
78+
run: |
79+
& msbuild -nologo -restore `
80+
Platforms\Windows\SwiftLint.wixproj `
81+
-p:Configuration=Release `
82+
-p:InstallerPlatform=${{ matrix.wix-platform }} `
83+
-p:ProductVersion=0.63.1.${{ github.run_number }} `
84+
-p:SwiftLintBuildDir=${{ github.workspace }}\.build\${{ matrix.target-triple }}\release `
85+
-p:OutputPath=${{ github.workspace }}\artifacts `
86+
-p:RunWixToolsOutOfProc=true
87+
Move-Item -Path "artifacts\SwiftLint.msi" -Destination "artifacts\SwiftLint.${{ matrix.arch }}.msi" -Force
88+
- name: Upload artifacts
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
90+
with:
91+
name: artifacts-${{ matrix.arch }}
92+
path: artifacts
93+
if-no-files-found: error
94+
retention-days: 2

Package.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// swift-tools-version:5.9
22
import CompilerPluginSupport
3+
import Foundation
34
import PackageDescription
45

56
let swiftFeatures: [SwiftSetting] = [
@@ -25,6 +26,19 @@ swiftLintPluginDependencies = [.target(name: "SwiftLintBinary")]
2526
swiftLintPluginDependencies = [.target(name: "swiftlint")]
2627
#endif
2728

29+
// Linker flags for static Windows builds.
30+
let windowsStaticLinkerflags: [LinkerSetting] =
31+
if ProcessInfo.processInfo.environment["SWIFTLINT_STATIC_WINDOWS_BUILD"] == nil {
32+
[]
33+
} else {
34+
[
35+
.linkedLibrary("libcurl.lib"),
36+
.linkedLibrary("zlibstatic.lib"),
37+
.linkedLibrary("brotlicommon.lib"),
38+
.linkedLibrary("brotlidec.lib"),
39+
]
40+
}
41+
2842
let package = Package(
2943
name: "SwiftLint",
3044
platforms: [.macOS(.v13)],
@@ -53,7 +67,8 @@ let package = Package(
5367
"SwiftLintFramework",
5468
"SwiftyTextTable",
5569
],
56-
swiftSettings: swiftFeatures + strictConcurrency
70+
swiftSettings: swiftFeatures + strictConcurrency,
71+
linkerSettings: windowsStaticLinkerflags
5772
),
5873
.executableTarget(
5974
name: "swiftlint-dev",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="WixToolset.Sdk/6.0.2">
2+
<PropertyGroup>
3+
<OutputType>Package</OutputType>
4+
<ProductName>SwiftLint</ProductName>
5+
<PackageName>SwiftLint</PackageName>
6+
<DefineConstants>
7+
ProductVersion=$(ProductVersion);
8+
ProductArchitecture=$(ProductArchitecture);
9+
SwiftLintBuildDir=$(SwiftLintBuildDir)
10+
</DefineConstants>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="WixToolset.UI.wixext" Version="6.0.2" />
15+
</ItemGroup>
16+
</Project>

Platforms/Windows/SwiftLint.wxs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<Wix
2+
xmlns="http://wixtoolset.org/schemas/v4/wxs"
3+
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
4+
5+
<Package
6+
Name="SwiftLint"
7+
Manufacturer="SwiftLint"
8+
Version="$(var.ProductVersion)"
9+
UpgradeCode="{83C6C6DC-BE70-4788-B79A-2BAA8F1F5FBF}"
10+
Language="1033">
11+
12+
<MajorUpgrade DowngradeErrorMessage="A newer version of SwiftLint is already installed." />
13+
14+
<StandardDirectory Id="ProgramFiles64Folder">
15+
<Directory Id="INSTALLFOLDER" Name="SwiftLint" />
16+
</StandardDirectory>
17+
18+
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
19+
<Component>
20+
<File Id="SwiftLintExe" Source="$(var.SwiftLintBuildDir)\swiftlint.exe" KeyPath="yes" />
21+
</Component>
22+
</ComponentGroup>
23+
24+
<ComponentGroup Id="EnvironmentVariables">
25+
<Component
26+
Id="SystemEnvironmentVariables"
27+
Condition="ALLUSERS=1"
28+
Directory="INSTALLFOLDER"
29+
Guid="A271C9AE-1BDC-4D27-B4A1-5195479C8D86">
30+
<Environment
31+
Id="SystemPath"
32+
Action="set"
33+
Name="Path"
34+
Part="last"
35+
Permanent="no"
36+
System="yes"
37+
Value="[INSTALLFOLDER]"
38+
/>
39+
</Component>
40+
<Component
41+
Id="UserEnvironmentVariables"
42+
Condition="NOT ALLUSERS=1"
43+
Directory="INSTALLFOLDER"
44+
Guid="1C384F6C-8779-4575-9723-CCB20C6DFFB6">
45+
<Environment
46+
Id="UserPath"
47+
Action="set"
48+
Name="Path"
49+
Part="last"
50+
Permanent="no"
51+
System="no"
52+
Value="[INSTALLFOLDER]"
53+
/>
54+
</Component>
55+
</ComponentGroup>
56+
57+
<Feature Id="MainFeature" Title="SwiftLint" Level="1">
58+
<ComponentGroupRef Id="ProductComponents" />
59+
<ComponentGroupRef Id="EnvironmentVariables" />
60+
</Feature>
61+
62+
<UI>
63+
<ui:WixUI Id="WixUI_InstallDir" />
64+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2" />
65+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" />
66+
</UI>
67+
68+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"></Property>
69+
</Package>
70+
</Wix>

0 commit comments

Comments
 (0)