Skip to content

Commit c430b34

Browse files
committed
feat: improve release workflow
1 parent 6845fa7 commit c430b34

3 files changed

Lines changed: 66 additions & 65 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ jobs:
5454
# Run standard tests and the package activation test
5555
xvfb-run -a sh -c "npm run test:all && npm run test:package"
5656
57-
- name: Build webview
58-
run: npm run build:webview # Use renamed script
59-
60-
- name: Compile extension
61-
run: npm run compile # This already includes build:webview
57+
- name: Compile extension and webview
58+
run: npm run compile # This includes build:webview
6259

6360
release:
6461
name: Build and Release Extension
@@ -94,10 +91,6 @@ jobs:
9491
cd webview-ui
9592
npm install --no-fund --no-audit
9693
97-
- name: Update Version
98-
run: |
99-
sed -i "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"${{ steps.version.outputs.version }}\"/" package.json
100-
10194
- name: Install Xvfb
10295
run: |
10396
sudo apt-get update
@@ -106,8 +99,9 @@ jobs:
10699
- name: Package Extension
107100
run: |
108101
mkdir -p dist
109-
# Use xvfb for compile step in case it launches VS Code
110-
xvfb-run -a npm run compile
102+
# Compile using production settings (if different, otherwise compile is fine)
103+
# Assuming compile handles production build logic if needed based on env or flags
104+
xvfb-run -a npm run compile
111105
# Package using vsce directly, dependencies are bundled by esbuild
112106
npx @vscode/vsce package --no-yarn -o dist/goose-vscode-${{ steps.version.outputs.version }}.vsix
113107

docs/DEVELOPMENT.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For architectural details, see [ARCHITECTURE.md](./ARCHITECTURE.md).
1818

1919
The extension uses a multi-step build process defined in `package.json` scripts:
2020

21-
1. **`npm run build:extension`**: Uses `esbuild` to bundle the main extension code (`src/extension.ts` and its direct/indirect imports) into a single file (`out/extension.js`) with a sourcemap. This significantly reduces the package size and improves load times. The `vscode` module is marked as external as it's provided by the VS Code runtime.
21+
1. **`npm run build:extension`**: Uses `esbuild` to bundle the main extension code (`src/extension.ts` and its direct/indirect imports) into a single file (`out/extension.js`) with a sourcemap. This significantly reduces the package size and improves load times. The `vscode` module is marked as external as it's provided by the VS Code runtime. Dependencies listed in `devDependencies` (like `yaml`) should be correctly bundled.
2222
2. **`npm run compile:tests`**: Uses the TypeScript compiler (`tsc`) based on the specific `tsconfig.tests.json` configuration. This compiles *only* the test files (`src/test/**/*.ts`) into JavaScript files within the `out/test/` directory, preserving the test file structure. This ensures test files are compiled separately from the main extension bundle and placed where the test runner expects them.
2323
3. **`npm run build:webview`**: Navigates to the `webview-ui/` directory, installs its dependencies, and runs its build process (using Vite) to create the optimized chat interface assets in `webview-ui/dist/`.
2424
4. **`npm run compile`**: Orchestrates the above steps, running `build:extension`, then `compile:tests`, then `build:webview`. This is the main script used for building the entire extension before testing or packaging. It ensures the main bundle is created first, followed by the separate compilation of tests, and finally the webview build.
@@ -61,36 +61,42 @@ For testing the webview UI components directly:
6161

6262
## Packaging and Releasing
6363

64-
### Packaging the Extension
64+
### Packaging the Extension (Manual)
6565

66-
Run packaging commands from the project root.
66+
While the official release packaging is handled by the GitHub workflow, you can manually package the extension for local testing or distribution using commands run from the project root.
6767

68-
The extension can be packaged into a `.vsix` file for distribution. There are several npm scripts available for packaging:
68+
The available npm scripts use `vsce` (VS Code Extension Manager) and rely on the standard build (`npm run compile`):
6969

70-
- `npm run package` - Runs tests, then packages the extension
71-
- `npm run package:dist` - Runs tests, then packages the extension into the `dist` directory with version number
72-
- `npm run package:skip-tests` - Skips tests and packages the extension
70+
- `npm run package`: Runs linting and all tests, then compiles and packages the extension into a `.vsix` file in the project root.
71+
- `npm run package:dist`: Runs linting and all tests, then compiles and packages the extension into the `dist/` directory, naming the file `goose-vscode-[version].vsix`.
72+
- `npm run package:skip-tests`: Skips linting and tests, compiles, and packages the extension into a `.vsix` file in the project root.
7373

74-
To package the extension for distribution:
74+
Example for creating a distributable package in the `dist` folder:
7575

7676
```bash
7777
npm run package:dist
7878
```
7979

80-
This will create a `.vsix` file in the `dist` directory with the name `goose-vscode-[version].vsix`.
80+
This will create a `.vsix` file in the `dist/` directory with the name `goose-vscode-[version].vsix`.
8181

8282
### Using the Release Script
8383

84-
A helper script is provided to simplify the release process:
84+
A helper script is provided to automate the version bumping, committing, and tagging process:
8585

8686
```bash
87-
./scripts/release.sh 0.1.0 # Replace with your desired version
87+
./scripts/release.sh <new_version>
88+
# Example: ./scripts/release.sh 0.1.0
8889
```
8990

