|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main # semantic-release works on branch pushes, not tags |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write # Required for creating releases and pushing commits |
| 10 | + issues: write # Required for commenting on issues |
| 11 | + pull-requests: write # Required for commenting on PRs |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Call the CI workflow to run all validation, linting, tests, and build |
| 15 | + ci: |
| 16 | + name: Run CI |
| 17 | + uses: ./.github/workflows/ci.yml |
| 18 | + |
| 19 | + # Automated release with semantic-release |
| 20 | + release: |
| 21 | + name: Semantic Release |
| 22 | + runs-on: ubuntu-latest |
| 23 | + needs: ci |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 # Fetch all history for semantic-release |
| 30 | + persist-credentials: false # Use custom token for pushing |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: '22' |
| 36 | + cache: 'npm' |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: npm ci |
| 40 | + |
| 41 | + - name: Verify package.json and package-lock.json are in sync |
| 42 | + run: npm ci --dry-run |
| 43 | + |
| 44 | + - name: Run semantic-release |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + # Uncomment if publishing to VS Code Marketplace |
| 48 | + # VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 49 | + run: | |
| 50 | + npx semantic-release |
| 51 | +
|
| 52 | + # Optional: Manual tag-based release (fallback if semantic-release is not used) |
| 53 | + # This job only runs when a tag is pushed |
| 54 | + # manual-release: |
| 55 | + # name: Manual Tag Release |
| 56 | + # if: startsWith(github.ref, 'refs/tags/v') |
| 57 | + # runs-on: ubuntu-latest |
| 58 | + # |
| 59 | + # steps: |
| 60 | + # - name: Checkout code |
| 61 | + # uses: actions/checkout@v4 |
| 62 | + # with: |
| 63 | + # fetch-depth: 0 |
| 64 | + # |
| 65 | + # - name: Get version from tag |
| 66 | + # id: get_version |
| 67 | + # run: | |
| 68 | + # TAG=${GITHUB_REF#refs/tags/} |
| 69 | + # VERSION=${TAG#v} |
| 70 | + # echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 71 | + # echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 72 | + # |
| 73 | + # - name: Download VSIX artifact |
| 74 | + # uses: actions/download-artifact@v4 |
| 75 | + # with: |
| 76 | + # name: vsix-package |
| 77 | + # |
| 78 | + # - name: Create GitHub Release |
| 79 | + # uses: softprops/action-gh-release@v2 |
| 80 | + # with: |
| 81 | + # tag_name: ${{ steps.get_version.outputs.tag }} |
| 82 | + # name: Release ${{ steps.get_version.outputs.version }} |
| 83 | + # files: '*.vsix' |
| 84 | + # env: |
| 85 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments