Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClickOnce Build Workflow #180

Merged
merged 17 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build-debug

on:
workflow_dispatch:
pull_request:
branches: dev-*
paths:
- '**.vb'
- '**.vbproj'

jobs:
build-debug:
runs-on: windows-latest
steps:
- name: "Get Short SHA"
run: echo "SHORT_SHA=$("${{ github.sha }}".SubString(0, 8))" >> $env:GITHUB_ENV

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Checkout Code
uses: actions/checkout@v4

# msbuild cannot handle .vdproj Installer projects, so only build debug for now.
- name: Build solution
run: msbuild -t:build -restore -p:Configuration=Debug WinNUT_V2/WinNUT_V2.sln

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ format('WinNUT-Client-debugbuild-{0}', env.SHORT_SHA) }}
if-no-files-found: error
path: WinNUT_V2/WinNUT-Client/bin/Debug
99 changes: 99 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Build solution in Release mode and submit a GitHub release.

name: build-release

on:
push:
tags: "v*"

env:
# The desired name of the no-install archive to be uploaded along side the installer.
ARCHIVE_NAME: "_WinNUT-Client-NoInstall"

jobs:
build-release:
runs-on: windows-latest
steps:
- name: Setup Git
run: |
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 github-actions@github.com

- name: Checkout code
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@v2

- name: Build solution
working-directory: WinNUT_V2
run: >
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@v4
with:
ref: "gh-pages"
path: "gh-pages"

