Skip to content

Commit ea1e0ca

Browse files
committed
ci(workflow): add tag-triggered release upload and conditional Marketplace publish
1 parent 2ff5ab6 commit ea1e0ca

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/package-vsce.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ name: Package VS Code extension
33
on:
44
push:
55
branches: [ main ]
6-
workflow_dispatch: {}
6+
tags: ['v*']
7+
workflow_dispatch:
8+
inputs:
9+
publish:
10+
description: 'Publish to VS Code Marketplace (true/false)'
11+
required: false
12+
default: 'false'
713

814
jobs:
915
package:
@@ -44,3 +50,36 @@ jobs:
4450
with:
4551
name: easyjade-vsix
4652
path: ${{ steps.package.outputs.vsix_file }}
53+
54+
- name: Create GitHub Release
55+
if: startsWith(github.ref, 'refs/tags/')
56+
id: create_release
57+
uses: actions/create-release@v1
58+
with:
59+
tag_name: ${{ github.ref_name }}
60+
release_name: ${{ github.ref_name }}
61+
body: "Automated package for ${{ github.ref_name }}"
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Upload VSIX to Release
66+
if: startsWith(github.ref, 'refs/tags/')
67+
uses: actions/upload-release-asset@v1
68+
with:
69+
upload_url: ${{ steps.create_release.outputs.upload_url }}
70+
asset_path: ${{ steps.package.outputs.vsix_file }}
71+
asset_name: ${{ steps.package.outputs.vsix_file }}
72+
asset_content_type: application/octet-stream
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Publish to VS Code Marketplace
77+
if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true') }}
78+
env:
79+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
80+
run: |
81+
if [ -z "$VSCE_PAT" ]; then
82+
echo "VSCE_PAT secret not set; skipping publish"
83+
exit 1
84+
fi
85+
npx --yes @vscode/vsce publish --pat $VSCE_PAT

0 commit comments

Comments
 (0)