-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (222 loc) · 7.75 KB
/
Copy pathreleaseBuild.yml
File metadata and controls
243 lines (222 loc) · 7.75 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Build for release
on:
workflow_run:
workflows: [.NET CI]
types: [completed]
push:
tags:
- v*
jobs:
build_and_pack:
name: Release build & package
runs-on: ubuntu-24.04
timeout-minutes: 30
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
env:
GithubNugetUsername: craigfowler
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Setup build dependencies
uses: ./.github/actions/setup-build-dependencies
with:
dotnet-version: ${{ vars.SDK_VERSION }}
- name: Restore third party libs
uses: ./.github/actions/restore-dependencies
- name: Build CI version
if: ${{ github.event_name == 'workflow_run' }}
run: dotnet pack -p:VersionSuffix=ci.${{ github.run_number }} -o packages
- name: Get semantic tag version
if: ${{ github.event_name == 'push' }}
id: get_version
run: |
tagname="${{ github.ref_name }}"
echo "name=${tagname:1}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Build tagged version
if: ${{ github.event_name == 'push' }}
run: dotnet pack -p:Version=${{ steps.get_version.outputs.name }} -o packages
- name: Upload build result artifacts
uses: actions/upload-artifact@v7
with:
name: Build results (NuGet)
path: packages/*.nupkg
build_docs_site:
name: Build the documentation website
runs-on: ubuntu-24.04
timeout-minutes: 30
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Setup build dependencies
uses: ./.github/actions/setup-build-dependencies
with:
dotnet-version: ${{ vars.SDK_VERSION }}
- name: Restore third party libs
uses: ./.github/actions/restore-dependencies
- name: Remove old docs
run: dotnet clean CSF.Screenplay.Docs
- name: Build docs website
run: dotnet build -c Docs CSF.Screenplay.Docs
- name: Upload docs website artifact
uses: actions/upload-artifact@v7
with:
name: Docs website
path: docs/**/*
publish_nuget:
name: Publish new Release (Github & NuGet)
runs-on: ubuntu-slim
if: ${{ github.event_name == 'push' }}
needs: build_and_pack
permissions:
actions: read
id-token: write
contents: write
steps:
- name: Add .NET global tools location to PATH
run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
shell: bash
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ vars.SDK_VERSION }}
- name: Get release artifacts
uses: actions/download-artifact@v8
with:
name: Build results (NuGet)
path: ./packages
- name: Log into NuGet & get short-lived API key
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
run: dotnet nuget push ./packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
- name: Determine release properties
id: get-release-props
run: |
VERSION="${GITHUB_REF_NAME#v}"
PRERELEASE="$([[ "$VERSION" =~ "-" ]] && echo "true" || echo "false")"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
- name: Generate release notes (first part)
run: |
PACKAGE_LIST=$(for package in packages/*.nupkg; do echo $(basename "$package" | sed -r 's/^([A-Za-z.]+)\.[0-9.A-Za-z-]*\.nupkg$/\1/'); done)
VERSION="${{ steps.get-release-props.outputs.version }}"
cat <<EOF > release_notes.md
# CSF.Screenplay version $VERSION
## NuGet packages
These are the NuGet packages which are published for this release.
| Package | Version |
| ------- | ------- |
EOF
for package in $PACKAGE_LIST
do
echo "| [${package}](https://www.nuget.org/packages/${package}/${VERSION}) | $VERSION |" >> release_notes.md
done
cat <<EOF >> release_notes.md
## Changelog
EOF
- name: Create release
uses: softprops/action-gh-release@v3
with:
draft: true
name: ${{ steps.get-release-props.outputs.version }}
prerelease: ${{ steps.get-release-props.outputs.prerelease }}
body_path: release_notes.md
generate_release_notes: true
publish_github:
name: Publish packages to GitHub
runs-on: ubuntu-slim
needs: build_and_pack
if: ${{ github.event_name == 'workflow_run' && github.ref_name == 'master' }}
env:
GithubNugetUsername: craigfowler
steps:
- name: Add .NET global tools location to PATH
run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
shell: bash
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ vars.SDK_VERSION }}
- name: Get release artifacts
uses: actions/download-artifact@v8
with:
name: Build results (NuGet)
path: ./packages
- name: Publish packages to GitHub feed
run: |
dotnet nuget add source --username ${{ env.GithubNugetUsername }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/csf-dev/index.json"
for package in packages/*.nupkg
do
dotnet nuget push $package --api-key ${{ secrets.GITHUB_TOKEN }} --source github
done
update_docs_website:
name: Update docs website
runs-on: ubuntu-slim
needs: build_docs_site
if: ${{ github.event_name == 'workflow_run' && github.ref_name == 'master' }}
outputs:
committed: ${{ steps.add-and-commit.outputs.committed }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- name: Add .NET global tools location to PATH
run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
shell: bash
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ vars.SDK_VERSION }}
- name: Remove old docs
run: dotnet clean CSF.Screenplay.Docs
- name: Get release artifacts
uses: actions/download-artifact@v8
with:
name: Docs website
path: ./docs
- name: Add & Commit
uses: EndBug/add-and-commit@v9.1.4
id: add-and-commit
with:
add: -A docs/
default_author: github_actor
committer_name: Github Actions Workflow (bot)
committer_email: github-actions-workflow@bots.noreply.github.com
fetch: true
message: Publish updated documentation website
push: origin master
publish_github_pages:
name: Publish updated Github pages site
runs-on: ubuntu-slim
needs: update_docs_website
if: needs.update_docs_website.outputs.committed == true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4