Skip to content

Commit 2c6e200

Browse files
authored
feat(workflows): add reusable workflows for VS Code extensions (#60)
Add vsc-vsix-build.yml and vsc-vsix-publish.yml for building and publishing VS Code extensions, following the same pattern as the existing vsix-build.yml and vsix-publish.yml for Visual Studio. - vsc-vsix-build: checkout, npm ci, lint, test, build, package, upload - vsc-vsix-publish: version (calendar), publish, release, social posts
1 parent 697957c commit 2c6e200

2 files changed

Lines changed: 230 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: VSC VSIX Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
extension-name:
7+
description: 'The extension name (e.g., VSC-MCPServer)'
8+
required: true
9+
type: string
10+
node-version:
11+
description: 'Node.js version to use'
12+
required: false
13+
type: string
14+
default: '20'
15+
run-lint:
16+
description: 'Whether to run linting'
17+
required: false
18+
type: boolean
19+
default: true
20+
run-tests:
21+
description: 'Whether to run tests'
22+
required: false
23+
type: boolean
24+
default: true
25+
26+
env:
27+
VSIX_FILE: CodingWithCalvin.${{ inputs.extension-name }}.vsix
28+
29+
jobs:
30+
build:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ inputs.node-version }}
40+
cache: 'npm'
41+
42+
- name: Install dependencies
43+
run: npm ci
44+
45+
- name: Run linting
46+
if: inputs.run-lint
47+
run: npm run lint
48+
49+
- name: Run tests
50+
if: inputs.run-tests
51+
run: npm run test
52+
53+
- name: Build extension
54+
run: npm run build
55+
56+
- name: Package VSIX
57+
run: npx @vscode/vsce package -o ${{ env.VSIX_FILE }}
58+
59+
- name: Upload VSIX artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: vsix
63+
path: ${{ env.VSIX_FILE }}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: VSC VSIX Publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
extension-name:
7+
description: 'The extension name (e.g., VSC-MCPServer)'
8+
required: true
9+
type: string
10+
display-name:
11+
description: 'Human readable display name (e.g., "VSC as MCP")'
12+
required: true
13+
type: string
14+
marketplace-id:
15+
description: 'VS Code Marketplace ID (e.g., CodingWithCalvin.VSC-MCPServer)'
16+
required: true
17+
type: string
18+
description:
19+
description: 'Short description for social media embeds'
20+
required: true
21+
type: string
22+
hashtags:
23+
description: 'Additional hashtags for social posts (optional)'
24+
required: false
25+
type: string
26+
default: ''
27+
node-version:
28+
description: 'Node.js version to use'
29+
required: false
30+
type: string
31+
default: '20'
32+
run-tests:
33+
description: 'Whether to run tests before publishing'
34+
required: false
35+
type: boolean
36+
default: true
37+
secrets:
38+
VS_PAT:
39+
description: 'VS Code Marketplace PAT'
40+
required: true
41+
BLUESKY_USERNAME:
42+
description: 'BlueSky username'
43+
required: true
44+
BLUESKY_APP_PASSWORD:
45+
description: 'BlueSky app password'
46+
required: true
47+
X_CONSUMER_KEY:
48+
description: 'X API consumer key'
49+
required: true
50+
X_CONSUMER_KEY_SECRET:
51+
description: 'X API consumer key secret'
52+
required: true
53+
X_ACCESS_TOKEN:
54+
description: 'X API access token'
55+
required: true
56+
X_ACCESS_TOKEN_SECRET:
57+
description: 'X API access token secret'
58+
required: true
59+
60+
env:
61+
VSIX_FILE: CodingWithCalvin.${{ inputs.extension-name }}.vsix
62+
63+
jobs:
64+
publish:
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
outputs:
69+
version: ${{ steps.version.outputs.version }}
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: ${{ inputs.node-version }}
80+
cache: 'npm'
81+
82+
- name: Install dependencies
83+
run: npm ci
84+
85+
- name: Run tests
86+
if: inputs.run-tests
87+
run: npm run test
88+
89+
- name: Build extension
90+
run: npm run build
91+
92+
- name: Set version
93+
id: version
94+
run: |
95+
VERSION=$(date +'%Y.%m%d').${{ github.run_number }}
96+
npm version $VERSION --no-git-tag-version --allow-same-version
97+
echo "version=$VERSION" >> $GITHUB_OUTPUT
98+
99+
- name: Package VSIX
100+
run: npx @vscode/vsce package -o ${{ env.VSIX_FILE }}
101+
102+
- name: Publish to VS Code Marketplace
103+
run: npx @vscode/vsce publish -p ${{ secrets.VS_PAT }}
104+
105+
- name: Upload VSIX artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: vsix
109+
path: ${{ env.VSIX_FILE }}
110+
111+
changelog:
112+
needs: publish
113+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
114+
secrets: inherit
115+
116+
release:
117+
needs: [publish, changelog]
118+
runs-on: ubuntu-latest
119+
permissions:
120+
contents: write
121+
steps:
122+
- name: Download VSIX artifact
123+
uses: actions/download-artifact@v4
124+
with:
125+
name: vsix
126+
127+
- name: Create GitHub Release
128+
uses: softprops/action-gh-release@v1
129+
with:
130+
tag_name: v${{ needs.publish.outputs.version }}
131+
name: v${{ needs.publish.outputs.version }}
132+
body: ${{ needs.changelog.outputs.changelog }}
133+
files: CodingWithCalvin.${{ inputs.extension-name }}.vsix
134+
135+
bluesky:
136+
needs: [publish, release]
137+
uses: CodingWithCalvin/.github/.github/workflows/bluesky-post.yml@main
138+
with:
139+
post_text: |
140+
🚀 ${{ inputs.display-name }} v${{ needs.publish.outputs.version }} has been released!
141+
142+
[GitHub Release](https://github.com/${{ github.repository }}/releases/tag/v${{ needs.publish.outputs.version }})
143+
[VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=${{ inputs.marketplace-id }})
144+
145+
#vscode ${{ inputs.hashtags }}
146+
embed_title: "${{ inputs.display-name }} v${{ needs.publish.outputs.version }}"
147+
embed_description: ${{ inputs.description }}
148+
secrets:
149+
BLUESKY_USERNAME: ${{ secrets.BLUESKY_USERNAME }}
150+
BLUESKY_APP_PASSWORD: ${{ secrets.BLUESKY_APP_PASSWORD }}
151+
152+
x:
153+
needs: [publish, release]
154+
uses: CodingWithCalvin/.github/.github/workflows/x-post.yml@main
155+
with:
156+
post_text: |
157+
🚀 ${{ inputs.display-name }} v${{ needs.publish.outputs.version }} has been released!
158+
159+
GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${{ needs.publish.outputs.version }}
160+
VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=${{ inputs.marketplace-id }}
161+
162+
#vscode ${{ inputs.hashtags }}
163+
secrets:
164+
X_CONSUMER_KEY: ${{ secrets.X_CONSUMER_KEY }}
165+
X_CONSUMER_KEY_SECRET: ${{ secrets.X_CONSUMER_KEY_SECRET }}
166+
X_ACCESS_TOKEN: ${{ secrets.X_ACCESS_TOKEN }}
167+
X_ACCESS_TOKEN_SECRET: ${{ secrets.X_ACCESS_TOKEN_SECRET }}

0 commit comments

Comments
 (0)