Skip to content

Commit 43f075f

Browse files
authored
Add workflow to build SwiftFormat
Add initial support for packaging SwiftFormat so that we can use this tool locally easily without having to build it constantly.
1 parent 8b877b4 commit 43f075f

File tree

4 files changed

+212
-0
lines changed

4 files changed

+212
-0
lines changed

.github/workflows/SwiftFormat.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: SwiftFormat
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
windows:
8+
runs-on: windows-latest
9+
10+
strategy:
11+
matrix:
12+
include:
13+
- tag: 0.51.10
14+
branch: master
15+
16+
steps:
17+
# Build
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 1
21+
ref: refs/tags/${{ matrix.tag }}
22+
repository: nicklockwood/SwiftFormat
23+
24+
- uses: compnerd/gha-setup-swift@main
25+
with:
26+
branch: development
27+
tag: DEVELOPMENT-SNAPSHOT-2023-05-22-a
28+
29+
- name: test
30+
run: |
31+
swift test
32+
33+
- name: build
34+
run: |
35+
swift build -c release
36+
37+
# Package
38+
- uses: actions/checkout@v2
39+
with:
40+
fetch-depth: 1
41+
ref: ${{ vars.GITHUB_REF_NAME }}
42+
repository: ${{ vars.GITHUB_REPOSITORY }}
43+
path: ${{ github.workspace }}/SourceCache/${{ vars.GITHUB_REPOSITORY }}
44+
45+
- uses: microsoft/[email protected]
46+
47+
- name: package
48+
run: |
49+
msbuild -restore ${{ github.workspace }}\SourceCache\${{ vars.GITHUB_REPOSITORY }}\installer-scripts\SwiftFormat.wixproj -nologo -p:Configuration=Release -p:ProductVersion=${{ matrix.tag }} -p:SWIFTFORMAT_BUILD=${{ github.workspace }}\.build\release -p:OutputPath=${{ github.workspace }}\artifacts -p:RunWixToolsOutOfProc=true
50+
51+
# Release
52+
- uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
id: create_release
56+
with:
57+
draft: true
58+
prerelease: true
59+
release_name: SwiftFormat-${{ matrix.tag }}
60+
tag_name: SwiftFormat-${{ matrix.tag }}
61+
- uses: actions/[email protected]
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
asset_content_type: application/octet-stream
66+
asset_name: swiftformat.exe
67+
asset_path: .build\x86_64-unknown-windows-msvc\release\swiftformat.exe
68+
upload_url: ${{ steps.create_release.outputs.upload_url }}
69+
- uses: actions/[email protected]
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
asset_content_type: application/octet-stream
74+
asset_name: SwiftFormat.msi
75+
asset_path: ${{ github.workspace }}\artifacts\SwiftFormat.msi
76+
upload_url: ${{ steps.create_release.outputs.upload_url }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2+
<Package
3+
Language="1033"
4+
Manufacturer="nicklockwood"
5+
Name="SwiftFormat for Windows x86_64"
6+
UpgradeCode="98e01ac8-a17d-43fd-99ed-1cd8b58715bf"
7+
Version="$(var.ProductVersion)"
8+
Scope="perMachine">
9+
<SummaryInformation Description="SwiftFormat for Windows x86_64" />
10+
11+
<!-- NOTE(compnerd) use pre-3.0 schema for better compatibility. -->
12+
<Media Id="1" Cabinet="SwiftFormat.cab" EmbedCab="yes" />
13+
14+
<!-- Directory Structure -->
15+
<!-- WindowsVolume is not a StandardDirectory value, but rather a standard property. See https://github.com/wixtoolset/issues/issues/7314 -->
16+
<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]" />
17+
<Directory ComponentGuidGenerationSeed="7818d7fe-5173-4a41-9809-e72263ea9738" Id="WINDOWSVOLUME">
18+
<Directory Id="INSTALLDIR">
19+
<Directory Id="Library" Name="Library">
20+
<Directory Id="Developer" Name="Developer">
21+
<Directory Id="Tools" Name="Tools">
22+
</Directory>
23+
</Directory>
24+
</Directory>
25+
</Directory>
26+
</Directory>
27+
28+
<!-- Components -->
29+
<ComponentGroup Id="SwiftFormat">
30+
<Component Id="swiftformat.exe" Directory="Tools" Guid="77126634-5f91-40a7-b344-035ce99ef46f">
31+
<File Id="swiftformat.exe" Source="$(var.SWIFTFORMAT_BUILD)\swiftformat.exe" Checksum="yes" />
32+
</Component>
33+
</ComponentGroup>
34+
35+
<Component Id="EnvironmentVariables" Directory="INSTALLDIR" Guid="b46687c3-f836-47e5-9b43-d9fd2552a731">
36+
<Environment Id="Path" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Library\Developer\Tools" />
37+
</Component>
38+
39+
<Feature Id="SwiftFormat" AllowAbsent="no" AllowAdvertise="yes" ConfigurableDirectory="INSTALLDIR" Description="SwiftFormat for Windows x86_64" Level="1" Title="SwiftFormat (Windows x86_64)">
40+
<ComponentGroupRef Id="SwiftFormat" />
41+
<ComponentRef Id="EnvironmentVariables" />
42+
</Feature>
43+
44+
<UI>
45+
<ui:WixUI Id="WixUI_InstallDir" />
46+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2" />
47+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" />
48+
</UI>
49+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
50+
51+
</Package>
52+
</Wix>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2+
<Package
3+
Language="1033"
4+
Manufacturer="nicklockwood"
5+
Name="SwiftFormat for Windows aarch64"
6+
UpgradeCode="12571ad2-06b7-46e0-9e03-209db2b5667d"
7+
Version="$(var.ProductVersion)"
8+
Scope="perMachine">
9+
<SummaryInformation Description="SwiftFormat for Windows aarch64" />
10+
11+
<!-- NOTE(compnerd) use pre-3.0 schema for better compatibility. -->
12+
<Media Id="1" Cabinet="SwiftFormat.cab" EmbedCab="yes" />
13+
14+
<!-- Directory Structure -->
15+
<!-- WindowsVolume is not a StandardDirectory value, but rather a standard property. See https://github.com/wixtoolset/issues/issues/7314 -->
16+
<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]" />
17+
<Directory ComponentGuidGenerationSeed="ae6cd8c6-6eba-46ff-8784-d432fa64367e" Id="WINDOWSVOLUME">
18+
<Directory Id="INSTALLDIR">
19+
<Directory Id="Library" Name="Library">
20+
<Directory Id="Developer" Name="Developer">
21+
<Directory Id="Tools" Name="Tools">
22+
</Directory>
23+
</Directory>
24+
</Directory>
25+
</Directory>
26+
</Directory>
27+
28+
<!-- Components -->
29+
<ComponentGroup Id="SwiftFormat">
30+
<Component Id="swiftformat.exe" Directory="Tools" Guid="2803667e-f043-4bf8-94d6-f3926be39597">
31+
<File Id="swiftformat.exe" Source="$(var.SWIFTFORMAT_BUILD)\swiftformat.exe" Checksum="yes" />
32+
</Component>
33+
</ComponentGroup>
34+
35+
<Component Id="EnvironmentVariables" Directory="INSTALLDIR" Guid="9e402459-cfe7-4476-a084-fc613016b626">
36+
<Environment Id="Path" Action="set" Name="Path" Part="last" Permanent="no" System="yes" Value="[INSTALLDIR]Library\Developer\Tools" />
37+
</Component>
38+
39+
<Feature Id="SwiftFormat" AllowAbsent="no" AllowAdvertise="yes" ConfigurableDirectory="INSTALLDIR" Description="SwiftFormat for Windows aarch64" Level="1" Title="SwiftFormat (Windows aarch64)">
40+
<ComponentGroupRef Id="SwiftFormat" />
41+
<ComponentRef Id="EnvironmentVariables" />
42+
</Feature>
43+
44+
<UI>
45+
<ui:WixUI Id="WixUI_InstallDir" />
46+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2" />
47+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" />
48+
</UI>
49+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"></Property>
50+
51+
</Package>
52+
</Wix>

installer-scripts/SwiftFormat.wixproj

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="WixToolset.Sdk/4.0.0">
2+
<PropertyGroup>
3+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
4+
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<ProductArchitecture Condition=" '$(ProductArchitecture)' == '' ">amd64</ProductArchitecture>
8+
<ProductArchitecture>$(ProductArchitecture)</ProductArchitecture>
9+
10+
<ProductVersion Condition=" '$(ProductVersion)' == '' ">0.0.0</ProductVersion>
11+
<ProductVersion>$(ProductVersion)</ProductVersion>
12+
</PropertyGroup>
13+
14+
<PropertyGroup>
15+
<OutputPath>build\</OutputPath>
16+
<IntermediateOutputPath>build\obj\</IntermediateOutputPath>
17+
</PropertyGroup>
18+
19+
<!-- <Import Project="WiXCodeSigning.targets" /> -->
20+
21+
<PropertyGroup>
22+
<DefineConstants>ProductVersion=$(ProductVersion);SWIFTFORMAT_BUILD=$(SWIFTFORMAT_BUILD)</DefineConstants>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="WixToolset.UI.wixext" Version="4.0.0" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<Compile Include="SwiftFormat-$(ProductArchitecture).wxs" />
31+
</ItemGroup>
32+
</Project>

0 commit comments

Comments
 (0)