- name: Prep ClickOnce branch and deploy
working-directory: gh-pages
run: |
$outDir = "WinNUT_V2/WinNUT-Client/publish"
Write-Output "Removing previous files..."
if (Test-Path "Application Files") {
Remove-Item -Path "Application Files" -Recurse
}
if (Test-Path "WinNUT-Client.application") {
Remove-Item -Path "WinNUT-Client.application"
}
Write-Output "Copying new files..."
Copy-Item -Path "../$outDir/Application Files","../$outDir/WinNUT-Client.application" -Destination . -Recurse
# Stage and commit.
Write-Output "Staging..."
git add -A
Write-Output "Committing..."
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\${{ 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@v2
with:
draft: true
fail_on_unmatched_files: true
generate_release_notes: true
files: |
WinNUT_V2/WinNUT-Client/publish/_WinNUT-Client-ClickOnce-Installer.application
${{ env.ARCHIVE_NAME }}

# Leave out other files until we no longer need the MSI be first in the assets list.
# LICENSE.txt
# README.md
# CHANGELOG.md
25 changes: 25 additions & 0 deletions .github/workflows/build-translation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build-translation

on:
workflow_dispatch:

pull_request:
branches: Dev-2.2
paths:
- "**.xlf"

jobs:
build-translation:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Multilingual App Toolkit extension
uses: microcompiler/install-vsix@db1f973c3d24d1ddc0c38f14d0e1e3a85b2ccb21
with:
packagename: 'dts-publisher.mat2022'
- name: Build solution in Debug configuration
uses: ./.github/actions/build-solution
with:
build-mode: "Debug"
version: "${{ vars.PRERELEASE_VERSION }}.*"
53 changes: 0 additions & 53 deletions .github/workflows/build-validate.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/get-ver.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Verify valid semver, and provide it along with an AssemblyVersion-compatible string as env vars.

# Set to the value provided by github.ref
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 (!($matchInfo.Success)) {
Write-Host "Could not find valid semver within ref. string. Given: $ghRef"
Exit 1
}

$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_OUTPUT
echo $semVerRes >> $env:GITHUB_OUTPUT
echo $isPr >> $env:GITHUB_OUTPUT

Write-Host "Result: $verRes, $semVerRes, $isPr"
71 changes: 69 additions & 2 deletions changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,73 @@
## History:
### Further releases
Please see the [releases](https://github.com/nutdotnet/WinNUT-Client/releases) page for more recent releases.
### Pre-Release v2.2.8436
After a longer than expected wait, the next pre-release is out with another set of bugfixes.

## What's Changed
* Data directory location is more consistent depending on how WinNUT is being run (build type and location) by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/62
* Also includes some improvements to the Logger
* WinNUT is more stable when the connection is lost, and the UI will no longer show strange data by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/64
* Define UPS_States values as pow of 2 to fix state change detection by @supersmile2009 in https://github.com/nutdotnet/WinNUT-Client/pull/71
* Fix release build by @supersmile2009 in https://github.com/nutdotnet/WinNUT-Client/pull/72

## New Contributors
* @supersmile2009 made their first contribution in https://github.com/nutdotnet/WinNUT-Client/pull/71

**Full Changelog**: https://github.com/nutdotnet/WinNUT-Client/compare/v2.2.8356...v2.2.8436

### Pre-Release v2.2.8356
## What's Changed
* Installer dependency cleanup by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/48
* Logging fixes by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/50
* Fix incorrect windows version detection by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/51
* Fix List_Var_Gui error by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/52
* Upgrade to .Net Framework 4.8 by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/53
* Upgrade unhandled exception handling, cryptography by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/49
* This fixes an error on startup that was affecting many people. Please upgrade to this version if WinNUT was crashing on startup for you.
* Respect Follow FSD setting by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/57

Also fixing the installer per #60

**Full Changelog**: https://github.com/nutdotnet/WinNUT-Client/compare/v2.2.8331...v2.2.8356

### Pre-Release v2.2.8331 (Installer quick fix)
Quick fix to remove many dependencies that were added to the installer distribution of WinNUT. Only the installer has changed; please see the last release for the non-installer version.

### Pre-Release v2.2.8328
## Noticeable changes
* Re-enabled the Battery Runtime calculation. Not sure why it was disabled, please report any issues experienced with this. https://github.com/nutdotnet/WinNUT-Client/pull/33
* Finally applied pending de-DE and zh-TW translations to WinNUT https://github.com/nutdotnet/WinNUT-Client/pull/39
* Re-activate stop actions system and extensive core changes including status updates overhaul in https://github.com/nutdotnet/WinNUT-Client/pull/36
* Also fixed resuming WinNUT from a suspended state
* Correct Interval/Delay value in https://github.com/nutdotnet/WinNUT-Client/pull/37

## Minor changes
* Created a build automation workflow so pull requests will have debug builds of WinNUT created and available for download automatically.
* Updated documentation for build & release, and translation procedures.
* Upgraded AGauge .Net Framework to solution's 4.7.2.
* Replaced Win10 static binary references with NuGet package to enable Toast Notifications while still building cross-platform (Win7 and up).

## New Contributors
* @MartinKurtz made their first contribution in https://github.com/nutdotnet/WinNUT-Client/pull/30

**Full Changelog**: https://github.com/nutdotnet/WinNUT-Client/compare/v2.2.8303...v2.2.8328

### Version 2.2.8303
Attempting to fix versioning on MSI Installer for future smooth upgrades. No changes in main program since last version.

**NOTE:** You will need to remove the old version (2.2 in Add Remove Programs list) for this and future upgrades to install correctly.

**Full Changelog**: https://github.com/nutdotnet/WinNUT-Client/compare/v2.2.8286...v2.2.8303

### Version 2.2.8286
Beta/Prerelease
* Add Translation/zh-TW/zh-TW.csv for Chinese (Traditional) by @yrctw in https://github.com/nutdotnet/WinNUT-Client/pull/23
* Large changes to Socket/UPS, DATA-STALE error handling by @gbakeman in https://github.com/nutdotnet/WinNUT-Client/pull/25

## New Contributors
* @yrctw made their first contribution in https://github.com/nutdotnet/WinNUT-Client/pull/23

**Full Changelog**: https://github.com/nutdotnet/WinNUT-Client/compare/v2.2.8255...v2.2.8286


### Version 2.2.8255
Beta Release
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions WinNUT_V2/SharedAssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ Imports System.Resources
<Assembly: AssemblyProduct("WinNUT Client")>
<Assembly: AssemblyCopyright("NUTDotNet contributors © 2019-2024")>
<Assembly: AssemblyTrademark("https://github.com/nutdotnet/WinNUT-Client")>

<Assembly: AssemblyVersion("2.3.*")>
<Assembly: NeutralResourcesLanguage("en-US")>
Loading