diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..acecfa9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +# Caller stub — docs/12 §2.1. +# +# The `quality` job is local because the ops reusable runs NO quality gates at +# all: its entire surface is install → build → assert manifest_version == 3 → +# zip → upload. Lint, type-check, knip, coverage and the grep gate are ours. +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + quality: + name: Quality gates + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v6 + with: + node-version: '24' + cache: npm + - run: npm ci + - run: npm run lint # biome check . + - run: npm run check # svelte-check + tsc --noEmit + - run: npm run knip + - run: npm run coverage # vitest --coverage, thresholds per docs/11 §1 + - run: npm run guard # the canonical grep gate, docs/08 §3 + + build: + name: Build + package + needs: quality + # No `secrets:` here — the reusable declares no secrets block at all, and + # passing a named secret to it is a workflow-compile error. + uses: poli0981/.github/.github/workflows/reusable-chrome-extension.yml@main + permissions: + contents: read + with: + # All four are required in practice. Leaving package-manager at its + # 'none' default skips install and build, then fails on + # `test -f ./manifest.json` — a file WXT never writes to the repo root. + package-manager: 'npm' + node-version: '24' + build-command: 'npm run build' + source-dir: '.output/chrome-mv3' + release: false diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..394160e --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,36 @@ +# Caller stub — docs/12 §2.2. +# +# Uses `reusable-codeql.yml` (CodeQL Action v4), NOT the older `codeql.yml`, +# whose input is the singular `language`. This one takes `languages`: a JSON +# array encoded as a string. +# +# ⚠️ Prerequisite: repo Settings → Advanced Security → CodeQL "Default setup" +# must be DISABLED, or this advanced-setup workflow is rejected at SARIF upload. +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '0 14 * * 1' # weekly, Monday + +permissions: + security-events: write + actions: read + contents: read + packages: read + +jobs: + analyze: + # Reusable workflows do not inherit the caller's permissions — the block + # below is repeated on the job on purpose. + uses: poli0981/.github/.github/workflows/reusable-codeql.yml@main + permissions: + security-events: write + actions: read + contents: read + packages: read + with: + languages: '["javascript-typescript"]' diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml new file mode 100644 index 0000000..95b9743 --- /dev/null +++ b/.github/workflows/notify-ci-failure.yml @@ -0,0 +1,25 @@ +# Caller stub — docs/12 §2.4. +# +# The reusable already filters to `conclusion == 'failure'` on the default +# branch, so this caller needs no `if:`. +# +# ⚠️ It declares `DISCORD_CI_WEBHOOK` as `required: true`, so this workflow +# fails until that repo secret exists (docs/12 §5). +name: Notify CI failure + +on: + workflow_run: + workflows: ['CI'] + types: [completed] + +permissions: + contents: read + actions: read + +jobs: + notify: + uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@main + permissions: + contents: read + actions: read + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2a3ea4d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,80 @@ +# Release — docs/12 §2.3. +# +# Standalone rather than the ops reusable: the reusable's `release` job only +# runs `gh release create --generate-notes`. It produces no SHA256SUMS.txt +# (required by docs/09 §5), performs no store submission, and exposes no +# `outputs:`, so a caller cannot reference the zip it built. +name: Release + +on: + push: + tags: ['v*'] + +permissions: + contents: read + +jobs: + release: + runs-on: ubuntu-latest + timeout-minutes: 20 + permissions: + contents: write # create the GitHub Release + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v6 + with: + node-version: '24' + cache: npm + - run: npm ci + + # The same gates as CI. A tag must never ship what a PR would have + # blocked — pushing a tag skips the CI workflow's branch triggers. + - run: npm run lint + - run: npm run check + - run: npm run knip + - run: npm run coverage + - run: npm run guard + + - run: npm run zip # wxt zip → .output/--chrome.zip + + - name: Verify tag matches manifest version + run: | + set -euo pipefail + MANIFEST_VERSION=$(jq -r '.version' .output/chrome-mv3/manifest.json) + TAG_VERSION="${GITHUB_REF_NAME#v}" + test "$MANIFEST_VERSION" = "$TAG_VERSION" \ + || { echo "::error::tag $TAG_VERSION != manifest $MANIFEST_VERSION"; exit 1; } + + - name: SHA256SUMS + working-directory: .output + run: sha256sum *-chrome.zip > SHA256SUMS.txt + + - name: GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "$GITHUB_REF_NAME" \ + .output/*-chrome.zip .output/SHA256SUMS.txt --generate-notes + + # v1.0.x is published by hand (docs/12 §3) — first store reviews often + # ask questions and want a human in the loop. Flipping the repo variable + # CWS_AUTOPUBLISH to 'true' turns this on for v1.1+. + - name: Publish to Chrome Web Store + if: vars.CWS_AUTOPUBLISH == 'true' + env: + CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }} + CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }} + CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }} + CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }} + run: npx wxt submit --chrome-zip .output/*-chrome.zip + + # A job INSIDE this workflow, not an `on: release: [published]` caller. + # A Release created by `gh release create` under the default GITHUB_TOKEN + # emits no event that starts new workflow runs, so an event-driven caller + # would silently never fire. + announce: + needs: release + uses: poli0981/.github/.github/workflows/announce-release.yml@main + permissions: + contents: read + secrets: inherit