-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (157 loc) · 5.94 KB
/
create_release.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Copyright (c) Stéphane ANDRE.
# Licensed under the MIT license.
# This continuous integration pipeline is triggered anytime a user pushes a tag. Could be trigger by user action.
# This pipeline builds solution, update CHANGELOG.md and creates a draft release
name: Create Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
# GitVersion
gitversion:
timeout-minutes: 5
runs-on: windows-latest
outputs:
full_version: ${{ steps.gitversion.outputs.SemVer }}
suffix_label: ${{ steps.gitversion.outputs.PreReleaseLabel }}
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Install Git version
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
# Check Git version
- name: Check Git Semantic Version
id: gitversion
uses: gittools/actions/gitversion/[email protected] # https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md
with:
useConfigFile: true
configFilePath: .\.github\GitVersion.yml
disableNormalization: true
# Build and test
build:
runs-on: windows-latest
name: Build all projects
needs: [ gitversion ]
env:
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET 8.0.201
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.201
- name: Add NuGet Feed
shell: pwsh
run: |
$userName = "${{ vars.PRIVATE_NUGET_API_USERNAME }}"
$token = "${{ secrets.PRIVATE_NUGET_API_KEY }}"
if ($userName -eq '' || $token -eq '') {
dotnet nuget add source ${{ vars.PRIVATE_NUGET_API_SOURCE }} -n NuGetFeed
} else {
dotnet nuget add source ${{ vars.PRIVATE_NUGET_API_SOURCE }} -u $userName -p $token -n NuGetFeed
}
- name: NuGet Restore
run: dotnet restore .\src\MyNetWpf.sln
- name: Build Packages
run: dotnet build .\src\MyNetWpf.sln -c Release /p:GitVersion=${{ needs.gitversion.outputs.full_version }} /p:VersionSuffix=${{ needs.gitversion.outputs.suffix_label }}
- name: Run Tests
if: ${{ inputs.run-tests }}
run: dotnet test .\src\MyNetWpf.sln --configuration Release --logger GitHubActions --no-build --no-restore --blame-crash --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --no-build
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: NuGet
path: ./Artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: TestApp
path: |
./build/MyNet.Wpf.TestApp/Release/**
!./build/MyNet.Wpf.TestApp/Release/*.xml
!./build/MyNet.Wpf.TestApp/Release/*.pdb
# Create release
release:
runs-on: ubuntu-latest
needs: [ gitversion, build ]
env:
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
package_name: MyNet.Wpf
permissions:
contents: write
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Update CHANGELOG with all conventional commit from previous tag
- name: Update CHANGELOG
continue-on-error: true
id: changelog
uses: requarks/[email protected] # https://github.com/marketplace/actions/changelog-from-conventional-commits
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
# Commit changes in CHANGELOG and skip CI
- name: Commit CHANGELOG.md
continue-on-error: true
uses: stefanzweifel/git-auto-commit-action@v4 # https://github.com/marketplace/actions/git-auto-commit
with:
branch: main
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
file_pattern: CHANGELOG.md
# Download artifacts
- uses: actions/download-artifact@v3
with:
name: NuGet
path: Artifacts/
# Download artifacts
- uses: actions/download-artifact@v3
with:
name: TestApp
path: TestApp/
# Zip testApp
- name: Zip artifact for deployment
run: zip Artifacts/TestApp.zip TestApp/** -r
# Get package version
- name: Process Package Version
shell: bash
id: process_version
working-directory: Artifacts/
run: |
echo "Downloading package version script..."
curl -sS -o process-version.pl https://raw.githubusercontent.com/avantipoint/workflow-templates/master/build/process-version.pl
echo "Finished downloading package version script."
echo "Processing package version..."
perl process-version.pl ${{ env.package_name }}
# Create release
- uses: ncipollo/release-action@main # https://github.com/marketplace/actions/create-release
name: Create Release
with:
artifacts: "Artifacts/*.nupkg,Artifacts/*.snupkg,Artifacts/*.zip"
artifactErrorsFailBuild: true
draft: true
generateReleaseNotes: false
token: ${{ github.token }}
name: "${{ steps.process_version.outputs.release-display-name }}"
prerelease: ${{ steps.process_version.outputs.is-preview }}
tag: v${{needs.gitversion.outputs.full_version}}
body: ${{ steps.changelog.outputs.changes }}