Skip to content

Commit 83cee76

Browse files
committed
Automate GitHub prerelease builds
1 parent ae694ef commit 83cee76

5 files changed

Lines changed: 78 additions & 25 deletions

File tree

.github/workflows/release.yml

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Release
22

3-
# Runs when you push a version tag: git tag v99.0.12 && git push origin v99.0.12
43
on:
54
push:
5+
branches:
6+
- main
67
tags:
78
- 'v*'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: true
814

915
permissions:
1016
contents: write # needed to create the GitHub Release
@@ -25,31 +31,76 @@ jobs:
2531
node-version: '24'
2632
cache: 'npm'
2733

34+
- name: Cache VS Code test runtime
35+
uses: actions/cache@v4
36+
with:
37+
path: .vscode-test
38+
key: vscode-test-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
39+
restore-keys: |
40+
vscode-test-${{ runner.os }}-
41+
2842
- name: Install dependencies
2943
run: npm ci
3044

45+
- name: Build and typecheck
46+
run: npm run pretest
47+
48+
- name: Run tests
49+
run: npm test
50+
3151
# vsce package auto-calls vscode:prepublish (esbuild minify) before packing
3252
- name: Build & package VSIX
33-
env:
34-
RELEASE_TAG: ${{ github.ref_name }}
35-
run: npm run package:vsix
53+
run: |
54+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
55+
RELEASE_TAG="${GITHUB_REF_NAME}" npm run package:vsix
56+
else
57+
npm run package:vsix
58+
fi
59+
60+
- name: Upload VSIX artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: copilot-cockpit-vsix
64+
path: archive/vsix/latest/copilot-cockpit-*.vsix
3665

3766
# Generate release notes from CHANGELOG.md when present, otherwise write fallback notes
38-
- name: Extract changelog section
39-
run: node ./scripts/release-notes.js CHANGELOG.md release-notes.md
67+
- name: Generate release metadata
68+
shell: bash
69+
run: |
70+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
71+
echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
72+
echo "RELEASE_TITLE=Copilot Cockpit ${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
73+
echo "RELEASE_PRERELEASE=false" >> "$GITHUB_ENV"
74+
node ./scripts/release-notes.js CHANGELOG.md release-notes.md
75+
else
76+
echo "RELEASE_TAG=edge" >> "$GITHUB_ENV"
77+
echo "RELEASE_TITLE=Copilot Cockpit edge" >> "$GITHUB_ENV"
78+
echo "RELEASE_PRERELEASE=true" >> "$GITHUB_ENV"
79+
{
80+
echo "Automated prerelease from main."
81+
echo
82+
echo "- Commit: ${GITHUB_SHA}"
83+
echo "- Source ref: ${GITHUB_REF_NAME}"
84+
echo "- Trigger: push"
85+
echo "- Packaged from workspace version: $(node -p \"require('./package.json').version\")"
86+
} > release-notes.md
87+
fi
4088
4189
- name: Create or update GitHub Release with VSIX
4290
env:
4391
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
shell: bash
4493
run: |
45-
if gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then
46-
gh release upload "${{ github.ref_name }}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber
47-
gh release edit "${{ github.ref_name }}" \
48-
--title "Copilot Cockpit ${{ github.ref_name }}" \
49-
--notes-file release-notes.md
94+
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
95+
gh release upload "${RELEASE_TAG}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber
96+
gh release edit "${RELEASE_TAG}" \
97+
--title "${RELEASE_TITLE}" \
98+
--notes-file release-notes.md \
99+
$([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease || echo --latest)
50100
else
51-
gh release create "${{ github.ref_name }}" \
101+
gh release create "${RELEASE_TAG}" \
52102
archive/vsix/latest/copilot-cockpit-*.vsix \
53-
--title "Copilot Cockpit ${{ github.ref_name }}" \
54-
--notes-file release-notes.md
103+
--title "${RELEASE_TITLE}" \
104+
--notes-file release-notes.md \
105+
$([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease)
55106
fi

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "copilot-cockpit",
33
"displayName": "Copilot Cockpit",
44
"description": "Built on VS Code and GitHub Copilot: a native orchestration layer for AI workflows, MCP tools, scheduling, and human-in-the-loop execution",
5-
"version": "1.1.149",
5+
"version": "1.1.150",
66
"publisher": "local-dev",
77
"license": "SEE LICENSE IN LICENSE",
88
"icon": "images/icon.png",

scripts/release-utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const TEMP_ARTIFACTS = [
88
".tmp-package-vsix.log",
99
".tmp-playwright",
1010
".tmp-pretest.log",
11-
".vscode-test",
1211
"npm-test-output.log",
1312
"npm-test-output.txt",
1413
"npm-test.log",

src/test/suite/releaseUtils.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ suite("Release Pipeline Contract Tests", () => {
171171
const workflowPath = path.resolve(__dirname, "../../../.github/workflows/release.yml");
172172
const workflow = fs.readFileSync(workflowPath, "utf8");
173173

174-
assert.ok(workflow.includes("RELEASE_TAG: ${{ github.ref_name }}"));
175174
assert.ok(
176-
workflow.includes(
177-
"run: node ./scripts/release-notes.js CHANGELOG.md release-notes.md",
178-
),
175+
workflow.includes("branches:") && workflow.includes("- main"),
179176
);
180-
assert.ok(workflow.includes("gh release view \"${{ github.ref_name }}\" >/dev/null 2>&1"));
181-
assert.ok(workflow.includes("gh release upload \"${{ github.ref_name }}\" archive/vsix/latest/copilot-cockpit-*.vsix --clobber"));
182-
assert.ok(workflow.includes('gh release edit "${{ github.ref_name }}" \\'));
177+
assert.ok(workflow.includes("uses: actions/cache@v4"));
178+
assert.ok(workflow.includes("path: .vscode-test"));
179+
assert.ok(workflow.includes("run: npm run pretest"));
180+
assert.ok(workflow.includes("run: npm test"));
181+
assert.ok(workflow.includes("RELEASE_TAG=edge"));
182+
assert.ok(workflow.includes("node ./scripts/release-notes.js CHANGELOG.md release-notes.md"));
183+
assert.ok(workflow.includes('gh release view "${RELEASE_TAG}" >/dev/null 2>&1'));
184+
assert.ok(workflow.includes('gh release upload "${RELEASE_TAG}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber'));
185+
assert.ok(workflow.includes('gh release edit "${RELEASE_TAG}" \\'));
183186
});
184187
});

0 commit comments

Comments
 (0)