name: PR preview release

on:
  pull_request:
    paths:
      - ".github/workflows/preview.yml"
      - "src/**"
      - "gulpfile.ts"
      - "package.json"
      - "tsconfig.json"

jobs:
  release:
    name: Release preview build
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          cache: "npm"
          node-version: 20

      - name: Install dependencies
        run: npm ci

      - name: Build
        run: npm run package

      - name: Prepare pnpm for preview publishing
        run: |
          npm install -g corepack@latest
          corepack prepare pnpm@latest --activate

      - name: Release preview version
        run: npm run publish:preview
