147 lines
6.3 KiB
YAML
147 lines
6.3 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version/tag to create (e.g. v1.2.3)"
|
|
required: false
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-2025-vs2026
|
|
steps:
|
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
|
|
- uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
|
|
with:
|
|
dotnet-version: "10.x"
|
|
|
|
- uses: nuget/setup-nuget@fd55a6f3b34392fa83fde1454582407d8c714123 # 4.0.0
|
|
|
|
- uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # 3.0.0
|
|
with:
|
|
msbuild-architecture: x64
|
|
|
|
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # 4.0.1
|
|
id: changes
|
|
with:
|
|
filters: |
|
|
buildprops:
|
|
- 'Directory.Build.props'
|
|
|
|
- name: Update version
|
|
run: |
|
|
$inputVersion = "${{ inputs.version }}"
|
|
if ($inputVersion) {
|
|
$cleanVersion = $inputVersion -replace '^v', ''
|
|
(Get-Content Directory.Build.props) | % {
|
|
$m = [regex]::match($_, '<Version>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?</Version>');
|
|
if($m.Success) { $_ -replace $m.Value, "<Version>$cleanVersion</Version>"; }
|
|
else { $_; }
|
|
} | Set-Content Directory.Build.props
|
|
} elseif ('${{ steps.changes.outputs.buildprops }}' -eq 'false') {
|
|
(Get-Content Directory.Build.props) | % {
|
|
$m = [regex]::match($_, '<Version>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?</Version>');
|
|
if(!$m.Success -or $m.Groups[4].Success -or $m.Groups[5].Success) { $_; }
|
|
else { $_ -replace $m.Value, ("<Version>{0}.{1}.{2}-pre${{ github.run_number }}</Version>" -f $m.Groups[1].Value,$m.Groups[2].Value,([convert]::ToInt32($m.Groups[3].Value)+1)); }
|
|
} | Set-Content Directory.Build.props
|
|
}
|
|
|
|
- name: Get Version
|
|
id: get_version
|
|
run: |
|
|
$content = Get-Content Directory.Build.props
|
|
$m = [regex]::match($content, '<Version>([^<]+)</Version>')
|
|
if ($m.Success) {
|
|
$version = $m.Groups[1].Value
|
|
} else {
|
|
$version = "1.0.0-draft"
|
|
}
|
|
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
|
|
echo "Detected version: $version"
|
|
|
|
- name: Determine Tag
|
|
id: tag_name
|
|
run: |
|
|
$inputVersion = "${{ inputs.version }}"
|
|
if ($inputVersion) {
|
|
$tag = $inputVersion
|
|
if ($tag -notmatch '^v') {
|
|
$tag = "v" + $tag
|
|
}
|
|
} elseif ("${{ github.ref_type }}" -eq "tag") {
|
|
$tag = "${{ github.ref_name }}"
|
|
} else {
|
|
$tag = "v${{ steps.get_version.outputs.VERSION }}"
|
|
}
|
|
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
|
|
echo "Release tag: $tag"
|
|
|
|
- name: Restore application packages
|
|
run: dotnet restore LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj
|
|
|
|
- name: Build application
|
|
run: dotnet build LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj -c Release --no-restore -p:Platform=x64
|
|
|
|
- name: Restore library packages
|
|
run: dotnet restore LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj
|
|
|
|
- name: Build x64 libraries
|
|
run: dotnet build LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj -c Release --no-restore -p:Platform=x64
|
|
|
|
- name: Run library tests
|
|
run: dotnet test LibreHardwareMonitorLib.Tests\LibreHardwareMonitorLib.Tests.csproj -c Release -p:Platform=x64
|
|
|
|
- name: Run WinUI tests
|
|
run: dotnet test LibreHardwareMonitor.Windows.WinUI.Tests\LibreHardwareMonitor.Windows.WinUI.Tests.csproj -c Release -p:Platform=x64
|
|
|
|
- name: Publish WinUI application
|
|
run: dotnet publish LibreHardwareMonitor.Windows.WinUI\LibreHardwareMonitor.Windows.WinUI.csproj -c Release -r win-x64 -p:Platform=x64 -p:PublishSingleFile=true -p:PublishSelfContained=true --self-contained true --no-restore -o publish/app
|
|
|
|
- name: Stage Release Assets
|
|
run: |
|
|
New-Item -ItemType Directory -Force -Path release-staging
|
|
|
|
# Copy application binary (single file, self-contained, with .NET version)
|
|
Copy-Item publish/app/LibreHardwareMonitor.Windows.WinUI.exe release-staging/LibreHardwareMonitor.Windows.WinUI-net10.0.exe
|
|
|
|
# Copy library DLL (net10.0 build)
|
|
Copy-Item bin/Release/x64/net10.0/LibreHardwareMonitorLib.dll release-staging/LibreHardwareMonitorLib.dll
|
|
|
|
# Create source code ZIP
|
|
git archive --format=zip --output release-staging/LibreHardwareMonitor-source.zip HEAD
|
|
|
|
# Generate SHA256 checksums
|
|
$sha256 = [System.Security.Cryptography.SHA256]::Create()
|
|
Get-ChildItem release-staging | Where-Object { $_.Name -ne "SHA256SUMS.txt" } | ForEach-Object {
|
|
$fileStream = [System.IO.File]::OpenRead($_.FullName)
|
|
$hashBytes = $sha256.ComputeHash($fileStream)
|
|
$fileStream.Close()
|
|
$hash = [System.BitConverter]::ToString($hashBytes).Replace("-", "").ToLower()
|
|
"{0} {1}" -f $hash, $_.Name
|
|
} | Set-Content release-staging/SHA256SUMS.txt
|
|
|
|
# Log hashes for visibility
|
|
Get-Content release-staging/SHA256SUMS.txt
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # 3.0.0
|
|
with:
|
|
tag_name: ${{ steps.tag_name.outputs.TAG }}
|
|
name: ${{ steps.tag_name.outputs.TAG }}
|
|
draft: false
|
|
prerelease: ${{ contains(steps.tag_name.outputs.TAG, '-pre') }}
|
|
files: |
|
|
release-staging/LibreHardwareMonitor.Windows.WinUI-net10.0.exe
|
|
release-staging/LibreHardwareMonitorLib.dll
|
|
release-staging/LibreHardwareMonitor-source.zip
|
|
release-staging/SHA256SUMS.txt
|