-
Notifications
You must be signed in to change notification settings - Fork 2
296 lines (252 loc) · 9.04 KB
/
Copy pathrelease.yml
File metadata and controls
296 lines (252 loc) · 9.04 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Release
on:
push:
tags:
- '*'
permissions:
contents: write
packages: write
id-token: write
env:
CONTAINER_REGISTRY: ghcr.io
CONTAINER_IMAGE: ${{ github.repository_owner }}/skillserver
jobs:
# ─── Stage 1: Build everything in parallel ───────────────────────────
nuget-pack:
name: NuGet Pack
runs-on: ubuntu-latest
environment: nuget
steps:
- name: "Checkout"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
with:
global-json-file: "./global.json"
- name: "Restore .NET tools"
run: dotnet tool restore
- name: "Update release notes"
shell: pwsh
run: ./build.ps1
- name: "Pack"
run: dotnet pack -p:PackageVersion=${{ github.ref_name }} -c Release -o ./output
- name: "Upload artifacts"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: nuget-packages
path: |
output/*.nupkg
output/*.snupkg
retention-days: 7
cli-binaries:
name: CLI-${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- rid: linux-x64
os: ubuntu-latest
archive: tar
- rid: linux-arm64
os: ubuntu-latest
archive: tar
- rid: osx-arm64
os: macos-latest
archive: tar
- rid: win-x64
os: windows-latest
archive: zip
steps:
- name: "Checkout"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
with:
global-json-file: "./global.json"
- name: "Restore .NET tools"
run: dotnet tool restore
- name: "Update release notes"
shell: pwsh
run: ./build.ps1
- name: "Set version"
shell: bash
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
ASSEMBLY_VERSION=$(echo "$VERSION" | cut -d'-' -f1)
echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> "$GITHUB_ENV"
- name: "Publish CLI"
shell: bash
run: |
dotnet publish src/Netclaw.SkillServer.Cli/Netclaw.SkillServer.Cli.csproj \
-c Release \
-r ${{ matrix.rid }} \
--self-contained \
-p:PublishSingleFile=true \
-p:Version=${{ env.VERSION }} \
-p:AssemblyVersion=${{ env.ASSEMBLY_VERSION }} \
-p:FileVersion=${{ env.ASSEMBLY_VERSION }} \
-o ./publish
- name: "Smoke test"
if: matrix.rid != 'linux-arm64'
shell: bash
run: |
RID="${{ matrix.rid }}"
if [[ "$RID" == win-* ]]; then
./publish/skillserver.exe --version
./publish/skillserver.exe --help
else
./publish/skillserver --version
./publish/skillserver --help
fi
- name: "Package (tar.gz)"
if: matrix.archive == 'tar'
shell: bash
run: |
cd publish
tar -czf "../skillserver-${{ env.VERSION }}-${{ matrix.rid }}.tar.gz" ./*
cd ..
sha256sum "skillserver-${{ env.VERSION }}-${{ matrix.rid }}.tar.gz" \
> "skillserver-${{ env.VERSION }}-${{ matrix.rid }}.tar.gz.sha256"
- name: "Package (zip)"
if: matrix.archive == 'zip'
shell: pwsh
run: |
Compress-Archive -Path publish/* -DestinationPath skillserver-${{ env.VERSION }}-${{ matrix.rid }}.zip
$hash = (Get-FileHash -Algorithm SHA256 skillserver-${{ env.VERSION }}-${{ matrix.rid }}.zip).Hash.ToLower()
"$hash skillserver-${{ env.VERSION }}-${{ matrix.rid }}.zip" | Set-Content skillserver-${{ env.VERSION }}-${{ matrix.rid }}.zip.sha256
- name: "Upload artifacts"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: cli-${{ matrix.rid }}
path: |
skillserver-${{ env.VERSION }}-${{ matrix.rid }}.*
retention-days: 7
container-images:
name: Container-${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x64
rid: linux-x64
- arch: arm64
rid: linux-arm64
steps:
- name: "Checkout"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
with:
global-json-file: "./global.json"
- name: "Login to GitHub Container Registry"
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build and Push Container"
run: |
dotnet publish src/SkillServer/SkillServer.csproj \
-c Release \
-t:PublishContainer \
-p:ContainerRegistry=${{ env.CONTAINER_REGISTRY }} \
-p:ContainerRepository=${{ env.CONTAINER_IMAGE }} \
-p:ContainerRuntimeIdentifier=${{ matrix.rid }} \
-p:ContainerImageTags='"${{ github.ref_name }}-${{ matrix.arch }}"'
# ─── Stage 2: Publish everything once all builds succeed ─────────────
publish-release:
name: Publish Release
runs-on: ubuntu-latest
needs: [nuget-pack, cli-binaries, container-images]
environment: nuget
steps:
- name: "Checkout"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
with:
global-json-file: "./global.json"
- name: "Download NuGet packages"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: nuget-packages
path: ./nuget
- name: "Download CLI binaries"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
pattern: cli-*
merge-multiple: true
path: ./cli
- name: "NuGet login (OIDC)"
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: "Push NuGet packages"
run: |
dotnet nuget push "nuget/*.nupkg" \
--api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
dotnet nuget push "nuget/*.snupkg" \
--api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: "Create Docker multi-arch manifest"
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
docker login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin
IS_PRERELEASE=false
if [[ "$GITHUB_REF_NAME" == *-* ]]; then
IS_PRERELEASE=true
fi
docker manifest create \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }} \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }}-x64 \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }}-arm64
docker manifest push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }}
if [[ "$IS_PRERELEASE" == "false" ]]; then
docker manifest create \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:latest \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }}-x64 \
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:${{ github.ref_name }}-arm64
docker manifest push ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:latest
else
echo "Skipping latest container tag for prerelease ${{ github.ref_name }}"
fi
- name: "Extract release notes"
shell: pwsh
run: |
$content = Get-Content RELEASE_NOTES.md -Raw
if ($content -match '(?s)(####.+?)(?=\n####|\z)') {
$Matches[1].Trim() | Set-Content RELEASE_NOTES_LATEST.md
} else {
$content | Set-Content RELEASE_NOTES_LATEST.md
}
- name: "Create GitHub Release"
run: |
PRERELEASE_FLAG=""
if [[ "$GITHUB_REF_NAME" == *-* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create "${{ github.ref_name }}" \
--title "SkillServer ${{ github.ref_name }}" \
$PRERELEASE_FLAG \
--notes-file RELEASE_NOTES_LATEST.md \
nuget/*.nupkg nuget/*.snupkg cli/*
env:
GH_TOKEN: ${{ github.token }}