sitez

ci.yml

No prose in this file.

name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  # One job, named `ci`, so branch protection can require one check.
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: pnpm/action-setup@v6
      - uses: actions/setup-node@v7
        with:
          node-version-file: package.json
          cache: pnpm

      - run: pnpm install --frozen-lockfile

      # check, test and build, with publint inside the build. The same script releases run.
      - name: Verify
        run: pnpm run verify

      # The package as npm would ship it, installed into a copy of the blog example: catches a
      # file missing from `files` or a dependency only the repo has, before a release does.
      # Outside the repository, since npm refuses to run where `devEngines` names pnpm.
      - name: Install the packed tarball in a site
        run: |
          pnpm pack --pack-destination "$RUNNER_TEMP"
          cp -R tests/sites/blog "$RUNNER_TEMP/site"
          cd "$RUNNER_TEMP/site"
          tgz="$(ls "$RUNNER_TEMP"/amitkaps-sitez-*.tgz)"
          node -e 'const fs = require("fs"); const p = JSON.parse(fs.readFileSync("package.json")); p.devDependencies["@amitkaps/sitez"] = "file:" + process.argv[1]; fs.writeFileSync("package.json", JSON.stringify(p))' "$tgz"
          printf 'import sitez from "@amitkaps/sitez/vite";\n\nexport default { plugins: [sitez()] };\n' > vite.config.js
          npm install --no-audit --no-fund
          npx vp build