Skip to content

release

release #8

Workflow file for this run

name: release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build-and-release:
runs-on: windows-latest
env:
PROJECT_PATH: HTWind/HTWind.csproj
RUNTIME: win-x64
PUBLISH_DIR: out/publish
DIST_DIR: dist
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Resolve version from project
id: version
shell: pwsh
run: |
[xml]$project = Get-Content $env:PROJECT_PATH
$version = $null
foreach ($group in $project.Project.PropertyGroup) {
if ($group.Version) {
$version = "$($group.Version)".Trim()
break
}
}
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Version was not found in $env:PROJECT_PATH."
}
if ($env:GITHUB_REF_TYPE -eq "tag") {
$tagVersion = "$env:GITHUB_REF_NAME" -replace '^v', ''
if ($tagVersion.Trim() -ne $version) {
throw "Tag version '$tagVersion' does not match project Version '$version'."
}
}
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Restore
run: dotnet restore $env:PROJECT_PATH
- name: Build
run: dotnet build $env:PROJECT_PATH -c Release --no-restore
- name: Clean publish output
shell: pwsh
run: |
if (Test-Path $env:PUBLISH_DIR) {
Remove-Item $env:PUBLISH_DIR -Recurse -Force
}
- name: Publish
shell: pwsh
run: |
dotnet publish $env:PROJECT_PATH `
-c Release `
-r $env:RUNTIME `
--self-contained true `
/p:PublishSingleFile=true `
/p:IncludeNativeLibrariesForSelfExtract=true `
/p:Version=${{ steps.version.outputs.version }} `
-o $env:PUBLISH_DIR
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Build installer
shell: pwsh
run: |
New-Item -ItemType Directory -Path $env:DIST_DIR -Force | Out-Null
iscc `
/DSourceDir="$pwd\\$env:PUBLISH_DIR" `
/DMyAppExeName="HTWind.exe" `
installer/HTWind.iss
- name: Build portable zip
shell: pwsh
run: |
$zipPath = "$env:DIST_DIR/HTWind-portable-${{ steps.version.outputs.version }}.zip"
if (Test-Path $zipPath) {
Remove-Item $zipPath -Force
}
Compress-Archive -Path "$env:PUBLISH_DIR/*" -DestinationPath $zipPath
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
target_commitish: ${{ github.sha }}
name: HTWind v${{ steps.version.outputs.version }}
generate_release_notes: true
files: |
dist/HTWind-setup-*.exe
dist/HTWind-portable-*.zip