-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (99 loc) · 3.63 KB
/
release.yml
File metadata and controls
114 lines (99 loc) · 3.63 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write # needed to create the GitHub Release
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Cache VS Code test runtime
uses: actions/cache@v5
with:
path: .vscode-test
key: vscode-test-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
vscode-test-${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Build and typecheck
run: npm run pretest
- name: Ensure Xvfb is available
shell: bash
run: |
if ! command -v xvfb-run >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y xvfb
fi
- name: Run tests
shell: bash
run: xvfb-run -a --server-args="-screen 0 1280x1024x24" npm test
# vsce package auto-calls vscode:prepublish (esbuild minify) before packing
- name: Build & package VSIX
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
RELEASE_TAG="${GITHUB_REF_NAME}" npm run package:vsix
else
npm run package:vsix
fi
- name: Upload VSIX artifact
uses: actions/upload-artifact@v6
with:
name: copilot-cockpit-vsix
path: archive/vsix/latest/copilot-cockpit-*.vsix
# Generate release notes from CHANGELOG.md when present, otherwise write fallback notes
- name: Generate release metadata
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
echo "RELEASE_TITLE=Copilot Cockpit ${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
echo "RELEASE_PRERELEASE=false" >> "$GITHUB_ENV"
node ./scripts/release-notes.js CHANGELOG.md release-notes.md
else
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
echo "RELEASE_TAG=edge" >> "$GITHUB_ENV"
echo "RELEASE_TITLE=Copilot Cockpit edge" >> "$GITHUB_ENV"
echo "RELEASE_PRERELEASE=true" >> "$GITHUB_ENV"
{
echo "Automated prerelease from main."
echo
echo "- Commit: ${GITHUB_SHA}"
echo "- Source ref: ${GITHUB_REF_NAME}"
echo "- Trigger: push"
echo "- Packaged from workspace version: ${PACKAGE_VERSION}"
} > release-notes.md
fi
- name: Create or update GitHub Release with VSIX
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
gh release upload "${RELEASE_TAG}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber
gh release edit "${RELEASE_TAG}" \
--title "${RELEASE_TITLE}" \
--notes-file release-notes.md \
$([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease || echo --latest)
else
gh release create "${RELEASE_TAG}" \
archive/vsix/latest/copilot-cockpit-*.vsix \
--title "${RELEASE_TITLE}" \
--notes-file release-notes.md \
$([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease)
fi