Skip to content

Release

Release #9

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
configuration:
description: Build configuration
required: false
default: Release
type: choice
options:
- Release
- Debug
app_id:
description: Installer/App GUID metadata value
required: false
default: 45156332-3408-47B7-B5D2-2567E5888F64
type: string
permissions:
contents: write
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Resolve release metadata
id: release_meta
shell: pwsh
run: |
[xml] $projectXml = Get-Content -LiteralPath '.\ContextMenuMgr.Frontend\ContextMenuMgr.Frontend.csproj'
$propertyGroups = @($projectXml.Project.PropertyGroup)
$releaseVersion = $null
foreach ($group in $propertyGroups) {
if ($group.InformationalVersion) {
$releaseVersion = [string] $group.InformationalVersion
break
}
}
if ([string]::IsNullOrWhiteSpace($releaseVersion)) {
foreach ($group in $propertyGroups) {
if ($group.FileVersion) {
$releaseVersion = [string] $group.FileVersion
break
}
}
}
if ([string]::IsNullOrWhiteSpace($releaseVersion)) {
throw "Neither InformationalVersion nor FileVersion was found in ContextMenuMgr.Frontend.csproj."
}
$releaseTag = "v$releaseVersion"
$releaseName = "Release-$releaseTag"
git fetch --tags --force
$previousTag = git tag --sort=-version:refname | Select-Object -First 1
$releaseBodyLines = @(
'## Changes'
''
)
if ([string]::IsNullOrWhiteSpace($previousTag)) {
$releaseBodyLines += '- Initial release'
}
else {
$releaseBodyLines += ('Previous tag: `{0}`' -f $previousTag)
$releaseBodyLines += ''
$revisionRange = '{0}..HEAD' -f $previousTag
$gitLogArguments = @(
'log'
'--pretty=format:- %s (%h)'
$revisionRange
)
$commitLines = & git @gitLogArguments
if (-not $commitLines) {
$releaseBodyLines += '- No commits since the previous tag'
}
else {
$releaseBodyLines += $commitLines
}
}
"release_version=$releaseVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"release_tag=$releaseTag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"release_name=$releaseName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"release_body<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
$releaseBodyLines | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Build multi-arch installers
shell: pwsh
run: >
.\build.ps1
-Configuration "${{ inputs.configuration }}"
-AppId "${{ inputs.app_id }}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ContextMenuManager-${{ steps.release_meta.outputs.release_tag }}
path: |
build/dist/*.exe
build/dist/artifacts.txt
if-no-files-found: error
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_meta.outputs.release_tag }}
name: ${{ steps.release_meta.outputs.release_name }}
draft: true
body: ${{ steps.release_meta.outputs.release_body }}
files: |
build/dist/*.exe