Skip to content

Commit af1dd56

Browse files
committed
ci: add and fix extension workflows
1 parent 66580a7 commit af1dd56

14 files changed

Lines changed: 3383 additions & 364 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '22'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Compile TypeScript
27+
run: npm run compile
28+
29+
- name: Run tests
30+
run: xvfb-run -a npm test
31+
32+
- name: Package extension
33+
run: npx @vscode/vsce package
34+
35+
- name: Upload VSIX artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: vscode-capnp-extension
39+
path: '*.vsix'

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-vscode:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '22'
18+
cache: 'npm'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: "Publish to VS Code: Marketplace"
24+
run: npx @vscode/vsce publish -p ${{ secrets.VSCE_TOKEN }}
25+
26+
publish-openvsx:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '22'
36+
cache: 'npm'
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Publish to Open VSX
42+
run: npx ovsx publish -p ${{ secrets.OVSX_TOKEN }}

Makefile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Makefile for VS Code: Cap'n Proto Extension
2+
# Provides build, test, package, and publish targets
3+
4+
.PHONY: all build compile test clean package install publish publish-ovsx help check-tools
5+
6+
# Detect VS Code: CLI (code or codium)
7+
VSCODE_CLI := $(shell command -v code || command -v codium || echo "")
8+
9+
# Default target
10+
all: build
11+
12+
# Check required tools are installed
13+
check-tools:
14+
@which npm > /dev/null || (echo "ERROR: npm not found. Install Node.js first." && exit 1)
15+
@which node > /dev/null || (echo "ERROR: node not found. Install Node.js first." && exit 1)
16+
@echo "✓ Node.js and npm found"
17+
18+
# Build/compile the extension
19+
build: check-tools
20+
@echo "Building extension..."
21+
npm run compile
22+
23+
# Alias for build
24+
compile: build
25+
26+
# Watch mode for development
27+
watch: check-tools
28+
@echo "Starting watch mode..."
29+
npm run watch
30+
31+
# Clean build artifacts
32+
clean:
33+
@echo "Cleaning build artifacts..."
34+
rm -rf out/
35+
rm -f *.vsix
36+
37+
# Install dependencies
38+
install-deps: check-tools
39+
@echo "Installing dependencies..."
40+
npm install
41+
42+
# Run tests
43+
test: build
44+
@echo "Running tests..."
45+
@if [ ! -d "out/test" ]; then \
46+
echo "ERROR: Test files not compiled. Run 'make build' first."; \
47+
exit 1; \
48+
fi
49+
npm test
50+
51+
# Package the extension into .vsix file
52+
package: clean build
53+
@echo "Packaging extension..."
54+
@which npx > /dev/null || (echo "ERROR: npx not found." && exit 1)
55+
npx @vscode/vsce package
56+
57+
# Install the .vsix locally for testing
58+
install: package
59+
@if [ -z "$(VSCODE_CLI)" ]; then \
60+
echo "ERROR: Neither 'code' nor 'codium' CLI found."; \
61+
echo "Install VS Code: from https://code.visualstudio.com/"; \
62+
echo "For VSCodium, install from https://vscodium.com/"; \
63+
exit 1; \
64+
fi
65+
@echo "Installing extension using: $(VSCODE_CLI)"
66+
$(VSCODE_CLI) --install-extension $$(ls -t *.vsix | head -1)
67+
68+
# Publish to VS Code: Marketplace
69+
publish: package
70+
@echo "Publishing to VS Code: Marketplace..."
71+
@which npx > /dev/null || (echo "ERROR: npx not found." && exit 1)
72+
npx @vscode/vsce publish
73+
74+
# Publish to Open VSX Registry (for VSCodium)
75+
publish-ovsx: package
76+
@echo "Publishing to Open VSX..."
77+
@which npx > /dev/null || (echo "ERROR: npx not found." && exit 1)
78+
npx ovsx publish
79+
80+
# Quick publish workflow: package + publish to both
81+
publish-all: package
82+
@echo "Publishing to VS Code: Marketplace..."
83+
npx @vscode/vsce publish
84+
@echo "Publishing to Open VSX..."
85+
npx ovsx publish
86+
87+
# Login to VS Code: Marketplace (run once)
88+
login-vscode:
89+
@which npx > /dev/null || (echo "ERROR: npx not found." && exit 1)
90+
npx @vscode/vsce login xmonader
91+
92+
# Login to Open VSX (run once)
93+
login-ovsx:
94+
@which npx > /dev/null || (echo "ERROR: npx not found." && exit 1)
95+
npx ovsx login xmonader
96+
97+
# Development workflow - clean, install, build
98+
dev-setup: clean install-deps build
99+
@echo "Development setup complete!"
100+
101+
# Verify everything works (build + test)
102+
ci: build test
103+
@echo "✓ CI checks passed"
104+
105+
# Show help
106+
help:
107+
@echo "Available targets:"
108+
@echo " make build - Compile TypeScript sources"
109+
@echo " make compile - Alias for build"
110+
@echo " make watch - Start TypeScript watch mode"
111+
@echo " make clean - Remove build artifacts and .vsix files"
112+
@echo " make test - Run tests (builds first)"
113+
@echo " make package - Create .vsix package for distribution"
114+
@echo " make install - Install the .vsix locally for testing"
115+
@echo " make publish - Publish to VS Code: Marketplace"
116+
@echo " make publish-ovsx - Publish to Open VSX Registry"
117+
@echo " make publish-all - Publish to both marketplaces"
118+
@echo " make login-vscode - Login to VS Code: Marketplace"
119+
@echo " make login-ovsx - Login to Open VSX"
120+
@echo " make dev-setup - Full development setup"
121+
@echo " make ci - Run CI checks (build + test)"
122+
@echo " make help - Show this help message"

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Capnproto support for vscode
22

3+
![CI](https://github.com/xmonader/vscode-capnp/workflows/CI/badge.svg)
4+
35
Support for capnproto (http://capnproto.org/)
46

57
## Features
@@ -70,5 +72,26 @@ ovsx publish vscode-capnp-1.1.0.vsix -p <your-open-vsx-token>
7072
Get your token at https://open-vsx.org after signing in with GitHub.
7173

7274

75+
## Automated Publishing
76+
77+
The project includes GitHub Actions workflows for CI/CD:
78+
79+
### CI Workflow (`.github/workflows/ci.yml`)
80+
Runs on every push and pull request:
81+
- Compiles TypeScript
82+
- Runs tests
83+
- Packages the extension
84+
- Uploads the `.vsix` as an artifact
85+
86+
### Publish Workflow (`.github/workflows/publish.yml`)
87+
Triggers automatically when you create a GitHub release:
88+
- Publishes to VS Code: Marketplace (requires `VSCE_TOKEN` secret)
89+
- Publishes to Open VSX (requires `OVSX_TOKEN` secret)
90+
91+
#### Setting up secrets:
92+
1. Go to Settings → Secrets and variables → Actions
93+
2. Add `VSCE_TOKEN` - Your VS Code: Marketplace PAT
94+
3. Add `OVSX_TOKEN` - Your Open VSX token
95+
7396
## Credits
7497
https://github.com/textmate/capnproto.tmbundle (For textmate language grammar)

out/test/extension.test.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

out/test/extension.test.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

out/test/index.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

out/test/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)