90-
This script:
91-
1. Updates the version in `package.json`
92-
2. Packages the extension to the `dist` directory
93-
3. Provides instructions for creating a Git tag and pushing to GitHub
91+
This script performs the following actions:
92+
1. Updates the `version` in `package.json`.
93+
2. Runs `npm install` to update `package-lock.json`.
94+
3. Stages `package.json` and `package-lock.json`.
95+
4. Commits the changes with the message "Bump vscode extension to v<new_version>".
96+
5. Creates a Git tag named `vscode-v<new_version>`.
97+
6. Prints a confirmation message and reminds you to push the commit and tag (`git push && git push --tags`).
98+
99+
**Note:** This script no longer handles packaging. Packaging is now done automatically by the GitHub release workflow.
94100

95101
### GitHub Release Workflow
96102

@@ -114,13 +120,13 @@ Since direct commits to the main branch are restricted, follow this process for
114120

115121
2. Update the version in `package.json` and make any other necessary changes
116122
```bash
117-
./scripts/release.sh 0.1.0 # Creates the package and updates version
123+
./scripts/release.sh 0.1.0 # Updates version, runs npm install, commits, and tags
118124
```
119125

120-
3. Commit the changes:
126+
3. Push the commit and the new tag:
121127
```bash
122-
git add .
123-
git commit -m "Bump vscode extension to v0.1.0"
128+
git push origin release/vscode-v0.1.0
129+
# Do NOT push the tag from the feature branch
124130
```
125131

126132
4. Create a pull request and get it reviewed/approved
@@ -131,13 +137,15 @@ Since direct commits to the main branch are restricted, follow this process for
131137
git pull
132138
```
133139

134-
6. Create and push the tag from the main branch:
140+
6. Push the tag **from the main branch**:
135141
```bash
136-
git tag vscode-v0.1.0
137-
git push origin vscode-v0.1.0
142+
# Ensure you are on the main branch and it's up-to-date first!
143+
# git checkout main
144+
# git pull
145+
git push origin vscode-v0.1.0 # Push the specific tag created by the script
138146
```
139147

140-
This will trigger the GitHub workflow to create a release with the packaged extension.
148+
Pushing the tag (e.g., `vscode-v0.1.0`) from the `main` branch triggers the GitHub workflow to build, package, and create a release.
141149

142150
The workflow can also be triggered manually from the GitHub Actions tab, where you can specify the version to release.
143151

scripts/release.sh

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
#!/bin/bash
22

3-
# Script to help release a new version of the VS Code extension
3+
# Script to bump the version, update lockfile, commit, and tag for a new release.
4+
5+
set -e # Exit immediately if a command exits with a non-zero status.
46

57
# Check if a version is provided
68
if [ -z "$1" ]; then
7-
echo "Usage: ./release.sh <version>"
8-
echo "Example: ./release.sh 0.1.0"
9+
echo "Usage: ./scripts/release.sh <version>"
10+
echo "Example: ./scripts/release.sh 0.1.0"
911
exit 1
1012
fi
1113

1214
VERSION=$1
15+
TAG_NAME="vscode-v$VERSION"
16+
17+
echo "Bumping version to $VERSION..."
1318

1419
# Update the version in package.json
15-
sed -i.bak "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"$VERSION\"/" package.json
16-
rm package.json.bak
17-
18-
echo "Building and packaging extension..."
19-
npm run package:dist
20-
21-
# Verify the .vsix file was created
22-
if [ -f "dist/goose-vscode-$VERSION.vsix" ]; then
23-
echo "✅ Extension packaged successfully: dist/goose-vscode-$VERSION.vsix"
24-
else
25-
echo "❌ Packaging failed. Let's try with verbose output:"
26-
echo "Running with verbose flag..."
27-
mkdir -p dist
28-
npx @vscode/vsce package --no-dependencies --no-yarn -o dist/goose-vscode-$VERSION.vsix --verbose
29-
30-
if [ -f "dist/goose-vscode-$VERSION.vsix" ]; then
31-
echo "✅ Extension packaged successfully on second attempt: dist/goose-vscode-$VERSION.vsix"
32-
else
33-
echo "❌ Failed to create the .vsix file. See errors above."
34-
exit 1
35-
fi
36-
fi
20+
# Using node to parse/update JSON is safer than sed
21+
node -e "
22+
const fs = require('fs');
23+
const pkgPath = 'package.json';
24+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
25+
pkg.version = '$VERSION';
26+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
27+
console.log('Updated package.json version to', pkg.version);
28+
"
29+
30+
echo "Updating package-lock.json..."
31+
npm install
32+
33+
echo "Staging and committing version bump..."
34+
git add package.json package-lock.json
35+
git commit -m "Bump vscode extension to v$VERSION"
36+
37+
echo "Creating git tag $TAG_NAME..."
38+
git tag "$TAG_NAME"
3739

3840
echo ""
39-
echo "To release this version, you can:"
40-
echo "1. Commit the changes: git commit -am \"Bump vscode extension to v$VERSION\""
41-
echo "2. Tag the release: git tag vscode-v$VERSION"
42-
echo "3. Push the changes: git push && git push --tags"
43-
echo ""
44-
echo "This will trigger the GitHub workflow to create a release with the packaged extension."
41+
echo "✅ Version bumped to $VERSION, changes committed, and tag '$TAG_NAME' created."
42+
echo "Ready to be published. Run 'git push && git push --tags' to push the commit and tag."
43+
echo "The GitHub workflow should then create a release."

0 commit comments

Comments
 (0)