forked from PropertyTools/PropertyTools
-
Notifications
You must be signed in to change notification settings - Fork 4
107 lines (91 loc) · 3.76 KB
/
Copy pathrelease.yml
File metadata and controls
107 lines (91 loc) · 3.76 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Release (build, test, publish package)
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "!v[0-9]+.[0-9]+.[0-9]+-preview[0-9][0-9][0-9]"
jobs:
build:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
10.0.x
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
- name: Verify commit exists in origin/main
run: git branch --remote --contains | findstr origin/main
- name: Extract release notes from CHANGELOG
shell: pwsh
run: |
$version = "${{ github.ref }}" -replace 'refs/tags/v', ''
$changelog = Get-Content CHANGELOG.md -Raw
# Try to find the version-specific section
$pattern = "## \[$version\](.*?)(?=## \[|$)"
$match = $changelog -match "(?s)$pattern"
if ($match) {
$releaseNotes = $Matches[1].Trim()
$releaseNotes | Out-File -FilePath RELEASE-NOTES.txt -Encoding utf8
Write-Host "Release notes extracted for version $version"
} else {
# Fallback to unreleased section
$match = $changelog -match '(?s)## Unreleased(.*?)(?=## \[|$)'
if ($match) {
$releaseNotes = $Matches[1].Trim()
$releaseNotes | Out-File -FilePath RELEASE-NOTES.txt -Encoding utf8
Write-Host "Release notes extracted from Unreleased section"
} else {
"Release $version" | Out-File -FilePath RELEASE-NOTES.txt -Encoding utf8
Write-Host "No release notes found in CHANGELOG.md"
}
}
- name: Set VERSION variable from tag
shell: pwsh
run: |
$version = "${{ github.ref }}" -replace 'refs/tags/v', ''
Write-Host "VERSION=$version"
"VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Restore dependencies
run: msbuild Source\PropertyTools.sln /t:Restore /p:Configuration=Release
- name: Build
run: msbuild Source\PropertyTools.sln /p:Configuration=Release /p:Version=${{ env.VERSION }}
- name: Test
run: dotnet test Source\PropertyTools.sln --configuration Release --no-build --verbosity normal
- name: Pack PropertyTools
working-directory: Source/PropertyTools
run: dotnet pack --configuration Release /p:Version=${{ env.VERSION }} --no-build --output ../../Packages
- name: Pack PropertyTools.Wpf
working-directory: Source/PropertyTools.Wpf
run: dotnet pack --configuration Release /p:Version=${{ env.VERSION }} --no-build --output ../../Packages
- name: Pack PropertyTools.Wpf.Extended.Toolkit
working-directory: Source/PropertyTools.Wpf.ExtendedToolkit
run: dotnet pack --configuration Release /p:Version=${{ env.VERSION }} --no-build --output ../../Packages
- name: Push to GitHub Packages
run: dotnet nuget push ./Packages/*.nupkg --source https://nuget.pkg.github.com/PropertyTools/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push to nuget.org
run: dotnet nuget push ./Packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
body_path: RELEASE-NOTES.txt
draft: false
prerelease: false
files: |
Packages/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}