|
| 1 | +# Triggered when a git tag matching vscode-v* is pushed (e.g. vscode-v1.0.0 or vscode-v1.0.0-beta). |
| 2 | +# Extracts the version from the tag, patches package.json, and publishes to the VSCode Marketplace. |
| 3 | +# Any tag version with a pre-release suffix (e.g. -alpha, -beta) is published as a pre-release. |
| 4 | +# The VSCode Marketplace only accepts major.minor.patch, so the suffix is stripped from package.json |
| 5 | +# but used to determine whether to pass --pre-release to vsce. |
| 6 | +# |
| 7 | +# Requires a VSCE_PAT secret configured in GitHub repo settings: |
| 8 | +# Azure DevOps -> User Settings -> Personal Access Tokens -> scope: Marketplace (Manage) |
| 9 | +name: Release VSCode Extension |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - 'vscode-v*' |
| 15 | + |
| 16 | + # Allow manual triggering for testing (will publish with the provided version) |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + version: |
| 20 | + description: 'Version to publish (e.g. 1.0.0 or 1.0.0-beta)' |
| 21 | + required: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + publish: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Extract version from tag or input |
| 32 | + run: | |
| 33 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 34 | + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
| 35 | + else |
| 36 | + echo "VERSION=${GITHUB_REF#refs/tags/vscode-v}" >> $GITHUB_ENV |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Determine if pre-release and strip suffix for package.json |
| 40 | + run: | |
| 41 | + if [[ "${{ env.VERSION }}" == *"-"* ]]; then |
| 42 | + echo "PRE_RELEASE=--pre-release" >> $GITHUB_ENV |
| 43 | + echo "PACKAGE_VERSION=$(echo "${{ env.VERSION }}" | cut -d'-' -f1)" >> $GITHUB_ENV |
| 44 | + else |
| 45 | + echo "PRE_RELEASE=" >> $GITHUB_ENV |
| 46 | + echo "PACKAGE_VERSION=${{ env.VERSION }}" >> $GITHUB_ENV |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Setup Node.js |
| 50 | + uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version: '20' |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + working-directory: tools/vscode-extension |
| 56 | + run: npm install --ignore-scripts |
| 57 | + |
| 58 | + - name: Set version in package.json |
| 59 | + working-directory: tools/vscode-extension |
| 60 | + run: npm version ${{ env.PACKAGE_VERSION }} --no-git-tag-version |
| 61 | + |
| 62 | + - name: Publish to VSCode Marketplace |
| 63 | + working-directory: tools/vscode-extension |
| 64 | + run: npx vsce publish ${{ env.PRE_RELEASE }} --no-git-tag-version |
| 65 | + env: |
| 66 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
0 commit comments