Skip to content

Commit 63ad5c8

Browse files
author
sunzhongyi
committed
chore: github actions
1 parent 4635dbf commit 63ad5c8

File tree

7 files changed

+667
-49
lines changed

7 files changed

+667
-49
lines changed

.github/workflows/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the Commit Assistant VS Code extension.
4+
5+
## Workflows
6+
7+
### 1. Build and Test (`build.yml`)
8+
9+
**Triggers:**
10+
- Push to `main` or `develop` branches
11+
- Pull requests to `main` or `develop` branches
12+
- Manual dispatch
13+
14+
**What it does:**
15+
- Tests the extension on Node.js 18.x and 20.x
16+
- Compiles TypeScript code
17+
- Builds the webview components
18+
- Runs tests (if available)
19+
- Packages the extension into a `.vsix` file
20+
- Uploads build artifacts
21+
22+
### 2. Publish to Marketplace (`publish.yml`)
23+
24+
**Triggers:**
25+
- Push tags starting with `v` (e.g., `v1.0.0`)
26+
- Manual dispatch
27+
28+
**What it does:**
29+
- Builds the extension
30+
- Packages it into a `.vsix` file
31+
- Publishes to VS Code Marketplace
32+
- Creates GitHub release with the `.vsix` file attached
33+
- Supports both regular and pre-release publishing
34+
35+
## Setup Instructions
36+
37+
### 1. VS Code Marketplace Token
38+
39+
You need to set up a `VSCE_TOKEN` secret in your GitHub repository:
40+
41+
1. Go to [Visual Studio Marketplace Publisher Management](https://marketplace.visualstudio.com/manage)
42+
2. Sign in with your Microsoft account
43+
3. Create a publisher account if you don't have one
44+
4. Go to your publisher profile and create a Personal Access Token (PAT)
45+
5. In your GitHub repository, go to Settings → Secrets and variables → Actions
46+
6. Add a new repository secret named `VSCE_TOKEN` with your PAT as the value
47+
48+
### 2. Update package.json
49+
50+
Make sure your `package.json` has the correct publisher name:
51+
52+
```json
53+
{
54+
"publisher": "your-publisher-name"
55+
}
56+
```
57+
58+
### 3. Repository URL
59+
60+
Update the repository URL in `package.json`:
61+
62+
```json
63+
{
64+
"repository": {
65+
"type": "git",
66+
"url": "https://github.com/your-username/commit-assistant"
67+
}
68+
}
69+
```
70+
71+
## Publishing Process
72+
73+
### Regular Release
74+
75+
1. Update the version in `package.json`
76+
2. Commit your changes
77+
3. Create and push a tag:
78+
```bash
79+
git tag v1.0.0
80+
git push origin v1.0.0
81+
```
82+
4. The workflow will automatically publish to the marketplace
83+
84+
### Pre-release
85+
86+
1. Go to Actions tab in your GitHub repository
87+
2. Select "Publish to VS Code Marketplace"
88+
3. Click "Run workflow"
89+
4. Leave the version input empty to publish as pre-release
90+
91+
### Manual Release
92+
93+
1. Go to Actions tab in your GitHub repository
94+
2. Select "Publish to VS Code Marketplace"
95+
3. Click "Run workflow"
96+
4. Enter a version (e.g., `v1.0.0`) if needed
97+
98+
## Artifacts
99+
100+
Both workflows upload artifacts that you can download:
101+
102+
- **Build workflow**: Uploads `.vsix` files and build output
103+
- **Publish workflow**: Uploads the published `.vsix` file
104+
105+
## Troubleshooting
106+
107+
### Common Issues
108+
109+
1. **Publisher not found**: Make sure the `publisher` field in `package.json` matches your VS Code Marketplace publisher name
110+
111+
2. **Token expired**: VS Code Marketplace tokens expire. Generate a new one and update the `VSCE_TOKEN` secret
112+
113+
3. **Build failures**: Check the build logs in the Actions tab. Common issues include:
114+
- Missing dependencies
115+
- TypeScript compilation errors
116+
- Webview build failures
117+
118+
### Debug Tips
119+
120+
- Check the Actions tab for detailed logs
121+
- Ensure all dependencies are properly listed in `package.json`
122+
- Test the build locally with `npm run build` before pushing

.github/workflows/build.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [18.x, 20.x]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Compile TypeScript
32+
run: npm run compile
33+
34+
- name: Build webview
35+
run: npm run build:webview
36+
37+
- name: Run tests (if available)
38+
run: npm test --if-present
39+
40+
- name: Package extension
41+
run: |
42+
npm install -g @vscode/vsce
43+
vsce package --no-dependencies
44+
45+
- name: Upload VSIX artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: commit-assistant-${{ matrix.node-version }}-${{ github.sha }}
49+
path: "*.vsix"
50+
retention-days: 30
51+
52+
- name: Upload build artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: build-output-${{ matrix.node-version }}-${{ github.sha }}
56+
path: |
57+
out/
58+
!out/**/*.map
59+
retention-days: 7
60+
61+
lint:
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '20.x'
72+
cache: 'npm'
73+
74+
- name: Install dependencies
75+
run: npm ci
76+
77+
- name: Check TypeScript
78+
run: npx tsc --noEmit
79+
80+
- name: Check Svelte components (if svelte-check is available)
81+
run: |
82+
if command -v npx svelte-check &> /dev/null; then
83+
npx svelte-check --workspace webviews
84+
else
85+
echo "svelte-check not available, skipping Svelte type checking"
86+
fi

.github/workflows/publish.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Publish to VS Code Marketplace
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to publish (e.g., v1.0.0)'
11+
required: false
12+
default: ''
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build project
34+
run: npm run build
35+
36+
- name: Install VSCE
37+
run: npm install -g @vscode/vsce
38+
39+
- name: Verify package.json
40+
run: |
41+
echo "Checking package.json..."
42+
cat package.json | jq '.name, .version, .publisher'
43+
44+
- name: Package extension
45+
run: vsce package --no-dependencies
46+
47+
- name: List generated files
48+
run: ls -la *.vsix
49+
50+
- name: Publish to VS Code Marketplace
51+
run: vsce publish -p $VSCE_TOKEN --no-dependencies
52+
env:
53+
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
54+
55+
- name: Upload VSIX to GitHub Release
56+
if: startsWith(github.ref, 'refs/tags/')
57+
uses: softprops/action-gh-release@v1
58+
with:
59+
files: "*.vsix"
60+
generate_release_notes: true
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Upload VSIX artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: commit-assistant-release-${{ github.sha }}
68+
path: "*.vsix"
69+
retention-days: 90
70+
71+
pre-release:
72+
runs-on: ubuntu-latest
73+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version == ''
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: '20.x'
83+
cache: 'npm'
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build project
89+
run: npm run build
90+
91+
- name: Install VSCE
92+
run: npm install -g @vscode/vsce
93+
94+
- name: Package pre-release
95+
run: vsce package --pre-release --no-dependencies
96+
97+
- name: Publish pre-release to VS Code Marketplace
98+
run: vsce publish --pre-release -p $VSCE_TOKEN --no-dependencies
99+
env:
100+
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
101+
102+
- name: Upload pre-release VSIX artifact
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: commit-assistant-prerelease-${{ github.sha }}
106+
path: "*.vsix"
107+
retention-days: 30

.vscodeignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Source files
2+
webviews/**
3+
src/**
4+
*.ts
5+
!out/**/*.js
6+
7+
# Build and development files
8+
.vscode-test/**
9+
.vscode/**
10+
node_modules/**
11+
rollup.config.mjs
12+
tailwind.config.mjs
13+
postcss.config.js
14+
tsconfig.json
15+
webviews/tsconfig.json
16+
17+
# Development dependencies and configs
18+
.eslintrc.*
19+
.prettierrc.*
20+
.gitignore
21+
.github/**
22+
23+
# Documentation and examples
24+
README.md
25+
CHANGELOG.md
26+
docs/**
27+
examples/**
28+
29+
# Test files
30+
test/**
31+
tests/**
32+
**/*.test.js
33+
**/*.test.ts
34+
**/*.spec.js
35+
**/*.spec.ts
36+
37+
# Source maps (optional - remove if you want to include them)
38+
**/*.map
39+
40+
# Logs and temporary files
41+
*.log
42+
.DS_Store
43+
Thumbs.db
44+
45+
# Package manager files
46+
package-lock.json
47+
yarn.lock
48+
pnpm-lock.yaml
49+
50+
# IDE files
51+
.idea/**
52+
*.swp
53+
*.swo
54+
*~

0 commit comments

Comments
 (0)