|
| 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 |
0 commit comments