-
Notifications
You must be signed in to change notification settings - Fork 4
297 lines (264 loc) · 10 KB
/
Copy pathrelease.yml
File metadata and controls
297 lines (264 loc) · 10 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
297
name: Release
# Publishes Terminal.Gui.Editor to NuGet.
#
# Triggers:
# 1. Push of a `v*` tag (canonical release path, e.g. v2.5.3)
# → Version = tag with leading `v` stripped.
# 2. Push to `develop` (rolling pre-release)
# → Version computed by GitVersion from git history + GitVersion.yml,
# e.g. 2.5.3-develop.7 (latest reachable tag + Patch, develop label).
#
# No version is stored in the repo; tags are the source of truth.
# The computed value is injected into builds via `-p:Version=...`.
on:
push:
tags: ['v*']
branches: [develop]
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
resolve-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v5
with:
# GitVersion needs full history + tags.
fetch-depth: 0
- name: Install GitVersion
if: github.ref_type != 'tag'
uses: gittools/actions/gitversion/setup@v4.5.0
with:
versionSpec: '6.x'
- name: Run GitVersion
if: github.ref_type != 'tag'
id: gitversion
# GitVersion.yml at the repo root is picked up automatically.
uses: gittools/actions/gitversion/execute@v4.5.0
- name: Compute version
id: v
shell: bash
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
# Tag form: v2.5.3 → 2.5.3 (the tag is canonical; no GitVersion needed)
VERSION="${GITHUB_REF_NAME#v}"
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
# GitVersion: latest reachable tag + Patch, develop label, commit count.
VERSION="${{ steps.gitversion.outputs.SemVer }}"
else
echo "::error::Unsupported trigger: event=${{ github.event_name }} ref=${{ github.ref }}"
exit 1
fi
if [ -z "$VERSION" ]; then
echo "::error::Could not resolve version."
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "## Release" >> "$GITHUB_STEP_SUMMARY"
echo "- version: \`$VERSION\`" >> "$GITHUB_STEP_SUMMARY"
echo "- trigger: \`${{ github.event_name }}\` (\`${{ github.ref }}\`)" >> "$GITHUB_STEP_SUMMARY"
build-and-test:
needs: resolve-version
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-arm64
- os: windows-latest
rid: win-x64
- os: windows-latest
rid: win-arm64
runs-on: ${{ matrix.os }}
env:
VERSION: ${{ needs.resolve-version.outputs.version }}
# Tells Terminal.Gui drivers to skip real-terminal probing/IO
# so the ANSI driver runs on Windows runners without a TTY.
DisableRealDriverIO: "1"
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Restore
run: dotnet restore Terminal.Gui.Editor.slnx
- name: Build
run: dotnet build Terminal.Gui.Editor.slnx --no-restore -c Release -p:Version=${{ env.VERSION }}
- name: Terminal.Gui.Editor.Tests
run: dotnet run --project tests/Terminal.Gui.Editor.Tests --no-build -c Release
- name: Terminal.Gui.Editor.IntegrationTests
run: dotnet run --project tests/Terminal.Gui.Editor.IntegrationTests --no-build -c Release
- name: Publish ted AOT
run: >
dotnet publish examples/ted -c Release
-r ${{ matrix.rid }}
--self-contained
-p:PublishAot=true
-p:Version=${{ env.VERSION }}
-o publish/${{ matrix.rid }}
- name: Upload ted artifact
uses: actions/upload-artifact@v4
with:
name: ted-${{ matrix.rid }}
path: publish/${{ matrix.rid }}/
retention-days: 30
pack-and-publish:
needs: [resolve-version, build-and-test]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.resolve-version.outputs.version }}
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Pack Terminal.Gui.Editor
run: dotnet pack src/Terminal.Gui.Editor -c Release -p:Version=${{ env.VERSION }} -o packages/
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: packages/*.nupkg
retention-days: 30
- name: Push to NuGet
run: >
dotnet nuget push packages/*.nupkg
--api-key ${{ secrets.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate
# Attach ted AOT binaries to the GitHub Release (tag pushes only).
# The Release is created by finalize-release.yml before the tag push triggers this workflow.
release-assets:
if: github.ref_type == 'tag'
needs: [resolve-version, build-and-test]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.resolve-version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@v5
- name: Download all ted artifacts
uses: actions/download-artifact@v4
with:
pattern: ted-*
path: artifacts/
- name: Package release archives
shell: bash
run: |
set -euo pipefail
mkdir -p dist
package_unix() {
local rid="$1"
local src="artifacts/ted-${rid}"
if [ ! -d "$src" ]; then
echo "::warning::No artifact for ${rid}, skipping"
return 0
fi
chmod +x "$src/ted" 2>/dev/null || true
tar -czf "dist/ted-${VERSION}-${rid}.tar.gz" -C "$src" .
echo "Created dist/ted-${VERSION}-${rid}.tar.gz"
}
package_windows() {
local rid="$1"
local src="artifacts/ted-${rid}"
if [ ! -d "$src" ]; then
echo "::warning::No artifact for ${rid}, skipping"
return 0
fi
(cd "$src" && zip -r "../../dist/ted-${VERSION}-${rid}.zip" .)
echo "Created dist/ted-${VERSION}-${rid}.zip"
}
package_unix osx-arm64
package_unix linux-x64
package_windows win-x64
package_windows win-arm64
ls -la dist/
- name: Upload to GitHub Release
shell: bash
run: |
TAG="${GITHUB_REF_NAME}"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" dist/* --clobber
else
echo "::warning::Release $TAG not found; creating one."
gh release create "$TAG" --title "ted $TAG" --generate-notes dist/*
fi
# Notify downstream repos (gui-cs/clet) so they can rebuild against the new Editor version.
# Uses a PAT stored as CLET_DISPATCH_TOKEN with `repo` scope on gui-cs/clet.
notify-downstream:
needs: [resolve-version, pack-and-publish]
runs-on: ubuntu-latest
continue-on-error: true # Non-blocking: missing secret shouldn't fail the release
env:
VERSION: ${{ needs.resolve-version.outputs.version }}
CLET_DISPATCH_TOKEN: ${{ secrets.CLET_DISPATCH_TOKEN }}
steps:
- name: Skip dispatch (no token configured)
if: ${{ env.CLET_DISPATCH_TOKEN == '' }}
run: echo "::warning::CLET_DISPATCH_TOKEN is not set; skipping downstream dispatch."
- name: Wait for NuGet flat-container to index the version
if: ${{ env.CLET_DISPATCH_TOKEN != '' }}
run: |
VER="${{ env.VERSION }}"
for i in $(seq 1 60); do
if curl -fsS https://api.nuget.org/v3-flatcontainer/terminal.gui.editor/index.json \
| jq -r '.versions[]' | grep -qx "$VER"; then
echo "Indexed on flat-container: $VER (after $((i*10))s)"
exit 0
fi
echo "Waiting for $VER on NuGet flat-container ($i/60, 10s each)..."
sleep 10
done
echo "::error::Timed out after 10min waiting for $VER on flat-container"
exit 1
- name: Dispatch to gui-cs/clet
if: ${{ env.CLET_DISPATCH_TOKEN != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ env.CLET_DISPATCH_TOKEN }}
script: |
const ref = context.ref;
const isMain = ref === 'refs/heads/main' || ref.startsWith('refs/tags/v');
const isDevelop = ref === 'refs/heads/develop';
const eventType = isMain ? 'editor-main-published' : isDevelop ? 'editor-develop-published' : null;
if (!eventType) {
console.log(`Skipping downstream dispatch for ref=${ref}`);
return;
}
await github.rest.repos.createDispatchEvent({
owner: 'gui-cs',
repo: 'clet',
event_type: eventType,
client_payload: { tge_version: process.env.VERSION }
});
console.log(`Dispatched ${eventType} with tge_version=${process.env.VERSION} to gui-cs/clet`);
notify-failure:
needs: [resolve-version, build-and-test, pack-and-publish]
if: failure()
runs-on: ubuntu-latest
permissions:
issues: write
env:
VERSION: ${{ needs.resolve-version.outputs.version }}
steps:
- uses: actions/github-script@v7
with:
script: |
await github.rest.issues.create ({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Release v${process.env.VERSION} failed`,
body: `The release workflow for \`${process.env.VERSION}\` failed.\n\nSee [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`,
labels: ['release-failure']
});