Skip to content

Commit 2bb88dc

Browse files
authored
Add Windows CI for GHA (build-test-installer-release) (#251)
* Add Windows GitHub Actions workflow - build-test-installer-release * remove teamcity references
1 parent da4ae62 commit 2bb88dc

File tree

2 files changed

+151
-29
lines changed

2 files changed

+151
-29
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build Test Installer Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- 'v*'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
env:
19+
Configuration: Release
20+
21+
jobs:
22+
build_test:
23+
name: Build and test
24+
runs-on: windows-latest
25+
outputs:
26+
version: ${{ steps.compute_version.outputs.version }}
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v5
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Compute version
35+
id: compute_version
36+
shell: pwsh
37+
env:
38+
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }}
39+
REF_NAME: ${{ github.ref_name }}
40+
HEAD_COMMIT_TIMESTAMP: ${{ github.event.head_commit && github.event.head_commit.timestamp || '' }}
41+
GITHUB_SHA: ${{ github.sha }}
42+
run: |
43+
if ($env:IS_TAG -eq 'true') {
44+
$version = $env:REF_NAME
45+
} elseif (-not [string]::IsNullOrEmpty($env:HEAD_COMMIT_TIMESTAMP)) {
46+
$timestamp = [DateTime]::Parse($env:HEAD_COMMIT_TIMESTAMP).ToUniversalTime().ToString("yyyyMMddHHmm")
47+
$version = "$timestamp-$($env:GITHUB_SHA)"
48+
} else {
49+
$timestamp = [DateTime]::UtcNow.ToString("yyyyMMddHHmm")
50+
$version = "$timestamp-$($env:GITHUB_SHA)"
51+
}
52+
53+
"Version=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
54+
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
55+
56+
- name: Setup NuGet
57+
uses: NuGet/setup-nuget@v2
58+
59+
- name: Restore NuGet packages
60+
run: nuget restore SayMore.sln
61+
62+
- name: Setup MSBuild
63+
uses: microsoft/setup-msbuild@v2
64+
with:
65+
vs-version: '[17.0,18.0)'
66+
67+
- name: Build solution
68+
run: msbuild build\SayMore.proj /t:Build /p:Configuration=$env:Configuration /p:Version=$env:Version /m
69+
70+
- name: Run tests
71+
run: msbuild build\SayMore.proj /t:Test /p:Configuration=$env:Configuration /p:excludedCategories=SkipOnTeamCity /m
72+
73+
- name: Upload test results
74+
if: always()
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: saymore-test-results
78+
if-no-files-found: warn
79+
path: output/${{ env.Configuration }}/TestResults.xml
80+
81+
build_installer:
82+
name: Build installer, sign, and publish artifacts
83+
needs: build_test
84+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))) }}
85+
runs-on: windows-latest
86+
env:
87+
Version: ${{ needs.build_test.outputs.version }}
88+
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v5
92+
with:
93+
fetch-depth: 0
94+
95+
- name: Setup NuGet
96+
uses: NuGet/setup-nuget@v2
97+
98+
- name: Restore NuGet packages
99+
run: nuget restore SayMore.sln
100+
101+
- name: Fetch documentation artifacts
102+
shell: bash
103+
run: build/getDependencies-windows.sh
104+
105+
- name: Setup MSBuild
106+
uses: microsoft/setup-msbuild@v2
107+
with:
108+
vs-version: '[17.0,18.0)'
109+
110+
- name: Build installer
111+
run: msbuild build\SayMore.proj /t:Installer /p:Configuration=$env:Configuration /p:useNUnit-x86=true /p:Version=$env:Version /m
112+
113+
- name: Sign installer
114+
if: ${{ github.event_name != 'pull_request' }}
115+
uses: sillsdev/codesign/trusted-signing-action@v3
116+
with:
117+
credentials: ${{ secrets.TRUSTED_SIGNING_CREDENTIALS }}
118+
files-folder: output/installer
119+
files-folder-filter: SayMoreInstaller*.msi
120+
121+
- name: Upload installer artifacts
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: saymore-installer
125+
if-no-files-found: error
126+
path: |
127+
output/installer/SayMoreInstaller*.msi
128+
output/installer/*.download_info
129+
output/installer/appcast.xml
130+
output/releasenotes.download_info
131+
132+
- name: Create release
133+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
files: |
137+
output/installer/SayMoreInstaller*.msi
138+
output/installer/*.download_info
139+
output/installer/appcast.xml
140+
output/releasenotes.download_info
141+
draft: false
142+
generate_release_notes: true

build/SayMore.proj

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<RootDir Condition="'$(teamcity_version)' == ''">$(MSBuildProjectDirectory)\..</RootDir>
4-
<RootDir Condition="'$(teamcity_version)' != ''">$(teamcity_build_checkoutDir)</RootDir>
5-
<BUILD_NUMBER Condition="'$(BUILD_NUMBER)'==''">3.7.100</BUILD_NUMBER>
3+
<RootDir>$(MSBuildProjectDirectory)\..</RootDir>
4+
<RootDir Condition="'$(GITHUB_WORKSPACE)' != ''">$(GITHUB_WORKSPACE)</RootDir>
65
<BuildTasksDll Condition="Exists('$(RootDir)/packages/SIL.BuildTasks.3.1.1/tools/SIL.BuildTasks.dll')">$(RootDir)/packages/SIL.BuildTasks.3.1.1/tools/SIL.BuildTasks.dll</BuildTasksDll>
76
<BuildTasksDll Condition="!Exists('$(RootDir)/packages/SIL.BuildTasks.3.1.1/tools/SIL.BuildTasks.dll')">$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll</BuildTasksDll>
87
<SILReleaseTasksProps>$(RootDir)/packages/SIL.ReleaseTasks.3.1.1/build/SIL.ReleaseTasks.props</SILReleaseTasksProps>
@@ -20,7 +19,6 @@
2019
<Exec Command='$(NuGetCommand) install SIL.BuildTasks -excludeVersion -PreRelease -source "$(PackageSources)" -solutionDirectory "$(SolutionDir)."' />
2120
<Exec Command='$(NuGetCommand) install SIL.ReleaseTasks -excludeVersion -PreRelease -source "$(PackageSources)" -solutionDirectory "$(SolutionDir)"' />
2221
<Exec Command='$(NuGetCommand) install SIL.libpalaso.l10ns -excludeVersion -PreRelease -source "$(PackageSources)" -solutionDirectory "$(SolutionDir)."' />
23-
<Exec Command='$(NuGetCommand) install NUnit.Extension.TeamCityEventListener -excludeVersion -source "$(PackageSources)" -solutionDirectory "$(SolutionDir)."' />
2422
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="BuildInternal"
2523
Properties="Configuration=$(Configuration)" Condition="$(RestartBuild)" />
2624
</Target>
@@ -33,20 +31,12 @@
3331
<UsingTask TaskName="NUnit3" AssemblyFile="$(BuildTasksDll)" Condition="Exists('$(BuildTasksDll)')" />
3432

3533
<Target Name="VersionNumbers">
36-
<Message Text="BUILD_NUMBER: $(BUILD_NUMBER)" Importance="high"/>
34+
<PropertyGroup>
35+
<!-- The Version should be set from the outside, if not, set a default value -->
36+
<Version Condition="'$(Version)' == ''">$([System.DateTime]::Now.ToString("yyyyMMddHHmmss"))</Version>
37+
</PropertyGroup>
3738

38-
<Split Input="$(BUILD_NUMBER)" Delimiter="." OutputSubString="2">
39-
<Output TaskParameter="ReturnValue" PropertyName="BuildCounter" />
40-
</Split>
41-
42-
<Message Text="BuildCounter: $(BuildCounter)" Importance="high"/>
43-
44-
<!-- Note, after some thought, we've decided this is the best place to keep the version number (not on TeamCity, not in the assemblies). -->
45-
<CreateProperty Value="3.7.$(BuildCounter)">
46-
<Output PropertyName="Version" TaskParameter="Value"/>
47-
</CreateProperty>
48-
49-
<Message Text="Version: $(Version)" Importance="high"/>
39+
<Message Text="Version: $(Version)" Importance="high"/>
5040
</Target>
5141

5242
<Import Project="$(SILReleaseTasksProps)" Condition="Exists('$(SILReleaseTasksProps)')" />
@@ -84,7 +74,7 @@
8474
<ItemGroup>
8575
<TestAssemblies Include="$(RootDir)/output/release/*Tests.dll;"/>
8676
</ItemGroup>
87-
<NUnit3 Condition="'$(teamcity_version)' == ''"
77+
<NUnit3
8878
Assemblies="@(TestAssemblies)"
8979
ToolPath="$(RootDir)/packages/NUnit.ConsoleRunner.3.20.1/tools"
9080
ExcludeCategory="$(excludedCategories)"
@@ -94,15 +84,7 @@
9484
OutputXmlFile="$(RootDir)/output/$(Configuration)/TestResults.xml"
9585
UseNUnit3Xml = "true"
9686
TeamCity="false"/>
97-
<NUnit3 Condition="'$(teamcity_version)' != ''"
98-
Assemblies="@(TestAssemblies)"
99-
ToolPath="$(RootDir)/packages/NUnit.ConsoleRunner.3.20.1/tools"
100-
ExcludeCategory="SkipOnTeamCity,$(excludedCategories)"
101-
WorkingDirectory="$(RootDir)/output/$(Configuration)"
102-
Force32Bit="$(useNUnit-x86)"
103-
Verbose="true"
104-
TeamCity="true"/>
105-
</Target>
87+
</Target>
10688

10789
<Target Name="UpdateDownloadInfo" DependsOnTargets="VersionNumbers" >
10890

@@ -158,8 +140,6 @@
158140
<!-- remove an existing one with the same name, if necessary -->
159141
<Delete Files="$(RootDir)\output\installer\SayMoreInstaller.$(Version).msi" TreatErrorsAsWarnings="false" />
160142

161-
<Exec Command='sign /d "SayMoreInstaller.$(Version).msi" "$(RootDir)\output\installer\SayMoreInstaller.msi"'></Exec>
162-
163143
<Copy SourceFiles="$(RootDir)\output\installer\SayMoreInstaller.msi"
164144
DestinationFiles="$(RootDir)\output\installer\SayMoreInstaller.$(Version).msi"
165145
/>

0 commit comments

Comments
 (0)