aarch64 test release workflow on PR #4
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] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| 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: | |
| swift-version: development | |
| # Note: This snapshot includes the WindowsExperimental.sdk needed for static linking support, | |
| # this will be merged into Windows.sdk in the near future and $ExperimentalSDK related flags below will need to be removed | |
| swift-build: DEVELOPMENT-SNAPSHOT-2025-08-27-a | |
| update-sdk-modules: true | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - shell: pwsh | |
| run: | | |
| $ExperimentalSDK = "$(Split-Path -Path ${env:SDKROOT} -Parent)/WindowsExperimental.sdk" | |
| swift build -c release --triple ${{ matrix.target-triple }} -debug-info-format none -Xswiftc -static-stdlib ` | |
| -Xswiftc -sdk -Xswiftc ${ExperimentalSDK} | |
| - uses: microsoft/setup-msbuild@v2.0.0 | |
| - 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" | |
| } | |
| # Determine product version based on trigger | |
| if ("${{ github.event_name }}" -eq "release") { | |
| $ProductVersion = "${{ github.event.release.tag_name }}" | |
| } elseif ("${{ github.event_name }}" -eq "workflow_dispatch") { | |
| $ProductVersion = "${{ inputs.tag }}" | |
| } else { | |
| $ProductVersion = "0.0.0.1" | |
| } | |
| & msbuild -nologo -restore Platforms\Windows\SwiftFormat.wixproj ` | |
| -p:Configuration=Release ` | |
| -p:ProductArchitecture=${{ matrix.product-arch }} ` | |
| -p:ProductVersion=$ProductVersion ` | |
| -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() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') | |
| 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: Get Release ID | |
| id: get-release-id | |
| run: | | |
| if [ -n "${{ github.event.release.id }}" ]; then | |
| echo "release-id=${{ github.event.release.id }}" >> $GITHUB_OUTPUT | |
| else | |
| TAG="${{ inputs.tag }}" | |
| RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/$TAG --jq '.id') | |
| echo "release-id=$RELEASE_ID" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload release assets | |
| uses: skx/github-action-publish-binaries@master | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| releaseId: ${{ steps.get-release-id.outputs.release-id }} | |
| args: 'SwiftFormat.*.msi' |