|
| 1 | +name: Release Extension |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + # Only run if the PR was merged and has the "Release" label |
| 12 | + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Release') |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # Fetch full history for version tagging |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: '20' |
| 26 | + cache: 'npm' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Run linting |
| 32 | + run: npm run lint |
| 33 | + |
| 34 | + - name: Build extension |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Run tests |
| 38 | + run: xvfb-run -a npm test |
| 39 | + |
| 40 | + - name: Install vsce |
| 41 | + run: npm install -g @vscode/vsce |
| 42 | + |
| 43 | + - name: Get version from package.json |
| 44 | + id: get-version |
| 45 | + run: | |
| 46 | + VERSION=$(node -p "require('./package.json').version") |
| 47 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 48 | + echo "Extension version: $VERSION" |
| 49 | + |
| 50 | + - name: Package extension |
| 51 | + run: vsce package |
| 52 | + |
| 53 | + - name: Create GitHub Release |
| 54 | + uses: softprops/action-gh-release@v2 |
| 55 | + id: create-release |
| 56 | + with: |
| 57 | + tag_name: v${{ steps.get-version.outputs.version }} |
| 58 | + name: Release v${{ steps.get-version.outputs.version }} |
| 59 | + body: | |
| 60 | + ## Release v${{ steps.get-version.outputs.version }} |
| 61 | + |
| 62 | + This release was automatically created from PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }} |
| 63 | + |
| 64 | + ### Changes |
| 65 | + ${{ github.event.pull_request.body }} |
| 66 | + files: | |
| 67 | + commitollama-${{ steps.get-version.outputs.version }}.vsix |
| 68 | + draft: false |
| 69 | + prerelease: false |
| 70 | + |
| 71 | + - name: Publish to VS Code Marketplace |
| 72 | + env: |
| 73 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 74 | + run: vsce publish --pat $VSCE_PAT |
0 commit comments