fix: publish workflow (#5) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🚀 Publish to the Visual Studio Marketplace | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The version to release (e.g. x.x.x or major, minor, patch) | |
required: false | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check it | |
uses: actions/checkout@v4 | |
- name: Prepare it | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Install it | |
run: npm clean-install | |
- name: Version it | |
if: ${{ github.event_name == 'workflow_dispatch' }} && ${{ github.event.inputs.version }} | |
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version | |
- name: Package it | |
id: package | |
run: | | |
npm exec vsce package | |
echo "filename=$(ls *.vsix)" >> $GITHUB_OUTPUT | |
- name: Publish it | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
run: npm exec vsce publish -- --packagePath ${{ steps.package.outputs.filename }} | |
- name: Configure it | |
id: config | |
run: | | |
echo "version=$(node --print "require('./package.json').version")" >> $GITHUB_OUTPUT | |
echo "preview=$(node --print "require('./package.json').preview")" >> $GITHUB_OUTPUT | |
- name: Release it | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.config.outputs.version }} | |
release_name: v${{ steps.config.outputs.version }} | |
prerelease: ${{ steps.config.outputs.preview }} | |
body: | | |
# v${{ steps.config.outputs.version }} | |
see [CHANGELOG.md](CHANGELOG.md) for details on this release | |
- name: Upload it | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release.outputs.upload_url }} | |
asset_name: ${{ steps.package.outputs.filename }} | |
asset_path: ${{ steps.package.outputs.filename }} | |
asset_content_type: application/zip |