Skip to content

Commit 80cab0a

Browse files
committed
Release workflow
Creating workflow to handle any (pre)release. Triggered by pushing a tag starting with the letter 'v'. Also creating a separate powershell script to extract version information from the tag. - Renaming some standard repository text files for consistency and inclusion with the released artifacts. - VS Installer projects only build with the devenv command, so call that specifically for this purpose. - Updating some file references in the Setup project - Call special utility that allows us to run devenv on Setup projects (disable or enable out of process building?) - Try to fix errors building Setup project
1 parent 02e87c9 commit 80cab0a

File tree

5 files changed

+135
-240
lines changed

5 files changed

+135
-240
lines changed

.github/workflows/build-release.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Build solution in Release mode and submit a GitHub release.
2+
3+
name: build-release
4+
5+
on:
6+
push:
7+
tags: "v*"
8+
9+
env:
10+
# The desired name of the no-install archive to be uploaded along side the installer.
11+
ARCHIVE_NAME: "winnut-client"
12+
VS_PATH: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise"
13+
14+
jobs:
15+
build-release:
16+
runs-on: windows-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
# Provide VER and SEMVER env vars.
21+
- name: Extract version from tag
22+
run: ./.github/workflows/get-ver.ps1 ${{ github.ref }}
23+
- name: Build solution in Release configuration
24+
uses: ./.github/actions/build-solution
25+
with:
26+
build-mode: "Release"
27+
version: "${{ env.VER }}"
28+
- name: Prepare no install archive
29+
run: |
30+
$arc = Compress-Archive -PassThru -Path "WinNUT_V2\WinNUT-Client\bin\Release" -DestinationPath "${{ env.ARCHIVE_NAME }}-v${{ env.SEMVER }}.zip"
31+
echo "ARCHIVE_NAME=$arc" >> $env:GITHUB_ENV
32+
# https://stackoverflow.com/questions/8648428/an-error-occurred-while-validating-hresult-8000000a
33+
- name: Fix 'out of process' build error
34+
working-directory: ${{ env.VS_PATH }}
35+
run: Start-Process -Wait -NoNewWindow "${{ env.VS_PATH }}\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\DisableOutOfProcBuild.exe"
36+
# Since MSBuild won't build the Setup project, we need to call devenv directly.
37+
- name: Build Setup Project
38+
run: Start-Process -Wait -NoNewWindow "${{ env.VS_PATH }}\common7\ide\devenv.com" -ArgumentList "WinNUT_V2\WinNUT_V2.sln /Build Release /Project Setup\Setup.vdproj"
39+
- name: Create prerelease
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
draft: true
43+
fail_on_unmatched_files: true
44+
generate_release_notes: true
45+
files: |
46+
WinNUT_V2/Setup/Release/WinNUT-Setup.msi
47+
${{ env.ARCHIVE_NAME }}
48+
LICENSE.txt
49+
README.md
50+
CHANGELOG.md
51+
# - name: Create prerelease
52+
# uses: "marvinpinto/action-automatic-releases@v1.2.1"
53+
# with:
54+
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
55+
# draft: true # Release as draft until I'm more confident
56+
# prerelease: true
57+
# files: |
58+
# WinNUT_V2\Setup\Release\WinNUT-Setup.msi
59+
# ${{ env.ARCHIVE_NAME }}.zip
60+
# LICENSE.txt
61+
# README.md
62+
# CHANGELOG.md

.github/workflows/get-ver.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Verify valid semver, and provide it along with an AssemblyVersion-compatible string as env vars.
2+
3+
# Set to the value provided by github.ref
4+
param([string]$ghRef)
5+
6+
$semVerRegex = "(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
7+
8+
if (!($ghRef -match $semVerRegex)) {
9+
Write-Host "Could not find valid semver within ref. string. Given: $ghRef"
10+
Exit 1
11+
}
12+
13+
$verRes = "VER={0}.{1}.{2}" -f $matches.major, $matches.minor, $matches.patch
14+
$semVerRes = "SEMVER=" + $ghRef.Substring(10)
15+
16+
echo $verRes >> $env:GITHUB_ENV
17+
echo $semVerRes >> $env:GITHUB_ENV
18+
Write-Host "Result: $verRes, $semVerRes"
File renamed without changes.

COPYING renamed to LICENSE.txt

File renamed without changes.

0 commit comments

Comments
 (0)