11name : Publish to VS Code Marketplace
22
33on :
4- push :
5- tags :
6- - ' v*'
74 workflow_dispatch :
85 inputs :
96 version :
10- description : ' Version to publish (e.g., 1.0.0, leave empty to use package.json version)'
11- required : false
12- default : ' '
7+ description : ' Version to publish (e.g., 1.0.0)'
8+ required : true
9+ type : string
10+ release_type :
11+ description : ' Release type'
12+ required : true
13+ type : choice
14+ options :
15+ - ' release'
16+ - ' pre-release'
17+ default : ' release'
1318
1419jobs :
1520 publish :
1621 runs-on : ubuntu-latest
17-
22+
1823 steps :
1924 - name : Checkout code
2025 uses : actions/checkout@v4
21- with :
22- fetch-depth : 0
23-
26+
2427 - name : Setup Node.js
2528 uses : actions/setup-node@v4
2629 with :
2730 node-version : ' 20.x'
2831 cache : ' npm'
29-
32+
3033 - name : Install dependencies
3134 run : npm ci
32-
33- - name : Update version if specified
34- if : github.event.inputs.version != ''
35+
36+ - name : Update version
3537 run : |
3638 echo "Updating version to ${{ github.event.inputs.version }}"
3739 npm version ${{ github.event.inputs.version }} --no-git-tag-version
@@ -41,73 +43,46 @@ jobs:
4143
4244 - name : Install VSCE
4345 run : npm install -g @vscode/vsce
44-
45- - name : Verify package.json
46- run : |
47- echo "Checking package.json..."
48- cat package.json | jq '.name, .version, .publisher'
49-
46+
5047 - name : Package extension
51- run : vsce package
52-
53- - name : List generated files
54- run : ls -la *.vsix
55-
48+ run : |
49+ if [ "${{ github.event.inputs.release_type }}" = "pre-release" ]; then
50+ vsce package --pre-release
51+ else
52+ vsce package
53+ fi
54+
5655 - name : Publish to VS Code Marketplace
57- run : vsce publish -p $VSCE_TOKEN
56+ run : |
57+ if [ "${{ github.event.inputs.release_type }}" = "pre-release" ]; then
58+ vsce publish --pre-release -p "$VSCE_TOKEN"
59+ else
60+ vsce publish -p "$VSCE_TOKEN"
61+ fi
5862 env :
5963 VSCE_TOKEN : ${{ secrets.VSCE_TOKEN }}
60-
61- - name : Upload VSIX to GitHub Release
62- if : startsWith(github.ref, 'refs/tags/')
64+
65+ - name : Create Git Tag (for releases only)
66+ if : github.event.inputs.release_type == 'release'
67+ run : |
68+ git config --local user.email "[email protected] " 69+ git config --local user.name "GitHub Action"
70+ git tag "v${{ github.event.inputs.version }}"
71+ git push origin "v${{ github.event.inputs.version }}"
72+
73+ - name : Create GitHub Release (for releases only)
74+ if : github.event.inputs.release_type == 'release'
6375 uses : softprops/action-gh-release@v1
6476 with :
77+ tag_name : " v${{ github.event.inputs.version }}"
6578 files : " *.vsix"
6679 generate_release_notes : true
6780 env :
6881 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69-
82+
7083 - name : Upload VSIX artifact
7184 uses : actions/upload-artifact@v4
7285 with :
73- name : commit-assistant-release -${{ github.sha }}
86+ name : commit-assistant-${{ github.event.inputs.release_type }} -${{ github.event.inputs.version }}
7487 path : " *.vsix"
7588 retention-days : 90
76-
77- pre-release :
78- runs-on : ubuntu-latest
79- if : github.event_name == 'workflow_dispatch' && github.event.inputs.version == ''
80-
81- steps :
82- - name : Checkout code
83- uses : actions/checkout@v4
84-
85- - name : Setup Node.js
86- uses : actions/setup-node@v4
87- with :
88- node-version : ' 20.x'
89- cache : ' npm'
90-
91- - name : Install dependencies
92- run : npm ci
93-
94- - name : Build project
95- run : npm run build
96-
97- - name : Install VSCE
98- run : npm install -g @vscode/vsce
99-
100- - name : Package pre-release
101- run : vsce package --pre-release
102-
103- - name : Publish pre-release to VS Code Marketplace
104- run : vsce publish --pre-release -p $VSCE_TOKEN
105- env :
106- VSCE_TOKEN : ${{ secrets.VSCE_TOKEN }}
107-
108- - name : Upload pre-release VSIX artifact
109- uses : actions/upload-artifact@v4
110- with :
111- name : commit-assistant-prerelease-${{ github.sha }}
112- path : " *.vsix"
113- retention-days : 30
0 commit comments