Skip to content

Commit a551efb

Browse files
authored
Add tag-driven publish workflow with GitHub Release (#17)
Pushing a v*.*.* tag now lints, tests, packages, publishes to the VS Code Marketplace and Open VSX, and creates a matching GitHub Release with the corresponding CHANGELOG section as the body and the .vsix attached. workflow_dispatch supports an optional pre-release toggle. Adds release:patch/minor/major scripts that bump, tag, and push in one shot to trigger the workflow.
1 parent a636bbb commit a551efb

3 files changed

Lines changed: 159 additions & 20 deletions

File tree

.github/workflows/publish.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
preRelease:
10+
description: 'Publish as pre-release on the VS Code Marketplace'
11+
type: boolean
12+
default: false
13+
openVsx:
14+
description: 'Also publish to Open VSX (Cursor / VSCodium / code-server)'
15+
type: boolean
16+
default: true
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
cache: npm
30+
31+
- name: Verify tag matches package.json version
32+
if: startsWith(github.ref, 'refs/tags/v')
33+
run: |
34+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
35+
PKG_VERSION=$(node -p "require('./package.json').version")
36+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
37+
echo "::error::Tag v$TAG_VERSION does not match package.json $PKG_VERSION"
38+
exit 1
39+
fi
40+
echo "Publishing version $PKG_VERSION"
41+
42+
- run: npm ci
43+
44+
- run: npm run lint
45+
46+
- run: npm run format:check
47+
48+
- run: npm test
49+
50+
- run: npm run compile
51+
52+
- run: npm run package
53+
54+
- name: Publish to VS Code Marketplace
55+
env:
56+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
57+
run: |
58+
if [ -z "$VSCE_PAT" ]; then
59+
echo "::error::VSCE_PAT secret is not configured. See PUBLISHING.md."
60+
exit 1
61+
fi
62+
npx vsce publish \
63+
--packagePath "$(ls *.vsix | head -1)" \
64+
${{ inputs.preRelease && '--pre-release' || '' }} \
65+
--pat "$VSCE_PAT"
66+
67+
- name: Publish to Open VSX
68+
if: ${{ github.event_name == 'push' || inputs.openVsx }}
69+
continue-on-error: true
70+
env:
71+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
72+
run: |
73+
if [ -z "$OVSX_PAT" ]; then
74+
echo "::warning::OVSX_PAT secret is not configured; skipping Open VSX publish."
75+
exit 0
76+
fi
77+
npx ovsx publish "$(ls *.vsix | head -1)" --pat "$OVSX_PAT"
78+
79+
- name: Extract CHANGELOG section for this version
80+
if: startsWith(github.ref, 'refs/tags/v')
81+
run: |
82+
PKG_VERSION=$(node -p "require('./package.json').version")
83+
awk -v ver="$PKG_VERSION" '
84+
BEGIN { gsub(/\./, "\\.", ver) }
85+
$0 ~ "^## \\[" ver "\\]" { flag=1; next }
86+
flag && /^## \[/ { exit }
87+
flag { print }
88+
' CHANGELOG.md > /tmp/release-notes.md
89+
if [ ! -s /tmp/release-notes.md ]; then
90+
echo "::warning::No CHANGELOG section found for v$PKG_VERSION; falling back to a placeholder."
91+
echo "Release v$PKG_VERSION" > /tmp/release-notes.md
92+
fi
93+
echo "--- Release notes for v$PKG_VERSION ---"
94+
cat /tmp/release-notes.md
95+
96+
- name: Create GitHub Release
97+
if: startsWith(github.ref, 'refs/tags/v')
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
body_path: /tmp/release-notes.md
101+
files: '*.vsix'
102+
fail_on_unmatched_files: true
103+
prerelease: ${{ inputs.preRelease }}
104+
105+
- uses: actions/upload-artifact@v4
106+
with:
107+
name: agent-device-vscode-vsix
108+
path: '*.vsix'
109+
if-no-files-found: error

PUBLISHING.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,47 @@ These steps assume the work that's already in this repo: the `package.json` `pub
2828

2929
The token is cached under `~/.vsce`. You won't need to re-paste it for subsequent publishes from the same machine.
3030

31-
## Each release
31+
## Automated release (preferred)
3232

33-
1. **Bump the version** in `package.json` (semver). Update `CHANGELOG.md` to add a section for the new version and move items out of `[Unreleased]`.
33+
Tag-driven via GitHub Actions. Push a `v*.*.*` tag to `main` and the **Publish** workflow (`.github/workflows/publish.yml`) runs lint, format, tests, compile, package, publishes to the VS Code Marketplace and Open VSX, and creates a matching GitHub Release with the `.vsix` attached and the corresponding `CHANGELOG.md` section as the body.
3434

35-
2. **Sanity check** — the same checks CI runs:
35+
### One-time secrets
36+
37+
In the repository settings → Secrets and variables → Actions, add:
38+
39+
- `VSCE_PAT` — Marketplace PAT (required, see one-time setup above)
40+
- `OVSX_PAT` — Open VSX PAT (optional; if absent the Open VSX step warns and skips)
41+
42+
### Each release
43+
44+
1. Update `CHANGELOG.md` — move items out of `[Unreleased]` into a new dated section.
45+
2. Run one of:
46+
47+
```bash
48+
npm run release:patch # 0.1.0 -> 0.1.1
49+
npm run release:minor # 0.1.0 -> 0.2.0
50+
npm run release:major # 0.1.0 -> 1.0.0
51+
```
52+
53+
Each script bumps `package.json`, creates a `Release vX.Y.Z` commit, tags `vX.Y.Z`, and pushes both with `--follow-tags`. The push triggers the workflow.
54+
55+
3. Watch the run at <https://github.com/azizbecha/agent-device-vscode/actions/workflows/publish.yml>. The workflow refuses to run if the tag and `package.json` version don't match.
56+
57+
4. Verify the listing at `https://marketplace.visualstudio.com/items?itemName=<publisher>.agent-device-vscode`. Open VSX shows up at `https://open-vsx.org/extension/<publisher>/agent-device-vscode`.
58+
59+
### Manual dispatch
60+
61+
Any time you want a publish without a tag (e.g. re-running a failed publish), use **Actions → Publish → Run workflow** in the GitHub UI. The dispatch supports two checkboxes:
62+
63+
- **Publish as pre-release** — adds `--pre-release` to `vsce publish`. Users opted into pre-releases get the new version; everyone else sees the previous stable.
64+
- **Also publish to Open VSX** — defaults on; uncheck to skip the Open VSX step.
65+
66+
## Local publish (fallback)
67+
68+
If the workflow is broken or you need to publish from a laptop:
69+
70+
1. Bump the version in `package.json` and update `CHANGELOG.md`.
71+
2. Sanity-check — the same checks CI runs:
3672

3773
```bash
3874
npm run lint
@@ -42,38 +78,29 @@ These steps assume the work that's already in this repo: the `package.json` `pub
4278
npm run package # produces agent-device-vscode-<version>.vsix
4379
```
4480

45-
3. **Smoke-install the `.vsix`** locally:
81+
3. Smoke-install the `.vsix`:
4682

4783
```bash
4884
code --install-extension agent-device-vscode-<version>.vsix
4985
```
5086

5187
Open a folder with `.ad` files, click the Agent Device tab, run a script.
5288

53-
4. **Publish**:
89+
4. Publish:
5490

5591
```bash
56-
npx vsce publish
92+
npx vsce publish # uses cached login from one-time setup
93+
npx vsce publish --pre-release # if you want it pre-release
5794
```
5895

59-
Or, to bump and publish in one step:
60-
61-
```bash
62-
npx vsce publish patch
63-
npx vsce publish minor
64-
npx vsce publish major
65-
```
66-
67-
These bump `package.json` for you, commit the bump, and tag.
68-
69-
5. **Tag and push** if you bumped manually:
96+
5. Tag and push:
7097

7198
```bash
7299
git tag v$(node -p "require('./package.json').version")
73-
git push --tags
100+
git push --follow-tags
74101
```
75102

76-
6. **Verify on the marketplace** at `https://marketplace.visualstudio.com/items?itemName=<publisher>.agent-device-vscode`.
103+
6. Verify on the marketplace.
77104

78105
## Pre-release vs stable
79106

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
"format": "oxfmt",
4444
"format:check": "oxfmt --check",
4545
"test": "vitest run",
46-
"test:watch": "vitest"
46+
"test:watch": "vitest",
47+
"release:patch": "npm version patch -m 'Release v%s' && git push --follow-tags",
48+
"release:minor": "npm version minor -m 'Release v%s' && git push --follow-tags",
49+
"release:major": "npm version major -m 'Release v%s' && git push --follow-tags"
4750
},
4851
"dependencies": {
4952
"agent-device": "^0.14.7"

0 commit comments

Comments
 (0)