Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/publish-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ on:

jobs:
publish:
permissions:
contents: write
# Ensure we only run on merged PRs (not just closed)
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Check out the base branch (e.g., main) so we build/publish the merged result
ref: ${{ github.event.pull_request.base.ref }}

- name: Set up Node.js
uses: actions/setup-node@v4
Expand All @@ -31,17 +36,43 @@ jobs:
- name: Package extension
run: vsce package

- name: Read package metadata
id: get_meta
run: |
echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT
echo "name=$(node -p \"require('./package.json').name\")" >> $GITHUB_OUTPUT
echo "vsix=$(node -p \"const p=require('./package.json'); console.log(`${p.name}-${p.version}.vsix`)\")" >> $GITHUB_OUTPUT
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node command uses both -p (print) and console.log() which will output both the return value and the logged value. Use either node -p without console.log or node -e with console.log, but not both.

Suggested change
echo "vsix=$(node -p \"const p=require('./package.json'); console.log(`${p.name}-${p.version}.vsix`)\")" >> $GITHUB_OUTPUT
echo "vsix=$(node -p \"const p=require('./package.json'); `${p.name}-${p.version}.vsix`\")" >> $GITHUB_OUTPUT

Copilot uses AI. Check for mistakes.

- name: Upload VSIX artifact (optional)
uses: actions/upload-artifact@v4
with:
name: vsix
path: '*.vsix'
if-no-files-found: warn

- name: Check VSCE token is provided
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
run: |
if [ -z "${VSCE_PAT}" ]; then
echo "::error::VSCE_TOKEN secret is not set. Add it in Settings > Secrets and variables > Actions."
exit 1
fi

- name: Publish to Marketplace
env:
# Map your repo secret to the env var that vsce expects
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
run: |
# vsce reads token from VSCE_PAT; no need to pass --pat explicitly
vsce publish
vsce publish

- name: Create GitHub Release and upload asset
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_meta.outputs.version }}
name: v${{ steps.get_meta.outputs.version }}
files: ${{ steps.get_meta.outputs.vsix }}
draft: false
prerelease: false
generate_release_notes: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dropcomments",
"displayName": "DropComments",
"description": "DropComments is a Visual Studio Code extension that helps you automatically add comments to your code using AI.",
"version": "0.7.1",
"version": "0.7.2",
"icon": "img/DropCommentsLogo.png",
"repository": {
"type": "git",
Expand Down
Loading