From 47902e62c87c58379c03b2382362c357b03940f4 Mon Sep 17 00:00:00 2001 From: Emanuele Bartolesi Date: Mon, 8 Sep 2025 17:13:30 +0200 Subject: [PATCH] feat: update GitHub Actions workflow and package version for VS Code extension - Enhanced the GitHub Actions workflow to check out the base branch of the pull request for accurate builds. - Added steps to read package metadata and ensure the VSCE token is provided before publishing. - Updated the version in package.json from 0.7.1 to 0.7.2 to reflect the new changes. --- .github/workflows/publish-extension.yml | 33 ++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-extension.yml b/.github/workflows/publish-extension.yml index b3f0b7e..fd13300 100644 --- a/.github/workflows/publish-extension.yml +++ b/.github/workflows/publish-extension.yml @@ -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 @@ -31,6 +36,13 @@ 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 + - name: Upload VSIX artifact (optional) uses: actions/upload-artifact@v4 with: @@ -38,10 +50,29 @@ jobs: 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/package.json b/package.json index 8f241fa..99c6716 100644 --- a/package.json +++ b/package.json @@ -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",