-
Notifications
You must be signed in to change notification settings - Fork 12
125 lines (101 loc) · 3.61 KB
/
Copy pathrelease.yml
File metadata and controls
125 lines (101 loc) · 3.61 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
name: Release
on:
push:
tags:
- "*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to publish, for example 0.6.2"
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Build And Publish Release
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}
- name: Cache VS Code test runtime
uses: actions/cache@v4
with:
path: gateway-vscode/.vscode-test/vscode-*
key: vscode-test-v1-${{ runner.os }}-${{ runner.arch }}-1.106.1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@10.25.0 --activate
pnpm --version
- name: Build release artifacts
run: ./build_release.sh
- name: Run unit tests
run: pnpm test
- name: Run VS Code Extension Host tests
env:
WEBCODE_EVAL_VSCODE_PATH: download
VSCODE_TEST_VERSION: "1.106.1"
run: xvfb-run -a pnpm test:extension
- name: Extract release notes
run: |
node --input-type=module <<'EOF'
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const rawTag = process.env.RELEASE_TAG.replace(/^refs\/tags\//, "");
const version = rawTag.startsWith("v") ? rawTag.slice(1) : rawTag;
if (!/^\d+\.\d+\.\d+$/.test(version)) {
throw new Error(`Release tag must be a semver version, got ${rawTag}`);
}
function readVersionNotes(locale) {
const filePath = join("changelogs", locale, `v${version}.md`);
let content = "";
try {
content = readFileSync(filePath, "utf8");
} catch (error) {
throw new Error(`Could not read release notes file ${filePath}: ${error.message}`);
}
const normalized = content.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").trim();
if (!normalized) {
throw new Error(`Release notes file is empty: ${filePath}`);
}
const lines = normalized.split("\n");
if (lines[0]?.startsWith("# ")) {
lines.shift();
}
const notes = lines.join("\n").trim();
if (!notes) {
throw new Error(`Release notes file has no body after title: ${filePath}`);
}
return notes;
}
const englishNotes = readVersionNotes("en");
const chineseNotes = readVersionNotes("zh");
const releaseNotes = `# webcode ${version}
## English
${englishNotes}
## 中文
${chineseNotes}
`;
writeFileSync("release-notes.md", releaseNotes);
EOF
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ env.RELEASE_TAG }}
run: |
VERSION="${TAG_NAME#v}"
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
gh release upload "${TAG_NAME}" release/* --clobber
gh release edit "${TAG_NAME}" --title "webcode ${VERSION}" --notes-file release-notes.md
else
gh release create "${TAG_NAME}" release/* --title "webcode ${VERSION}" --notes-file release-notes.md --verify-tag
fi