|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | +permissions: {} |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + permissions: |
| 12 | + contents: write # to create release (changesets/action) |
| 13 | + id-token: write # OpenID Connect token needed for provenance |
| 14 | + pull-requests: write # to create pull request (changesets/action) |
| 15 | + # prevents this action from running on forks |
| 16 | + if: github.repository == 'sveltejs/vite-plugin-svelte' |
| 17 | + name: Release |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + # pseudo-matrix for convenience, NEVER use more than a single combination |
| 22 | + node: [24] |
| 23 | + os: [ubuntu-latest] |
| 24 | + steps: |
| 25 | + - name: checkout |
| 26 | + uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits |
| 29 | + fetch-depth: 0 |
| 30 | + - uses: actions/setup-node@v5 |
| 31 | + with: |
| 32 | + node-version: ${{ matrix.node }} |
| 33 | + package-manager-cache: false # pnpm is not installed yet |
| 34 | + - name: install pnpm |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json) |
| 38 | + echo installing pnpm version $PNPM_VER |
| 39 | + npm i -g pnpm@$PNPM_VER |
| 40 | + - uses: actions/setup-node@v5 |
| 41 | + with: |
| 42 | + node-version: ${{ matrix.node }} |
| 43 | + package-manager-cache: true # caches pnpm via packageManager field in package.json |
| 44 | + - name: install |
| 45 | + run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts |
| 46 | + - name: publint |
| 47 | + run: pnpm check:publint |
| 48 | + |
| 49 | + - name: Create Release Pull Request or Publish to npm |
| 50 | + id: changesets |
| 51 | + # pinned for security, always review third party action code before updating |
| 52 | + uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 |
| 53 | + with: |
| 54 | + # This expects you to have a script called release which does a build for your packages and calls changeset publish |
| 55 | + publish: pnpm release |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + NPM_CONFIG_PROVENANCE: true |
0 commit comments