-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (197 loc) · 9.07 KB
/
release.yml
File metadata and controls
239 lines (197 loc) · 9.07 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_version:
description: "Release tag or version label, for example v1.0.1"
required: true
type: string
publish_to_github_release:
description: "Upload packaged artifacts to a GitHub release"
required: true
default: false
type: boolean
permissions:
contents: write
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
name: Resolve Release Context
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.resolve.outputs.release_version }}
should_upload_release: ${{ steps.resolve.outputs.should_upload_release }}
steps:
- name: Resolve release metadata
id: resolve
shell: pwsh
run: |
if ("${{ github.event_name }}" -eq "push") {
$releaseVersion = "${{ github.ref_name }}"
$shouldUpload = "true"
}
else {
$releaseVersion = "${{ inputs.release_version }}"
$shouldUpload = if ("${{ inputs.publish_to_github_release }}" -eq "true") { "true" } else { "false" }
}
if ([string]::IsNullOrWhiteSpace($releaseVersion)) {
throw "A release version could not be resolved."
}
"release_version=$releaseVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"should_upload_release=$shouldUpload" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
verify:
name: Verify Release Build
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ApiHealthDashboard.sln
- name: Build solution
run: dotnet build ApiHealthDashboard.sln -c Release --no-restore
- name: Run tests
run: dotnet test ApiHealthDashboard.sln -c Release --no-build
publish:
name: Publish ${{ matrix.runtime }}
needs:
- prepare
- verify
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- runtime: win-x64
archive_extension: zip
- runtime: linux-x64
archive_extension: tar.gz
env:
PROJECT_PATH: src/ApiHealthDashboard/ApiHealthDashboard.csproj
RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: Publish self-contained app
run: dotnet publish ${{ env.PROJECT_PATH }} -c Release -r ${{ matrix.runtime }} --self-contained true -o ./artifacts/publish/${{ matrix.runtime }}
- name: Package Windows artifact
if: ${{ matrix.archive_extension == 'zip' }}
shell: pwsh
run: Compress-Archive -Path "./artifacts/publish/${{ matrix.runtime }}/*" -DestinationPath "./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.zip" -Force
- name: Package Linux artifact
if: ${{ matrix.archive_extension == 'tar.gz' }}
run: tar -C "./artifacts/publish/${{ matrix.runtime }}" -czf "./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.tar.gz" .
- name: Generate checksum
run: sha256sum "./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}" > "./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}.sha256"
- name: Upload packaged artifact to workflow run
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.runtime }}
path: |
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}.sha256
if-no-files-found: error
- name: Upload artifacts to GitHub Release
if: ${{ needs.prepare.outputs.should_upload_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_VERSION }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-${{ matrix.runtime }}.${{ matrix.archive_extension }}.sha256
docker-compose:
name: Docker Compose Release Bundle
needs:
- prepare
- verify
runs-on: ubuntu-latest
env:
APIHEALTHDASHBOARD_IMAGE: apihealthdashboard:release-${{ github.run_id }}
APIHEALTHDASHBOARD_PORT: 18080
COMPOSE_PROJECT_NAME: apihealthdashboard-release
RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Validate Docker Compose config
run: docker compose -f docker-compose.yml config
- name: Validate Windows Docker Compose config
run: docker compose -f docker-compose.windows.yml config
- name: Build Linux Docker Compose image
run: docker compose -f docker-compose.yml build
- name: Start Docker Compose app
run: docker compose -f docker-compose.yml up -d --no-build
- name: Probe Docker Compose app
run: |
for attempt in {1..30}; do
if curl --fail --silent --show-error "http://localhost:${APIHEALTHDASHBOARD_PORT}/" > /dev/null; then
exit 0
fi
sleep 2
done
docker compose -f docker-compose.yml logs
exit 1
- name: Stop Docker Compose app
if: ${{ always() }}
run: docker compose -f docker-compose.yml down --volumes --remove-orphans
- name: Package Docker Compose source bundle
shell: pwsh
run: |
$bundlePath = "./artifacts/docker-compose-bundle"
New-Item -ItemType Directory -Path $bundlePath -Force | Out-Null
New-Item -ItemType Directory -Path "$bundlePath/src" -Force | Out-Null
Copy-Item "Dockerfile" "$bundlePath/Dockerfile"
Copy-Item ".dockerignore" "$bundlePath/.dockerignore"
Copy-Item "docker-compose.yml" "$bundlePath/docker-compose.yml"
Copy-Item "docker-compose.windows.yml" "$bundlePath/docker-compose.windows.yml"
Copy-Item ".env.example" "$bundlePath/.env.example"
Copy-Item "DOCKER.md" "$bundlePath/DOCKER.md"
Copy-Item "src/ApiHealthDashboard" "$bundlePath/src/ApiHealthDashboard" -Recurse
- name: Package Docker Compose zip
run: zip -r "../ApiHealthDashboard-${RELEASE_VERSION}-docker-compose.zip" .
working-directory: ./artifacts/docker-compose-bundle
- name: Package Docker Compose tarball
run: tar -C "./artifacts/docker-compose-bundle" -czf "./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.tar.gz" .
- name: Generate Docker Compose bundle checksums
run: |
sha256sum "./artifacts/ApiHealthDashboard-${RELEASE_VERSION}-docker-compose.zip" > "./artifacts/ApiHealthDashboard-${RELEASE_VERSION}-docker-compose.zip.sha256"
sha256sum "./artifacts/ApiHealthDashboard-${RELEASE_VERSION}-docker-compose.tar.gz" > "./artifacts/ApiHealthDashboard-${RELEASE_VERSION}-docker-compose.tar.gz.sha256"
- name: Upload Docker Compose bundle to workflow run
uses: actions/upload-artifact@v4
with:
name: release-docker-compose
path: |
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.zip
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.zip.sha256
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.tar.gz
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.tar.gz.sha256
if-no-files-found: error
- name: Upload Docker Compose bundle to GitHub Release
if: ${{ needs.prepare.outputs.should_upload_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_VERSION }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.zip
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.zip.sha256
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.tar.gz
./artifacts/ApiHealthDashboard-${{ env.RELEASE_VERSION }}-docker-compose.tar.gz.sha256