-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 3.37 KB
/
Copy pathrelease.yml
File metadata and controls
90 lines (75 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
name: Publish and release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Resolve package version
shell: pwsh
run: |
$version = $env:GITHUB_REF_NAME -replace '^v', ''
if ($version -notmatch '^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$') {
throw "Tag '$env:GITHUB_REF_NAME' must be a semantic version tag like v1.2.3."
}
[xml]$csproj = Get-Content .\src\Adomd.Cli\Adomd.Cli.csproj
$versionPrefix = $csproj.Project.PropertyGroup.VersionPrefix | Select-Object -First 1
if ($versionPrefix -ne $version) {
throw "Tag version '$version' does not match VersionPrefix '$versionPrefix' in Adomd.Cli.csproj. Update the csproj before tagging a release."
}
"PACKAGE_VERSION=$version" >> $env:GITHUB_ENV
- name: Restore
run: dotnet restore .\src\Adomd.Cli\Adomd.Cli.csproj
- name: Publish win-x64 executable
run: dotnet publish .\src\Adomd.Cli\Adomd.Cli.csproj --configuration Release --runtime win-x64 --self-contained true --output .\artifacts\publish\win-x64 -p:PublishSingleFile=true -p:PublishReadyToRun=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
- name: Archive win-x64 executable
shell: pwsh
run: Compress-Archive -Path .\artifacts\publish\win-x64\* -DestinationPath .\artifacts\adomd-cli-win-x64.zip -Force
- name: Generate checksum
shell: pwsh
run: |
$hash = Get-FileHash -Path .\artifacts\adomd-cli-win-x64.zip -Algorithm SHA256
"$($hash.Hash.ToLowerInvariant()) adomd-cli-win-x64.zip" | Out-File -FilePath .\artifacts\adomd-cli-win-x64.zip.sha256 -Encoding ascii -NoNewline
- name: Extract release notes
shell: pwsh
run: |
$version = $env:PACKAGE_VERSION
$changelog = Get-Content .\CHANGELOG.md -Raw
# Grab the body of the section for this version, up to the next "## [" heading.
$pattern = "(?ms)^##\s*\[$([regex]::Escape($version))\].*?$("`n")(.*?)(?=^##\s*\[|\z)"
$match = [regex]::Match($changelog, $pattern)
if ($match.Success) {
$notes = $match.Groups[1].Value.Trim()
} else {
$notes = "Release v$version"
}
Set-Content -Path .\artifacts\release-notes.md -Value $notes -Encoding utf8
- name: Upload executable artifact
uses: actions/upload-artifact@v7
with:
name: adomd-cli-win-x64
path: |
artifacts\adomd-cli-win-x64.zip
artifacts\adomd-cli-win-x64.zip.sha256
if-no-files-found: error
- name: Create GitHub release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create $env:GITHUB_REF_NAME ./artifacts/adomd-cli-win-x64.zip ./artifacts/adomd-cli-win-x64.zip.sha256 --title $env:GITHUB_REF_NAME --notes-file ./artifacts/release-notes.md --verify-tag