Skip to content

Build and deploy extension #5

Build and deploy extension

Build and deploy extension #5

Workflow file for this run

name: Build and deploy extension
on:
workflow_dispatch:
inputs:
publish:
description: Publish to marketplaces.
type: boolean
default: true
bump_version:
description: Whether to increment the version number before publishing.
type: boolean
default: true
new_version:
description: The new version, passed to the `npm version` command. Has no effect if bump_version is off.
type: choice
required: true
options:
- major
- minor
- patch
pre_release:
description: Whether to release as a pre-release version.
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
version:
name: Increment version
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- name: Setup Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
with:
node-version: 20
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Configure Git
run: |
git config --global user.name 'Release Bot'
git config --global user.email 'modularbot@modular.com'
- name: Bump version
if: ${{ inputs.bump_version }}
run: npm version ${{ inputs.new_version }}
- name: Push version bump
if: ${{ inputs.bump_version }}
run: git push
- name: Extract package version
id: bump
run: |
export VERSION=$(jq -r '.version' package.json)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
build:
needs: [version]
uses: ./.github/workflows/build.yaml
publish:
name: Publish extension
runs-on: ubuntu-latest
needs: [version, build]
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: ./.github/actions/setup
- name: Download built VSIX
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
id: download
with:
name: ${{ needs.build.outputs.artifact-id }}
- name: Enable pre-release builds
if: ${{ inputs.pre_release }}
run: |
echo "PUBLISH_FLAGS=--pre-release" >> "$GITHUB_ENV"
- name: Upload extension to VS Code marketplace
if: ${{ inputs.publish }}
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx vsce publish $PUBLISH_FLAGS --packagePath "${{ steps.download.outputs.download-path }}/vscode-mojo.vsix" --skip-duplicate
- name: Upload extension to Open-VSX marketplace
if: ${{ inputs.publish }}
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: npx ovsx publish $PUBLISH_FLAGS --packagePath "${{ steps.download.outputs.download-path }}/vscode-mojo.vsix" --skip-duplicate
- name: Create release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8
with:
draft: true
tag_name: v${{ needs.version.output.version }}
release_name: v${{ needs.version.output.version }}
token: ${{ github.token }}
files: ${{ steps.download.outputs.download-path }}
generate_release_notes: true