-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (87 loc) · 3.63 KB
/
Copy pathvscode-release.yml
File metadata and controls
92 lines (87 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
name: VS Code Extension Release
# Publish to the VS Code Marketplace on a vscode-v* tag, mirroring how release.yml
# publishes npm on v* and jetbrains-release.yml publishes on jetbrains-v*. One
# surface, one tag prefix - a tag never publishes more than the surface it names.
#
# Requires a VSCE_PAT secret (a Marketplace Personal Access Token) on the
# `vscode-publish` environment. vsce reads the version to publish from
# packages/vscode/package.json, so bump that, tag vscode-v<version>, and push.
on:
push:
tags:
- 'vscode-v*'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
environment: vscode-publish
permissions:
contents: write # create the GitHub Release for this tag
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Verify release tag is on main
run: |
git fetch origin main --quiet
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
echo "::error::Tag ${{ github.ref_name }} (${{ github.sha }}) is not on main; refusing to publish."
exit 1
fi
echo "Release tag ${{ github.ref_name }} is on main; proceeding."
- name: Verify tag matches extension version
if: github.event_name != 'workflow_dispatch'
env:
REF_NAME: ${{ github.ref_name }}
run: |
TAG_VERSION="${REF_NAME#vscode-v}"
PKG_VERSION="$(node -p "require('./packages/vscode/package.json').version")"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag ${REF_NAME} does not match packages/vscode/package.json version ${PKG_VERSION}."
exit 1
fi
echo "Tag matches extension version ${PKG_VERSION}."
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm --filter asksql-vscode run build
- name: Publish to VS Code Marketplace
working-directory: packages/vscode
run: npx --yes @vscode/vsce@3.9.2 publish --no-dependencies
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
# Built from the same commit that was just published, so the attached file is
# what the Marketplace serves - handy for anyone installing from a .vsix.
- name: Package the VSIX for the release
working-directory: packages/vscode
run: npx --yes @vscode/vsce@3.9.2 package --no-dependencies -o asksql-vscode.vsix
- name: Release notes
id: notes
run: |
# %(contents) falls through to the tagged commit for a lightweight tag.
git fetch --force --tags --quiet
body=''
if [ "$(git for-each-ref --format='%(objecttype)' "refs/tags/$GITHUB_REF_NAME")" = 'tag' ]; then
body="$(git for-each-ref --format='%(contents)' "refs/tags/$GITHUB_REF_NAME")"
fi
{
echo 'body<<ASKSQL_EOF'
echo "$body"
echo 'ASKSQL_EOF'
} >> "$GITHUB_OUTPUT"
- name: Publish the GitHub Release
uses: softprops/action-gh-release@v3
with:
body: ${{ steps.notes.outputs.body }}
generate_release_notes: true
files: packages/vscode/asksql-vscode.vsix
fail_on_unmatched_files: true
# Optional: also publish to Open VSX (for VSCodium / Cursor / etc.).
# Uncomment and add an OVSX_PAT secret to enable.
# - name: Publish to Open VSX
# working-directory: packages/vscode
# run: npx --yes ovsx publish --no-dependencies -p ${{ secrets.OVSX_PAT }}