-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (118 loc) · 4.89 KB
/
release.yml
File metadata and controls
142 lines (118 loc) · 4.89 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
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