Repository navigation
103 lines (89 loc) · 3.28 KB
/
Copy pathrelease.yml
File metadata and controls
103 lines (89 loc) · 3.28 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
name: Release
# Pushing a vX.Y.Z tag builds the VSIX, attaches it (with SHA-256 checksums)
# to a GitHub Release using the matching CHANGELOG section as notes, and —
# when a VSCE_PAT secret is configured — publishes to the VS Code Marketplace.
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to release (e.g. v0.8.4)"
required: true
type: string
permissions:
contents: write
env:
HAS_VSCE_PAT: ${{ secrets.VSCE_PAT != '' }}
jobs:
release:
name: Build & publish ${{ inputs.tag || github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag || github.ref }}
- uses: actions/setup-node@v7
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Verify tag matches package.json version
if: github.event_name == 'push'
run: |
PKG_VERSION="v$(node -p "require('./package.json').version")"
if [ "$PKG_VERSION" != "${{ github.ref_name }}" ]; then
echo "::error::Tag ${{ github.ref_name }} does not match package.json version $PKG_VERSION"
exit 1
fi
- name: Package VSIX
run: npx @vscode/vsce package --no-dependencies
- name: SHA-256 checksums
run: |
sha256sum brotherwhale-vscode-*.vsix | tee checksums.txt
- name: Compose release notes
run: |
VERSION="$(node -p "require('./package.json').version")"
{
echo "CodeWhale for VS Code **v${VERSION}**"
echo
echo "**Install:** download \`brotherwhale-vscode-${VERSION}.vsix\` from the assets below, then:"
echo
echo '```bash'
echo "code --install-extension brotherwhale-vscode-${VERSION}.vsix --force"
echo '```'
echo
echo "SHA-256 checksums are in \`checksums.txt\`."
echo
echo "---"
echo
node -e '
const fs = require("fs");
const v = process.argv[1];
const lines = fs.readFileSync("CHANGELOG.md", "utf8").split(/\r?\n/);
const start = lines.findIndex((l) => l === `## ${v}`);
if (start === -1) { console.error(`CHANGELOG.md has no section for ${v}`); process.exit(1); }
const rest = lines.slice(start + 1);
const end = rest.findIndex((l) => /^## /.test(l));
console.log((end === -1 ? rest : rest.slice(0, end)).join("\n").trim());
' "${VERSION}"
} > release-notes.md
head -20 release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ inputs.tag || github.ref_name }}
name: ${{ inputs.tag || github.ref_name }}
body_path: release-notes.md
files: |
brotherwhale-vscode-*.vsix
checksums.txt
- name: Publish to VS Code Marketplace
if: github.event_name == 'push' && env.HAS_VSCE_PAT == 'true'
run: npx @vscode/vsce publish --no-dependencies -p ${{ secrets.VSCE_PAT }}