Skip to content

Commit

Permalink
Remove action, release build tweaks
Browse files Browse the repository at this point in the history
- Upgrade action versions
- Ported over get-ver.ps1 changes from AGauge repository
- Release build workflow selects solution configuration based on result from get-ver
- Simplified msbuild command
  • Loading branch information
gbakeman committed Aug 12, 2024
1 parent 714ed5c commit 86c4024
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 67 deletions.
44 changes: 0 additions & 44 deletions .github/actions/build-solution/action.yaml

This file was deleted.

54 changes: 37 additions & 17 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ on:

env:
# The desired name of the no-install archive to be uploaded along side the installer.
ARCHIVE_NAME: "winnut-client-noinstall"
VS_PATH: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise"
ARCHIVE_NAME: "_WinNUT-Client-NoInstall"

jobs:
build-release:
Expand All @@ -20,26 +19,39 @@ jobs:
git config --global url."https://user:${{ secrets.GITHUB_TOKEN }}@github".insteadOf https://github
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Checkout code
uses: actions/checkout@v3
# Provide VER and SEMVER env vars.
uses: actions/checkout@v4

- name: Extract version from tag
id: get-ver
run: ./.github/workflows/get-ver.ps1 ${{ github.ref }}

- name: Confirm Build mode
id: build-mode
run: >
if ($${{ steps.get-ver.outputs.ISPRERELEASE }})
{ echo "BUILD_MODE=PreRelease" >> $env:GITHUB_OUTPUT }
else { echo "BUILD_MODE=Release" >> $env:GITHUB_OUTPUT }
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2

- name: Build solution
working-directory: WinNUT_V2
run: >
msbuild -target:"restore;publish"
-property:Configuration="Release"
-property:Version="${{ env.VER }}"
-property:ApplicationVersion="${{ env.VER }}.0"
-property:PublishDir="./publish"
msbuild -t:"publish" -restore
-p:Configuration="${{ steps.build-mode.outputs.BUILD_MODE }}"
-p:Version="${{ steps.get-ver.outputs.VER }}"
-p:ApplicationVersion="${{ steps.get-ver.outputs.VER }}.0"
-p:PublishDir="./publish"
- name: Checkout pages branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: "gh-pages"
path: "gh-pages"

- name: Prep ClickOnce branch and deploy
working-directory: gh-pages
run: |
Expand All @@ -60,20 +72,28 @@ jobs:
git commit -m "Update to ${{ env.SEMVER }}"
# Push.
git push
- name: Prepare no install archive
run: |
$arc = Compress-Archive -PassThru -Path "WinNUT_V2\WinNUT-Client\bin\Release" -DestinationPath "${{ env.ARCHIVE_NAME }}-${{ env.SEMVER }}.zip"
$arc = Compress-Archive -PassThru -Path "WinNUT_V2\WinNUT-Client\bin\${{ steps.build-mode.outputs.BUILD_MODE }}" -DestinationPath "${{ env.ARCHIVE_NAME }}-${{ steps.get-ver.outputs.SEMVER }}.zip"
$arc = $arc -replace '\\','/'
echo "ARCHIVE_NAME=$arc" >> $env:GITHUB_ENV
# Rename the CO bootstrapper file to appear after the MSI once it's uploaded.
- name: HACK - Rename ClickOnce bootstrapper
run: Rename-Item -Path "./WinNUT_V2/WinNUT-Client/publish/WinNUT-Client.application" -NewName "_WinNUT-Client-ClickOnce-Installer.application"

- name: Create GitHub release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
draft: true
fail_on_unmatched_files: true
generate_release_notes: true
files: |
WinNUT_V2/WinNUT-Client/publish/WinNUT-Client.application
WinNUT_V2/WinNUT-Client/publish/_WinNUT-Client-ClickOnce-Installer.application
${{ env.ARCHIVE_NAME }}
LICENSE.txt
README.md
CHANGELOG.md
# Leave out other files until we no longer need the MSI be first in the assets list.
# LICENSE.txt
# README.md
# CHANGELOG.md
16 changes: 10 additions & 6 deletions .github/workflows/get-ver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
param([string]$ghRef)

$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-]+)*))?$"
$matchInfo = [regex]::Match($ghRef, $semVerRegex)

if (!($ghRef -match $semVerRegex)) {
if (!($matchInfo.Success)) {
Write-Host "Could not find valid semver within ref. string. Given: $ghRef"
Exit 1
}

$verRes = "VER={0}.{1}.{2}" -f $matches.major, $matches.minor, $matches.patch
$semVerRes = "SEMVER=" + $ghRef.Substring(10)
$verRes = "VER={0}.{1}.{2}" -f $matchInfo.Groups["major"], $matchInfo.Groups["minor"], $matchInfo.Groups["patch"]
$semVerRes = "SEMVER=" + $matchInfo.Value
$isPr = "ISPRERELEASE=" + $matchInfo.Groups.ContainsKey("prerelease").ToString().ToLower()

echo $verRes >> $env:GITHUB_ENV
echo $semVerRes >> $env:GITHUB_ENV
Write-Host "Result: $verRes, $semVerRes"
echo $verRes >> $env:GITHUB_OUTPUT
echo $semVerRes >> $env:GITHUB_OUTPUT
echo $isPr >> $env:GITHUB_OUTPUT

Write-Host "Result: $verRes, $semVerRes, $isPr"

0 comments on commit 86c4024

Please sign in to comment.