Merge pull request #13 from JuliaPluto/dr14-refactor #15
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main # semantic-release works on branch pushes, not tags | |
| workflow_dispatch: # Allow manual trigger | |
| inputs: | |
| dry_run: | |
| description: "Run in dry-run mode (no actual release)" | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write # Required for creating releases and pushing commits | |
| issues: write # Required for commenting on issues | |
| pull-requests: write # Required for commenting on PRs | |
| jobs: | |
| # Call the CI workflow to run all validation, linting, tests, and build | |
| ci: | |
| name: Run CI | |
| uses: ./.github/workflows/ci.yml | |
| # Automated release with semantic-release (no-commit mode) | |
| # This configuration creates releases without pushing version commits back to main | |
| # Perfect for repositories with strict branch protection/rulesets | |
| release: | |
| name: Semantic Release | |
| runs-on: ubuntu-latest | |
| needs: ci | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for semantic-release | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| persist-credentials: false # No need to push commits in no-commit mode | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Verify package.json and package-lock.json are in sync | |
| run: npm ci --dry-run | |
| - name: Build and package VSIX | |
| run: npm run package | |
| - name: Get VSIX filename | |
| id: vsix_file | |
| run: | | |
| VSIX_FILE=$(ls *.vsix | head -n 1) | |
| echo "filename=$VSIX_FILE" >> $GITHUB_OUTPUT | |
| echo "Built VSIX file: $VSIX_FILE" | |
| - name: Run semantic-release (no-commit mode) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: | | |
| if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then | |
| echo "Running in dry-run mode (no commits will be pushed)..." | |
| npx semantic-release --dry-run | |
| else | |
| echo "Running semantic-release in no-commit mode..." | |
| echo "This will create a GitHub release with VSIX but won't update package.json/CHANGELOG in the repo" | |
| echo "TODO: (and good first issue) actually introduce semantic release updating (after stable release) " | |
| npx semantic-release | |
| fi | |
| - name: Upload VSIX to release (fallback if semantic-release fails) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| with: | |
| name: vsix-package-release | |
| path: ${{ steps.vsix_file.outputs.filename }} | |
| retention-days: 90 | |
| # Optional: Manual tag-based release (fallback if semantic-release is not used) | |
| # This job only runs when a tag is pushed | |
| # manual-release: | |
| # name: Manual Tag Release | |
| # if: startsWith(github.ref, 'refs/tags/v') | |
| # runs-on: ubuntu-latest | |
| # | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # with: | |
| # fetch-depth: 0 | |
| # | |
| # - name: Get version from tag | |
| # id: get_version | |
| # run: | | |
| # TAG=${GITHUB_REF#refs/tags/} | |
| # VERSION=${TAG#v} | |
| # echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| # | |
| # - name: Download VSIX artifact | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: vsix-package | |
| # | |
| # - name: Create GitHub Release | |
| # uses: softprops/action-gh-release@v2 | |
| # with: | |
| # tag_name: ${{ steps.get_version.outputs.tag }} | |
| # name: Release ${{ steps.get_version.outputs.version }} | |
| # files: '*.vsix' | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |