Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit c79029d

Browse files
authored
build: add a GHA step for packaging swift-doc on Windows (#280)
This adds a GitHub Action step to package swift-doc for Windows for easy distribution. It installs to `[WindowsVolume]\Library\Developer\SwiftDoc` by default. This is currently not configurable, though it likely should be. However, this is the simplest configuration possible and co-locates the swift-doc package with the location of the Swift toolchain on Windows. Update the publish CI job to build the MSI and upload the asset as a release artifact.
1 parent 0b98f22 commit c79029d

File tree

4 files changed

+178
-4
lines changed

4 files changed

+178
-4
lines changed

.github/workflows/ci.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,21 @@ jobs:
9494
windows:
9595
runs-on: windows-latest
9696

97-
name: "Windows (Swift 5.5)"
97+
name: "Windows (Swift ${{ matrix.tag }})"
98+
99+
strategy:
100+
matrix:
101+
include:
102+
- tag: 5.5-DEVELOPMENT-SNAPSHOT-2021-05-09-a
103+
branch: swift-5.5-branch
98104

99105
steps:
100106
- uses: actions/checkout@v2
101107
- uses: seanmiddleditch/gha-setup-vsdevenv@master
102108

103-
- name: Install swift-5.5 (2021-04-19 SNAPSHOT)
109+
- name: Install Swift ${{ matrix.tag }}
104110
run: |
105-
Install-Binary -Url "https://swift.org/builds/swift-5.5-branch/windows10/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-04-19-a/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-04-19-a-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
111+
Install-Binary -Url "https://swift.org/builds/${{ matrix.branch }}/windows10/swift-${{ matrix.tag }}/swift-${{ matrix.tag }}-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
106112
- name: Set Environment Variables
107113
run: |
108114
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
@@ -126,7 +132,7 @@ jobs:
126132
# TODO(compnerd) figure out how to build graphviz
127133
- name: Fetch graphviz
128134
run: |
129-
Invoke-WebRequest -Uri "https://artprodeus21.artifacts.visualstudio.com/A8fd008a0-56bc-482c-ba46-67f9425510be/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbXBuZXJkL3Byb2plY3RJZC8zMTMzZDZhYi04MGE4LTQ5OTYtYWM0Zi0wM2RmMjVjZDMyMjQvYnVpbGRJZC81MDQ4NS9hcnRpZmFjdE5hbWUvZ3JhcGh2aXotd2luZG93cy14NjQ1/content?format=zip" -OutFile $env:Temp\graphviz-windows-x64.zip
135+
Invoke-WebRequest -Uri "https://artprodeus21.artifacts.visualstudio.com/A8fd008a0-56bc-482c-ba46-67f9425510be/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbXBuZXJkL3Byb2plY3RJZC8zMTMzZDZhYi04MGE4LTQ5OTYtYWM0Zi0wM2RmMjVjZDMyMjQvYnVpbGRJZC81MTAzNC9hcnRpZmFjdE5hbWUvZ3JhcGh2aXotd2luZG93cy14NjQ1/content?format=zip" -OutFile $env:Temp\graphviz-windows-x64.zip
130136
Expand-Archive -Path $env:Temp\graphviz-windows-x64.zip -Destination $env:Temp -Force
131137
Move-Item -Path $env:Temp\graphviz-windows-x64\Library\graphviz-development -Destination C:\Library\ -Force
132138
- name: Add graphviz to PATH
@@ -136,6 +142,15 @@ jobs:
136142
run: |
137143
swift build -v -c release -Xlinker -LC:\Library\graphviz-development\usr\lib -Xcc -DLIBXML_STATIC -Xcc -IC:\Library\libxml2-development\usr\include -Xcc -IC:\Library\libxml2-development\usr\include\libxml2 -Xlinker -LC:\Library\libxml2-development\usr\lib -Xcc -IC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\include -Xlinker -LC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib
138144
145+
- name: Package
146+
run: |
147+
msbuild WiX/swift-doc.wixproj -nologo -p:Configuration=Release -p:OutputPath=$PWD\.build\artifacts -p:RunWixToolsOutOfProc=true -p:GRAPHVIZ_ROOT=C:\Library\graphviz-development -p:SWIFT_DOC_BUILD=$PWD\.build\release # -p:ProductVersion=$env:GITHUB_REF.Replace('refs/tags/', '')
148+
149+
- uses: actions/upload-artifact@v2
150+
with:
151+
name: swift-doc.msi
152+
path: .build\artifacts\swift-doc.msi
153+
139154
validate-assets:
140155
runs-on: ubuntu-latest
141156

.github/workflows/publish.yml

+59
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,65 @@ jobs:
7676
env:
7777
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
7878

79+
windows_msi:
80+
name: Build swift-doc.msi
81+
runs-on: windows-latest
82+
strategy:
83+
matrix:
84+
include:
85+
- tag: 5.5-DEVELOPMENT-SNAPSHOT-2021-05-09-a
86+
branch: swift-5.5-branch
87+
steps:
88+
- uses: actions/checkout@v2
89+
- uses: seanmiddleditch/gha-setup-vsdevenv@master
90+
91+
- name: Install Swift ${{ matrix.tag }}
92+
run: |
93+
Install-Binary -Url "https://swift.org/builds/${{ matrix.branch }}/windows10/swift-${{ matrix.tag }}/swift-${{ matrix.tag }}-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
94+
- name: Set Environment Variables
95+
run: |
96+
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
97+
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
98+
- name: Adjust Paths
99+
run: |
100+
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
101+
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
102+
- name: Install Supporting Files
103+
run: |
104+
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
105+
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
106+
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
107+
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
108+
109+
- name: Fetch libxml2
110+
run: |
111+
Invoke-WebRequest -Uri "https://artprodeus21.artifacts.visualstudio.com/A8fd008a0-56bc-482c-ba46-67f9425510be/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbXBuZXJkL3Byb2plY3RJZC8zMTMzZDZhYi04MGE4LTQ5OTYtYWM0Zi0wM2RmMjVjZDMyMjQvYnVpbGRJZC8zNTI5NS9hcnRpZmFjdE5hbWUveG1sMi13aW5kb3dzLXg2NA2/content?format=zip" -OutFile $env:Temp\xml-windows-x64.zip
112+
Expand-Archive -Path $env:Temp\xml-windows-x64.zip -DestinationPath $env:Temp -Force
113+
Move-Item -Path $env:Temp\xml2-windows-x64\Library\libxml2-development -Destination C:\Library\ -Force
114+
- name: Fetch graphviz
115+
run: |
116+
Invoke-WebRequest -Uri "https://artprodeus21.artifacts.visualstudio.com/A8fd008a0-56bc-482c-ba46-67f9425510be/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbXBuZXJkL3Byb2plY3RJZC8zMTMzZDZhYi04MGE4LTQ5OTYtYWM0Zi0wM2RmMjVjZDMyMjQvYnVpbGRJZC81MTAzNC9hcnRpZmFjdE5hbWUvZ3JhcGh2aXotd2luZG93cy14NjQ1/content?format=zip" -OutFile $env:Temp\graphviz-windows-x64.zip
117+
Expand-Archive -Path $env:Temp\graphviz-windows-x64.zip -Destination $env:Temp -Force
118+
Move-Item -Path $env:Temp\graphviz-windows-x64\Library\graphviz-development -Destination C:\Library\ -Force
119+
120+
- name: Build
121+
run: |
122+
swift build -c release -Xlinker -LC:\Library\graphviz-development\usr\lib -Xcc -DLIBXML_STATIC -Xcc -IC:\Library\libxml2-development\usr\include -Xcc -IC:\Library\libxml2-development\usr\include\libxml2 -Xlinker -LC:\Library\libxml2-development\usr\lib -Xcc -IC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\include -Xlinker -LC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib
123+
124+
- name: Package
125+
run: |
126+
msbuild WiX/swift-doc.wixproj -nologo -p:Configuration=Release -p:OutputPath=$PWD\.build\artifacts -p:RunWixToolsOutOfProc=true -p:GRAPHVIZ_ROOT=C:\Library\graphviz-development -p:SWIFT_DOC_BUILD=$PWD\.build\release -p:ProductVersion=$env:GITHUB_REF.Replace('refs/tags/', '')
127+
128+
- name: Upload the installer to the GitHub release
129+
uses: actions/[email protected]
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
with:
133+
upload_url: ${{ github.event.release.upload_url }}
134+
asset_path: .build\artifacts\swift-doc.msi
135+
asset_name: swift-doc.msi
136+
asset_content_type: application/octet-stream
137+
79138
docker:
80139
name: Build and push Docker container
81140

WiX/swift-doc.wixproj

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<OutputName>swift-doc</OutputName>
9+
<OutputType>Package</OutputType>
10+
<ProjectGuid>d45046f0-1d8d-4521-bb45-17809bacf693</ProjectGuid>
11+
<SchemaVersion>2.0</SchemaVersion>
12+
</PropertyGroup>
13+
14+
<PropertyGroup>
15+
<OutputPath>.build\artifacts\</OutputPath>
16+
<IntermediateOutputPath>.build\obj\</IntermediateOutputPath>
17+
<DefineSolutionProperties>false</DefineSolutionProperties>
18+
</PropertyGroup>
19+
20+
<PropertyGroup>
21+
<ProductVersion Condition=" '$(ProductVersion)' == '' ">0.0.0</ProductVersion>
22+
<ProductVersion>$(ProductVersion)</ProductVersion>
23+
<DefineConstants>ProductVersion=$(ProductVersion);SWIFT_DOC_BUILD=$(SWIFT_DOC_BUILD);GRAPHVIZ_ROOT=$(GRAPHVIZ_ROOT)</DefineConstants>
24+
</PropertyGroup>
25+
26+
<Import Project="$(WixTargetsPath)" />
27+
<ItemGroup>
28+
<Compile Include="swift-doc.wxs" />
29+
</ItemGroup>
30+
</Project>

WiX/swift-doc.wxs

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<Product Id="*"
4+
Language="1033"
5+
Manufacturer="swiftdoc.org"
6+
Name="swift-doc"
7+
UpgradeCode="1a733d92-1f0f-4d76-9737-72c698a207cd"
8+
Version="$(var.ProductVersion)">
9+
<Package Compressed="yes" InstallScope="perMachine" Manufacturer="swiftdoc.org"/>
10+
11+
<Media Id="1" Cabinet="swiftdoc.cab" CompressionLevel="high" EmbedCab="yes"/>
12+
13+
<Directory Id="TARGETDIR" Name="SourceDir">
14+
<Directory Id="WINDOWSVOLUME">
15+
<Directory Id="LIBRARY" Name="Library">
16+
<Directory Id="DEVELOPER" Name="Developer">
17+
<Directory Id="SWIFT_DOC" Name="SwiftDoc">
18+
<Directory Id="USR" Name="usr">
19+
<Directory Id="USR_BIN" Name="bin">
20+
</Directory>
21+
</Directory>
22+
</Directory>
23+
</Directory>
24+
</Directory>
25+
</Directory>
26+
</Directory>
27+
28+
<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]"/>
29+
30+
<DirectoryRef Id="USR_BIN">
31+
<Component Id="SwiftDoc_BINS" Guid="6ae448ac-e535-4dd6-984a-b32ce99bcd84">
32+
<File Id="SWIFT_DOC_EXE" Source="$(var.SWIFT_DOC_BUILD)\swift-doc.exe" Checksum="yes"/>
33+
34+
<!-- GraphViz -->
35+
<File Id="CGRAPH_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\cgraph.dll" Checksum="yes"/>
36+
<File Id="GVC_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\gvc.dll" Checksum="yes"/>
37+
<File Id="CDT_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\cdt.dll" Checksum="yes"/>
38+
<File Id="PATHPLAN_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\Pathplan.dll" Checksum="yes"/>
39+
<File Id="XDOT_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\xdot.dll" Checksum="yes"/>
40+
<File Id="EXPAT_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\expat.dll" Checksum="yes"/>
41+
<File Id="DOT_EXE" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\dot.exe" Checksum="yes"/>
42+
43+
<!-- Plugins -->
44+
<File Id="GVPLUGIN_CORE_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\gvplugin_core.dll" Checksum="yes"/>
45+
<File Id="GVPLUGIN_DOT_LAYOUT_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\gvplugin_dot_layout.dll" Checksum="yes"/>
46+
<File Id="GVPLUGIN_GDIPLUS_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\gvplugin_gdiplus.dll" Checksum="yes"/>
47+
<File Id="GVPLUGIN_NEATO_LAYOUT_DLL" Source="$(var.GRAPHVIZ_ROOT)\usr\bin\gvplugin_neato_layout.dll" Checksum="yes"/>
48+
</Component>
49+
</DirectoryRef>
50+
51+
<DirectoryRef Id="TARGETDIR">
52+
<Component Id="ENV_VARS" Guid="e02268ca-0ea1-421e-9c19-d1ba23dcff4e">
53+
<Environment Id="PATH" Action="set" Name="PATH" Part="last" Permanent="no" System="yes" Value="[WindowsVolume]Library\Developer\SwiftDoc\usr\bin"/>
54+
</Component>
55+
</DirectoryRef>
56+
57+
<Feature Id="SwiftDoc" Level="1">
58+
<ComponentRef Id="SwiftDoc_BINS"/>
59+
<ComponentRef Id="ENV_VARS"/>
60+
</Feature>
61+
62+
<InstallExecuteSequence>
63+
<Custom Action="CreateDotConfig" After="InstallFiles">NOT REMOVE</Custom>
64+
<Custom Action="CleanupDotConfig" Before="RemoveFiles">REMOVE="ALL"</Custom>
65+
</InstallExecuteSequence>
66+
67+
<CustomAction Id="CreateDotConfig" Directory="USR_BIN" Execute="deferred" Impersonate="no" ExeCommand="cmd /c &quot;dot -c&quot;" Return="check"/>
68+
<CustomAction Id="CleanupDotConfig" Directory="USR_BIN" Execute="deferred" Impersonate="no" ExeCommand="cmd /c &quot;del config6&quot;" Return="ignore"/>
69+
</Product>
70+
</Wix>

0 commit comments

Comments
 (0)