|
| 1 | +name: Publish to VS Code Marketplace |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + default: 'patch' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + actions: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + publish: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + version: ${{ steps.version.outputs.version }} |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: '20' |
| 36 | + cache: 'npm' |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: npm ci |
| 40 | + |
| 41 | + - name: Run tests |
| 42 | + run: npm run test |
| 43 | + |
| 44 | + - name: Build extension |
| 45 | + run: npm run build |
| 46 | + |
| 47 | + - name: Bump version |
| 48 | + run: npm version ${{ inputs.version }} --no-git-tag-version |
| 49 | + |
| 50 | + - name: Get new version |
| 51 | + id: version |
| 52 | + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
| 53 | + |
| 54 | + - name: Package VSIX |
| 55 | + run: npx @vscode/vsce package |
| 56 | + |
| 57 | + - name: Publish to VS Code Marketplace |
| 58 | + run: npx @vscode/vsce publish -p ${{ secrets.VS_PAT }} |
| 59 | + |
| 60 | + - name: Upload VSIX artifact |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: vsix |
| 64 | + path: '*.vsix' |
| 65 | + |
| 66 | + - name: Commit version bump |
| 67 | + run: | |
| 68 | + git config user.name "github-actions[bot]" |
| 69 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 70 | + git add package.json package-lock.json |
| 71 | + git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" |
| 72 | + git tag "v${{ steps.version.outputs.version }}" |
| 73 | + git push |
| 74 | + git push --tags |
| 75 | +
|
| 76 | + changelog: |
| 77 | + needs: publish |
| 78 | + uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main |
| 79 | + secrets: inherit |
| 80 | + |
| 81 | + release: |
| 82 | + needs: [publish, changelog] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + permissions: |
| 85 | + contents: write |
| 86 | + steps: |
| 87 | + - name: Download VSIX artifact |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + name: vsix |
| 91 | + |
| 92 | + - name: Create GitHub Release |
| 93 | + uses: softprops/action-gh-release@v1 |
| 94 | + with: |
| 95 | + tag_name: v${{ needs.publish.outputs.version }} |
| 96 | + name: v${{ needs.publish.outputs.version }} |
| 97 | + body: ${{ needs.changelog.outputs.changelog }} |
| 98 | + files: '*.vsix' |
0 commit comments