VSCode Extension #3
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: VSCode Extension | |
| on: | |
| # Tag pushes trigger the full validate + publish pipeline. | |
| push: | |
| tags: | |
| - 'vscode-forge/v*.*.*' | |
| - 'vscode-forge/v*.*.*-*' | |
| # PRs touching the extension trigger validation only. | |
| pull_request: | |
| branches: [main, develop] | |
| paths: ['vscode-forge/**'] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g. 0.2.0). Leave empty to use package.json version.' | |
| required: false | |
| type: string | |
| dry_run: | |
| description: 'Dry run — package but do not publish' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: vscode-forge | |
| jobs: | |
| # ------------------------------------------------------------------- | |
| # Job: validate | |
| # Compiles TypeScript, packages the .vsix, and uploads as artifact. | |
| # Runs on every push/PR that touches vscode-forge/. | |
| # ------------------------------------------------------------------- | |
| validate: | |
| name: Validate & Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: vscode-forge/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint (type-check) | |
| run: npm run lint | |
| - name: Compile | |
| run: npm run compile | |
| - name: Package extension | |
| run: npx @vscode/vsce package --no-dependencies | |
| - name: List packaged contents | |
| run: npx @vscode/vsce ls --no-dependencies | |
| - name: Upload .vsix artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forge-devtools-vsix | |
| path: vscode-forge/*.vsix | |
| retention-days: 30 | |
| # ------------------------------------------------------------------- | |
| # Job: publish | |
| # Publishes to VS Code Marketplace and Open VSX Registry. | |
| # Runs only on version tags or manual dispatch (when not dry_run). | |
| # ------------------------------------------------------------------- | |
| publish: | |
| name: Publish Extension | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| if: >- | |
| (startsWith(github.ref, 'refs/tags/vscode-forge/v')) | |
| || (github.event_name == 'workflow_dispatch' && inputs.dry_run != true) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: vscode-forge/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Resolve version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| VERSION="${{ inputs.version }}" | |
| npm version "$VERSION" --no-git-tag-version | |
| else | |
| VERSION=$(node -p "require('./package.json').version") | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| if [[ "$VERSION" == *"-"* ]]; then | |
| echo "is_prerelease=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "is_prerelease=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| echo "::notice::Publishing forge-devtools v$VERSION" | |
| - name: Package extension | |
| run: npx @vscode/vsce package --no-dependencies | |
| - name: Publish to VS Code Marketplace | |
| run: npx @vscode/vsce publish --no-dependencies | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| - name: Publish to Open VSX Registry | |
| if: env.OVSX_PAT != '' | |
| run: npx ovsx publish *.vsix | |
| env: | |
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: vscode-forge/v${{ steps.version.outputs.version }} | |
| name: Forge DevTools v${{ steps.version.outputs.version }} | |
| body: | | |
| ## Forge DevTools v${{ steps.version.outputs.version }} | |
| ### Install | |
| - **VS Code Marketplace**: Search for "Forge DevTools" in the Extensions panel | |
| - **Manual**: Download the `.vsix` file below and install via `code --install-extension forge-devtools-${{ steps.version.outputs.version }}.vsix` | |
| files: vscode-forge/*.vsix | |
| prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }} | |
| generate_release_notes: true |