|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: "Version bump type" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: [patch, minor, major] |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: release |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + release: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout main (full history for tags) |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + ref: main |
| 28 | + |
| 29 | + - uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: 22 |
| 32 | + cache: npm |
| 33 | + |
| 34 | + - run: npm ci |
| 35 | + - run: npm run lint --if-present |
| 36 | + - run: npm run typecheck --if-present |
| 37 | + - run: npm test --if-present |
| 38 | + - run: npm run compile |
| 39 | + |
| 40 | + - name: Configure git identity |
| 41 | + run: | |
| 42 | + git config user.name "github-actions[bot]" |
| 43 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 44 | +
|
| 45 | + - name: Ensure working tree is clean |
| 46 | + run: | |
| 47 | + if [ -n "$(git status --porcelain)" ]; then |
| 48 | + echo "Working tree is not clean." |
| 49 | + git status --porcelain |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Bump version + create tag |
| 54 | + id: bump |
| 55 | + run: | |
| 56 | + NEW_TAG="$(npm version ${{ inputs.bump }} -m "chore(release): v%s")" |
| 57 | + echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT" |
| 58 | + echo "Created tag: $NEW_TAG" |
| 59 | +
|
| 60 | + - name: Push commit + tag |
| 61 | + run: git push --follow-tags origin main |
| 62 | + |
| 63 | + - name: Package (vsix) |
| 64 | + run: npx vsce package --no-dependencies |
| 65 | + |
| 66 | + - name: Publish to VS Code Marketplace |
| 67 | + env: |
| 68 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 69 | + run: npx vsce publish -p "$VSCE_PAT" |
| 70 | + |
| 71 | + - name: Create GitHub Release + upload VSIX |
| 72 | + uses: softprops/action-gh-release@v2 |
| 73 | + with: |
| 74 | + tag_name: ${{ steps.bump.outputs.new_tag }} |
| 75 | + generate_release_notes: true |
| 76 | + files: "*.vsix" |
0 commit comments