diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..9c25512 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,62 @@ +# Start a release from GitHub (Actions → Prepare release → Run workflow): raises the version on a copy of dev, writes +# its CHANGELOG.md section (yarn release), and opens the pull request "Release v" into dev. Review and edit the +# changelog there, merge it, then open dev → main as usual. +# RELEASE_TOKEN (a fine-grained token: this repo, Contents and Pull requests read and write) opens the pull request as +# you, so `check` and the preview run on it; GitHub doesn't start workflows for pull requests its own token opens. +name: Prepare release + +on: + workflow_dispatch: + inputs: + kind: + description: 'patch (fixes), minor (new tools or features) or major (breaks how people use Ream)' + type: choice + options: [patch, minor, major] + default: minor + +permissions: + contents: write + pull-requests: write + +concurrency: prepare-release + +jobs: + prepare: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v7 + with: + ref: dev + fetch-depth: 0 # the tags and history the changelog is made from + token: ${{ secrets.RELEASE_TOKEN || github.token }} + - uses: actions/setup-node@v7 + with: + node-version: 22 # scripts/release.ts is TypeScript, run directly; it needs only git + - name: Raise the version and write the changelog + id: release + run: | + node scripts/release.ts prepare "${{ inputs.kind }}" + echo "version=$(node scripts/release.ts version)" >> "$GITHUB_OUTPUT" + - name: Open the pull request into dev + env: + GH_TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }} + VERSION: ${{ steps.release.outputs.version }} + run: | + branch="release/v$VERSION" + if git ls-remote --exit-code --heads origin "$branch" >/dev/null; then + echo "::error::$branch already exists: merge or delete its pull request first." + exit 1 + fi + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git switch -c "$branch" + git add package.json CHANGELOG.md + git commit -m "Release v$VERSION" + git push origin "$branch" + { + echo "Raises the version to $VERSION and adds its changelog section. Edit \`CHANGELOG.md\` here if the wording needs it; after merging, open the pull request from \`dev\` into \`main\` to release." + echo + node scripts/release.ts notes + } > body.md + gh pr create --base dev --head "$branch" --title "Release v$VERSION" --body-file body.md diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 04d2808..ed7c8bf 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -127,10 +127,12 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy dist --project-name ream --branch main --commit-hash "${{ github.sha }}" --commit-message "v${{ steps.version.outputs.version }}" - - name: Tag the release and write its notes (the pull requests merged since the last one) + - name: Tag the release, with its CHANGELOG.md section as the notes env: GH_TOKEN: ${{ github.token }} - run: gh release create "v${{ steps.version.outputs.version }}" --repo "${{ github.repository }}" --target "${{ github.sha }}" --title "v${{ steps.version.outputs.version }}" --generate-notes + run: | + node repo/scripts/release.ts notes > notes.md + gh release create "v${{ steps.version.outputs.version }}" --repo "${{ github.repository }}" --target "${{ github.sha }}" --title "v${{ steps.version.outputs.version }}" --notes-file notes.md # the image for self-hosting: Intel/AMD and ARM, tagged with the version and latest. The site is built once, on # the runner's own platform; each platform's image only copies the files, so no emulation is needed. - uses: docker/setup-buildx-action@v4 diff --git a/AGENTS.md b/AGENTS.md index 99b6125..e472ce4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -156,7 +156,7 @@ To add a tool: manifest, run, panel, three registry entries, and tests. Reuse th - Routes (`App.tsx`, hash based): `#/tool/` the tool page, `#/tools`, `#/tools/pdf` and `#/tools/image` the tools home for a category (`Home.tsx`, `filterHref` in `TopBar.tsx`), `#/licence` and `#/notices` (`Legal.tsx`: the repo's `LICENSE` and `THIRD-PARTY-NOTICES.md`, imported `?raw` when the page opens) and `#/` (`Landing.tsx`); any other hash shows the landing page. The web-only pages share `Marketing.tsx` (nav, footer, `primary`/`secondary` link styles); app pages render `TopBar` (logo on the left; search and theme on the right; 1600 px like the pages) and `Breadcrumb` under it (All tools, the category, the tool; every level a link). The breadcrumb replaces visible headings on the tools home and tool pages (the `h1` is `sr-only`); on All tools the PDF tools and Image tools section titles link to their category. `focus` in `TopBar.tsx` is the shared focus ring. - Tools home (`Home.tsx`, at most 1600 px wide) is drop-first: the `Dropzone` `bar` layout, and dropped files handed to a tool through `handoff.ts`, the same mechanism as "Use in another tool". - Docker: `Dockerfile` builds the site with Node (on the build machine's platform) and serves it with `nginxinc/nginx-unprivileged` (non-root, port 8080). Its NGINX site is generated from `apps/web/public/_headers` by `scripts/nginx-conf.ts`, so change headers there only. The image build skips the typecheck (tests are left out by `.dockerignore`; CI typechecks anyway). `check` builds and runs it and checks the page, the headers, `sw.js` not being cached, the manifest's type, a 404 and a non-root user; the release pushes amd64 and arm64 images to `ghcr.io/deityhub/ream` and, with `DOCKERHUB_USERNAME`/`DOCKERHUB_TOKEN` set, `docker.io//ream`, tagged with the version and `latest`. Containers can't start in this Mac's Docker; test a server inside a throwaway `docker build` (start it in a `RUN`, query it with curl) or rely on CI. -- Versions: the root `package.json` `version` (semver, starting at 0.1.0) is the release version. A pull request into `main` must raise it (`yarn version patch|minor|major`; `node scripts/release.ts check` fails on a version already tagged or older); the merge deploys production, tags `v` and creates a GitHub Release with generated notes. The version is in the footer (`__APP_VERSION__`, defined in `vite.config.ts`, declared in `version.d.ts`) and in the offline cache's name. `.github/workflows/deploy-version.yml` builds a released tag again and deploys it to production (rollback when the Cloudflare dashboard's can't). +- Versions: the root `package.json` `version` (semver, starting at 0.1.0) is the release version. A pull request into `main` must raise it and have its `CHANGELOG.md` section: `yarn release patch|minor|major` (`scripts/release.ts prepare`) writes both, the section from the pull requests merged since the last tag (first-parent merges of `dev`, their titles and links; earlier releases skipped), and `node scripts/release.ts check` fails on a version already tagged or older or one without a section. The merge deploys production, tags `v` and creates a GitHub Release whose notes are that section (`release.ts notes`). `.github/workflows/prepare-release.yml` (Actions → Prepare release) runs `prepare` on `dev` and opens the "Release v" pull request into `dev`, as the `RELEASE_TOKEN` secret so `check` and the preview run on it. The version is in the footer (`__APP_VERSION__`, defined in `vite.config.ts`, declared in `version.d.ts`) and in the offline cache's name. `.github/workflows/deploy-version.yml` builds a released tag again and deploys it to production (rollback when the Cloudflare dashboard's can't). - Hosting: Cloudflare Pages, deployed by `.github/workflows/web.yml`: a pull request into `dev` runs `check` and gets a preview (its link is commented on the PR), a pull request into `main` runs `check`, a merge into `main` runs `check` and deploys production. Plain pushes run nothing. `check` is the status `.github/rulesets/protect-dev-main.json` requires (import it under Settings → Rules once the repo is public: rulesets aren't free on private repos). `apps/web/public/_headers` holds the security headers: the CSP allows only the site's own files, plus `api.fontsource.org` and `cdn.jsdelivr.net` in `connect-src` for Download free fonts, and no inline scripts or styles (`style-src 'self'`: React's `style` props are fine, `