Skip to content

Commit

Permalink
Build Windows Installer in Pipeline (#10)
Browse files Browse the repository at this point in the history
* Build scripts from any directory

* Use x-plat directory separator

* Add missing directory separator

* Avoid using double dots for parent directory

* Build only on Windows

* Remove trailing separator from root path

* Use correct coverage output path

* Revert "Build only on Windows"

This reverts commit f5e2e80.

* Simplify path resolution

* Build Windows installer

* Build MSI on builds of main or a pull request

* Set tag

* Fix call to GitVersion

* Output full GitVersion details

* Code quality: don't use Debug-Host

* Revert "Output full GitVersion details"

This reverts commit 19315b4.

* Build on pushes to branches

* Always build MSI & don't set tag for pull requests

* Build on pushes to main or pull request

* Always tag only on pushes to main

* Always build MSI

* Improve script formatting

* Build on pushes to all branches

* Fix typo +semver: feature

* Show when workflow is initiated due to a tag push

* Tighten up tag condition
  • Loading branch information
elzik authored Oct 22, 2023
1 parent 45007fd commit 29e35c7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:
branches:
- '*'
[push, pull_request]

jobs:
build:
Expand All @@ -28,12 +23,24 @@ jobs:
- name: Build & Test
run: ./Build/build-and-test.ps1
shell: pwsh
- name: Upoload Coverage Badge
- name: Upload Coverage Badge
if: github.event_name != 'pull_request' && matrix.os == 'windows-latest'
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.CODE_COVERAGE_AUTH_TOKEN }}
gist_id: 527882e89a938dc78f61a08c300edec4
gist_description: "code-coverage-${{ github.ref_name }}"
gist_file_name: fmsync-code-coverage-${{ github.ref_name }}.svg
file_path: tests/TestResults/badge_shieldsio_linecoverage_green.svg
file_path: tests/TestResults/badge_shieldsio_linecoverage_green.svg
- name: Build Windows Installer
if: matrix.os == 'windows-latest'
run: ./Build/build-windows-installer.ps1
shell: pwsh
- name: Tag With SemVer
if: github.ref_name == 'main'
run: ./Build/tag-with-semver.ps1
shell: pwsh
- name: Debug Output
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: Write-Output 'This was a tag push!'
shell: pwsh
12 changes: 8 additions & 4 deletions Build/build-and-test.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
dotnet test `
$ErrorActionPreference = "Stop"

$repoRootPath = (Resolve-Path "$PSScriptRoot/../").Path

dotnet test $repoRootPath/Elzik.FmSync.sln `
-c Release `
--verbosity normal `
-p:CollectCoverage=true `
Expand All @@ -10,6 +14,6 @@ dotnet tool update `
--version 5.1.8

reportgenerator `
"-reports:tests/Elzik.FmSync.Application.Tests.Unit/TestResults/coverage.opencover.xml;tests/Elzik.FmSync.Infrastructure.Tests.Integration/TestResults/coverage.opencover.xml;" `
"-targetdir:tests/TestResults" `
"-reporttypes:Badges"
"-reports:$repoRootPath/tests/Elzik.FmSync.Application.Tests.Unit/TestResults/coverage.opencover.xml;$repoRootPath/tests/Elzik.FmSync.Infrastructure.Tests.Integration/TestResults/coverage.opencover.xml;" `
"-targetdir:$repoRootPath/tests/TestResults" `
"-reporttypes:Badges"
10 changes: 7 additions & 3 deletions Build/build-windows-installer.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
dotnet publish $PSScriptRoot\..\src\Elzik.FmSync.Worker\Elzik.FmSync.Worker.csproj `
$ErrorActionPreference = "Stop"

$repoRootPath = (Resolve-Path "$PSScriptRoot/../").Path

dotnet publish $repoRootPath\src\Elzik.FmSync.Worker\Elzik.FmSync.Worker.csproj `
--runtime win-x64 `
--self-contained true `
--configuration Release `
-p:Platform=x64 `
-p:PublishSingleFile=true

dotnet publish $PSScriptRoot\..\src\Elzik.FmSync.Console\Elzik.FmSync.Console.csproj `
dotnet publish $repoRootPath\src\Elzik.FmSync.Console\Elzik.FmSync.Console.csproj `
--runtime win-x64 `
--self-contained true `
--configuration Release `
-p:Platform=x64 `
-p:PublishSingleFile=true

dotnet build $PSScriptRoot\..\Installer\Elzik.FmSync.WindowsInstaller\Elzik.FmSync.WindowsInstaller.wixproj `
dotnet build $repoRootPath\Installer\Elzik.FmSync.WindowsInstaller\Elzik.FmSync.WindowsInstaller.wixproj `
--runtime win-x64 `
--self-contained true `
--configuration Release `
Expand Down
4 changes: 2 additions & 2 deletions Build/local-pipeline.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ErrorActionPreference = "Stop"

& Build/build-and-test.ps1
& Build/build-windows-installer.ps1
& $PSScriptRoot/build-and-test.ps1
& $PSScriptRoot/build-windows-installer.ps1
9 changes: 9 additions & 0 deletions Build/tag-with-semver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dotnet tool update --global GitVersion.Tool

$semVer = (dotnet-gitversion | ConvertFrom-Json).SemVer
$tag = "v$semVer"

git tag $tag -f
git push --tags

Write-Output "Tagged with $tag"

0 comments on commit 29e35c7

Please sign in to comment.