From 4989c5d66a574eb7ae113e73fbb10df2711c5f54 Mon Sep 17 00:00:00 2001 From: Frederik Wallner Date: Tue, 29 Apr 2025 20:38:05 +0200 Subject: [PATCH] Revert "Rip out everything windows for now" This reverts commit 7d6348b84c07b33515ee21ebc40bbf974cc19d40. --- .github/workflows/ci.yml | 12 +++++++++++- src/windows/windows.ts | 41 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c902a900..fb30c768 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] + os: + [ + ubuntu-latest, + ubuntu-24.04-arm, + macos-latest, + windows-latest, + windows-11-arm, + ] swift: ["6.1"] steps: - uses: actions/checkout@v4 @@ -36,6 +43,9 @@ jobs: node-version-file: ".nvmrc" - run: npm install - run: npm run build && npm run pack-source-map + - name: Add msbuild to PATH + if: ${{ matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm' }} + uses: microsoft/setup-msbuild@v2 - uses: ./ with: swift-version: ${{ matrix.swift }} diff --git a/src/windows/windows.ts b/src/windows/windows.ts index 1d5b1bc5..33737bb8 100644 --- a/src/windows/windows.ts +++ b/src/windows/windows.ts @@ -9,5 +9,44 @@ import { coerce } from "semver"; * Setup Swift on Windows as theres no support for Swiftly yet. */ export async function setupWindows(version: string) { - throw Error("Windows is not supported yet"); + const path = await download(version); + addPath(path); +} + +async function download(version: string) { + const m = machine(); + + let url: string; + if (m === "arm64") { + url = `https://download.swift.org/swift-${version}-release/windows10-arm64/swift-${version}-RELEASE/swift-${version}-RELEASE-windows10-arm64.exe`; + } else { + url = `https://download.swift.org/swift-${version}-release/windows10/swift-${version}-RELEASE/swift-${version}-RELEASE-windows10.exe`; + } + + debug(`Downloading Swift installer from ${url}`); + + const tmpPath = tempDir(); + + const installerPath = await downloadTool( + url, + join(tmpPath, "swift-installer.exe"), + ); + + const targetPath = join(tmpPath, "Swift"); + + await cmd( + installerPath, + "/passive", + "/quiet", + "/norestart", + `InstallRoot=${targetPath}`, + ); + + return join( + targetPath, + "Toolchains", + `${coerce(version)}+Asserts`, + "usr", + "bin", + ); }