-
Notifications
You must be signed in to change notification settings - Fork 36
203 lines (169 loc) · 6.96 KB
/
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: "Release Generator"
# after successful analysis on the main branch, a new pre-release is generated
on:
#Makes a Nighly release on a new commit.
workflow_run:
workflows: [Code Analysis]
types: [completed]
branches: [master]
#Makes a Release on tag
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch: # ReleaseGen can be triggered manually
env:
IS_RELEASE: ${{ github.ref_type == 'tag' }}
ZIP_NAME: ${{ github.ref_type == 'tag' && 'Release_' || 'Release_Nightly_' }}
ZIP_PATH: ${{ github.ref_type == 'tag' && 'FASTER_' || 'FASTER_Nightly_' }}
jobs:
# BUILD APP
build:
strategy:
matrix:
# runtime: [x64, x86]
runtime: [x64]
runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Configuration: Release
Solution_Name: FASTER # Replace with your solution name, i.e. MyWpfApp.sln.
Test_Project_Path: FASTERTests\FASTERTests.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
Wap_Project_Directory: FASTER # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package.
Wap_Project_Path: FASTER.App.Package\FASTER.Package.wapproj # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj.
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{vars.DOTNET_VERSION}}
# Execute all unit tests in the solution
- name: Execute unit tests
run: dotnet test
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: dotnet restore
# Build
- name: Build the application
run: dotnet build --configuration $env:Configuration -a $env:Runtime ./FASTER/FASTER.csproj
env:
Runtime: ${{ matrix.runtime }}
# Pub
- name: Publish the application ${{ matrix.runtime }}
run: dotnet publish --configuration $env:Configuration -a $env:Runtime --self-contained true /p:useapphost=true --output .\$env:ZIP_NAME$env:Runtime ./FASTER/FASTER.csproj
env:
Runtime: ${{ matrix.runtime }}
# Zip the folder
- name: Zip the application folder
run: Compress-Archive -Path .\$env:ZIP_NAME$env:Runtime\* -DestinationPath .\$env:ZIP_NAME$env:Runtime.zip
shell: pwsh
env:
Runtime: ${{ matrix.runtime }}
# Get version number
- name: get-net-sdk-project-versions-action
uses: kzrnm/[email protected]
id: get-version
with:
proj-path: ./FASTER/FASTER.csproj
# Get Changes between Tags
- name: Generate Changelog
id: get-changes
run: |
Write-Output "::group::Collecting Changes between Tags..."
# Set options from inputs
$tagPattern = "^v?\d\.\d+([a-zA-Z]|\.\d+([a-zA-Z])?)?"
$linePrefix = "- "
# Fetch all tags from origin
git fetch origin --tags --force
# Get tags that match the pattern and sort them using version sorting in reverse
$tags = git tag --sort=committerdate -l | Select-String -Pattern $tagPattern | Sort-Object -Descending || ""
# Count the found tags
$countTags = ($tags -split "`n").Count
# Exit with error if no tags are found
if ($tags -eq "" -or $countTags -le 0) {
Write-Output "::error title=no tags found::changes-between-tags action could not find any tags to work with"
exit 1
}
# Take the first tag as latestTag
$latestTag = ($tags -split "`n")[0]
$range = "$latestTag" + "..@"
# Get changes for range
$changes = git log --pretty=reference --no-decorate $range
# If set, add a prefix to every commit message
if ($linePrefix) {
$changes = $changes -replace "^(.*)$", "$linePrefix`$1"
}
# Set outputs
$EOF = (New-Guid).Guid
"changes<<$EOF" >> $env:GITHUB_OUTPUT
$changes >> $env:GITHUB_OUTPUT
"$EOF" >> $env:GITHUB_OUTPUT
"tag=$latestTag" >> $env:GITHUB_OUTPUT
# Log the results
Write-Output "tag: $latestTag"
Write-Output "changes:"
Write-Output $changes
# End log grouping
Write-Output "::endgroup::"
shell: pwsh
# Set Version Number to environment
- name: Set Version
id: set_version
run: |
if ($env:IS_RELEASE -eq "true") {
echo "VERSION=$env:GITHUB_REF" >> $env:GITHUB_ENV
} else {
echo "VERSION=${{ steps.get-version.outputs.version }}" >> $env:GITHUB_ENV
}
shell: pwsh
#Create Release
- name: Create Release
if: env.IS_RELEASE == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: '${{ env.VERSION }}'
release_name: 'Release ${{ env.VERSION }}'
body: |
Changelog since release ${{ steps.get-changes.outputs.tag }} :
---
${{ steps.get-changes.outputs.changes }}
---
draft: false
prerelease: ${{ env.IS_RELEASE == 'false' }}
# Upload Artifacts
- name: Upload Release Asset
if: env.IS_RELEASE == 'true'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Runtime: ${{ matrix.runtime }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: .\${{ env.ZIP_NAME}}${{ env.Runtime }}.zip
asset_name: ${{ env.ZIP_NAME}}${{ env.Runtime }}.zip
asset_content_type: application/zip
# Create Nightly Release
- name: Create Nightly Release
if: env.IS_RELEASE == 'false'
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Runtime: ${{ matrix.runtime }}
with:
tag_name: nightly
name: 'Nightly Release v${{ env.VERSION }}'
body: |
Changelog since release ${{ steps.get-changes.outputs.tag }} :
---
${{ steps.get-changes.outputs.changes }}
---
prerelease: true
files: .\${{ env.ZIP_NAME}}${{ env.Runtime }}.zip