Build and Publish VS Code Extension #6
Workflow file for this run
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: Build and Publish VS Code Extension | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Git user | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Push changes and tags | |
run: | | |
git push https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/AaronF86/VScode-syrupmode.git | |
git push --tags https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/AaronF86/VScode-syrupmode.git | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
- name: Install dependencies | |
run: | | |
npm install | |
npm install -g vsce | |
- name: Checkout the default branch | |
run: | | |
# Fetch the latest branches and check out the default branch (typically 'main' or 'master') | |
git fetch --all | |
git checkout $(git remote show origin | grep "HEAD branch" | sed 's/.*: //') # Dynamically check out the default branch | |
- name: Update version from tag | |
run: | | |
TAG=$(echo ${{ github.ref }} | sed 's/refs\/tags\///') # Remove 'refs/tags/' from the ref | |
TAG=$(echo $TAG | sed 's/^v//') # Remove leading 'v' if present | |
npm version $TAG --no-git-tag-version # Update version in package.json | |
- name: Package with vsce | |
run: npx vsce package | |
- name: Publish to VS Code Marketplace | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
run: | | |
# Get the path to the .vsix file created by vsce package | |
VSIX_FILE=$(ls *.vsix) | |
npx vsce publish --packagePath $VSIX_FILE --pat $VSCE_PAT |