Publish Extension #42
This file contains hidden or 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 Extension | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Enter version or major/minor/patch/none' | |
required: true | |
default: 'patch' | |
registry: | |
description: 'Enter registry to publish to: vsce, openvsx or both' | |
required: true | |
default: 'both' | |
type: choice | |
options: | |
- vsce | |
- openvsx | |
- both | |
prerelease: | |
description: "Mark this version as a pre-release" | |
type: boolean | |
default: false | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install --omit=dev | |
- name: Configure git and clean repo | |
if: ${{ github.event.inputs.version != 'none' }} | |
run: | | |
git reset --hard HEAD | |
git config --global user.name "GitHubActions" | |
git config --global user.email "[email protected]" | |
- name: Bump version and create git tag | |
if: ${{ github.event.inputs.version != 'none' }} | |
run: npm version ${{ github.event.inputs.version }} | |
- name: Package extension | |
run: npx @vscode/vsce package ${{ github.event.inputs.prerelease == 'true' && '--pre-release' || '' }} | |
- name: Upload VSIX package as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vscode-vibrancy-continued-${{ github.event.inputs.version }} | |
path: "*.vsix" | |
- name: Publish extension to VSCE | |
if: ${{ github.event.inputs.registry == 'vsce' || github.event.inputs.registry == 'both' }} | |
run: npx @vscode/vsce publish -p ${{ secrets.VSCE_TOKEN }} --allow-star-activation --packagePath *.vsix ${{ github.event.inputs.prerelease == 'true' && '--pre-release' || '' }} | |
- name: Publish extension to Open VSX | |
if: ${{ github.event.inputs.registry == 'openvsx' || github.event.inputs.registry == 'both' }} | |
env: | |
OPEN_VSX_TOKEN: ${{ secrets.OPEN_VSX_TOKEN }} | |
run: npx ovsx publish -p $OPEN_VSX_TOKEN --packagePath *.vsix ${{ github.event.inputs.prerelease == 'true' && '--pre-release' || '' }} | |
- name: Configure SSH key | |
if: ${{ github.event.inputs.version != 'none' }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/id_ed25519 | |
chmod 600 ~/.ssh/id_ed25519 | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
- name: Push changes | |
if: ${{ github.event.inputs.version != 'none' }} | |
run: | | |
# Extract the branch name from the GITHUB_REF | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
git push --tags origin $BRANCH_NAME |