Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|mcp__github__create_pull_request",
"hooks": [
{
"type": "command",
"command": "node \"$CLAUDE_PROJECT_DIR/scripts/docs-drift.mjs\" --hook"
}
]
}
]
}
}
28 changes: 28 additions & 0 deletions .github/workflows/docs-drift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Docs drift

# Separate from CI because it also re-runs when the PR description is edited
# (that is where "Docs-Impact: none – <reason>" may be declared).
on:
pull_request:
types: [opened, synchronize, reopened, edited]

permissions:
contents: read

jobs:
docs-drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- run: node --test scripts/docs-drift.test.mjs
- name: Check that documented behaviour changes come with documentation
run: node scripts/docs-drift.mjs --base "$BASE_SHA" --head "$HEAD_SHA"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_BODY: ${{ github.event.pull_request.body }}
72 changes: 68 additions & 4 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
name: Deploy to GitHub Pages

# The web app (/app/) is always built from a release tag, so every deployed app can be
# verified against a tag. The documentation site is built from the triggering ref:
# - tag v*: site and app from that tag
# - push to main: site from main when site inputs changed, app from the latest release tag;
# skipped while main has unreleased app changes, so the published docs never
# describe an app that is not deployed (they go live with the next tag)
# - manual run: site from the chosen ref, app from the latest release tag (no skip)
on:
push:
tags: ['v*']
tags: ['v*'] # path filters do not apply to tag pushes
branches: [main]
paths:
- 'docs/**'
- 'site/**'
- 'design/**'
- '.github/workflows/pages.yml'
workflow_dispatch:

permissions:
Expand All @@ -17,43 +30,94 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.release.outputs.deploy }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve the app release
id: release
run: |
if [[ "$GITHUB_REF_TYPE" == tag ]]; then
tag="$GITHUB_REF_NAME"
else
tag=$(git tag --list 'v*' --sort=-v:refname | head -n 1)
fi
if [[ -z "$tag" ]]; then
echo "::error::No release tag v* exists. Tag a release (e.g. v0.1.0) to deploy the app."
exit 1
fi
deploy=true
if ! git diff --quiet "$tag" HEAD -- web ':(exclude)web/tests' ':(exclude)web/e2e'; then
if [[ "$GITHUB_EVENT_NAME" == push ]]; then
deploy=false
echo "::notice::$GITHUB_REF_NAME has app changes not released in $tag. The documentation goes live with the next release tag, or run this workflow manually."
else
echo "::warning::Deploying documentation from $GITHUB_SHA with the app from $tag; the documentation may describe unreleased app changes."
fi
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "deploy=$deploy" >> "$GITHUB_OUTPUT"
{
echo "| | Ref | Commit |"
echo "|---|---|---|"
echo "| Site | \`$GITHUB_REF_NAME\` | \`$GITHUB_SHA\` |"
echo "| App | \`$tag\` | \`$(git rev-parse "$tag^{commit}")\` |"
echo
echo "Deploy: **$deploy**"
} >> "$GITHUB_STEP_SUMMARY"
- uses: actions/setup-node@v4
if: steps.release.outputs.deploy == 'true'
with:
node-version: 22
cache: npm
cache-dependency-path: |
web/package-lock.json
site/package-lock.json
- name: Build web app
working-directory: web
- name: Build web app from the release tag
if: steps.release.outputs.deploy == 'true'
run: |
git worktree add --detach "$RUNNER_TEMP/release" "$TAG"
cd "$RUNNER_TEMP/release/web"
npm ci
npm test
npm run build
env:
TAG: ${{ steps.release.outputs.tag }}
VITE_GOOGLE_CLIENT_ID: ${{ vars.GOOGLE_CLIENT_ID }}
VITE_GOOGLE_API_KEY: ${{ vars.GOOGLE_API_KEY }}
VITE_GOOGLE_APP_ID: ${{ vars.GOOGLE_APP_ID }}
- name: Build documentation site (app under /app/)
if: steps.release.outputs.deploy == 'true'
working-directory: site
run: |
npm ci
node build.mjs --out ../_site --app ../web/dist
node build.mjs --out ../_site --app "$RUNNER_TEMP/release/web/dist"
node check.mjs --dir ../_site
- name: Record what the deployment was built from
if: steps.release.outputs.deploy == 'true'
run: |
printf 'site %s %s\napp %s %s\n' \
"$GITHUB_REF_NAME" "$GITHUB_SHA" "$TAG" "$(git rev-parse "$TAG^{commit}")" > _site/BUILD.txt
env:
TAG: ${{ steps.release.outputs.tag }}
- name: Checksums of every published file
if: steps.release.outputs.deploy == 'true'
run: node web/scripts/checksums.mjs _site
- uses: actions/upload-artifact@v4
if: steps.release.outputs.deploy == 'true'
with:
name: SHA256SUMS
path: _site/SHA256SUMS.txt
- uses: actions/upload-pages-artifact@v3
if: steps.release.outputs.deploy == 'true'
with:
path: _site

deploy:
needs: build
if: needs.build.outputs.deploy == 'true'
runs-on: ubuntu-latest
environment:
name: github-pages
Expand Down
7 changes: 7 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# unpassword

Overview, layout and commands: [README.md](README.md).

## Documentation

Update documentation in the same change as the code it describes. The threshold and the code-to-document map are in [CONTRIBUTING.md](CONTRIBUTING.md#documentation) and `scripts/docs-drift.mjs`. A `PreToolUse` hook blocks `git push` and PR creation while drift is open. If a change really does not alter what the named documents state, add `Docs-Impact: none – <reason>` as a commit trailer instead of editing documents for the sake of the check. Never edit `docs/PRIVACY.md`, `docs/TERMS.md` or `docs/IMPRINT.md` without saying so explicitly in the PR description: they are legal texts the maintainer approves.
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

Development commands are in the [README](README.md#development). Pull requests run CI (lint, typecheck, unit and E2E tests, site build) and the docs drift check described below.

## Documentation

Documentation is part of the change that makes it necessary, not a follow-up.

### When a change needs a documentation update

The threshold is not the size of a change but whether it alters something a document states. A change needs a documentation update when it changes:

- **what users can do or observe:** supported formats and protections, flows, messages, result file names (README, landing page, SUPPORT)
- **security and anti-misuse guarantees** or how they are enforced (README Guardrails, SECURITY)
- **what data goes where:** OAuth scopes, contacted hosts, CSP, storage (SECURITY, PRIVACY)
- **how to build, configure, deploy or verify** unpassword (README, SETUP)
- **the bundled third-party components** (THIRD_PARTY_NOTICES)

It does not need one for refactors, tests, styling, tooling or dependency updates that leave all of the above unchanged.

Privacy policy, terms and imprint are legal texts: changes to them are proposed in a pull request and approved by the maintainer, never published unreviewed.

### How it is enforced

[`scripts/docs-drift.mjs`](scripts/docs-drift.mjs) maps code areas to the documents that describe them (`RULES`). When a change touches such an area without touching one of its documents, the check fails and names the rule, the files and the documents to update. Then either update the documentation, or declare that the change does not alter what those documents describe:

```
Docs-Impact: none – <reason>
```

as a commit message trailer or in the pull request description. A reason is required. The check only makes sure the decision is taken explicitly; whether it is right is decided in review.

- **CI:** the *Docs drift* workflow runs on every pull request, and again when its description is edited.
- **Claude Code:** a `PreToolUse` hook in [`.claude/settings.json`](.claude/settings.json) blocks `git push` and pull request creation while drift is open, so the agent updates the documentation within the same change. At push time there is no pull request description yet, so an opt-out has to be a commit trailer.

Keep the map current: a new code area or document gets a rule. A rule that mostly produces opt-outs is too broad and should be narrowed (the `dependencies` rule, for example, fires only when runtime dependencies are added or removed, not on version bumps).

### Publishing

The documentation site deploys automatically when `docs/`, `site/` or `design/` change on `main`. The web app under `/app/` is always built from the latest release tag. While `main` contains app changes that are not released yet, the automatic deployment is skipped, so the site never describes an app that is not deployed; the documentation then goes live with the next release tag. Details are in the [setup guide](docs/SETUP.md#5-deploy-the-site-and-the-web-app).
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ web/ static web app (Vite + TypeScript, no UI framework)
gmail-addon/ Apps Script Gmail launcher (never decrypts)
site/ documentation site for GitHub Pages: renders docs/ and the landing page, no JavaScript
design/ Nullthrone Design System tokens and fonts (self-hosted), the unpassword mark and its PNG renderings
scripts/ fixture generator, cross-check, brand asset renderer
scripts/ fixture generator, cross-check, brand asset renderer, docs drift check
docs/ security model, privacy policy, terms, support, imprint, deployment setup
```

Expand All @@ -94,11 +94,13 @@ node check.mjs # CSP, no external resources, no broken links

Brand assets (icons, banner, Marketplace screenshots) are rendered by `node scripts/render-brand-assets.mjs` after `npm run build` in `web/`.

Changes that alter documented behaviour update the documentation in the same pull request; the *Docs drift* check enforces this. See [CONTRIBUTING.md](CONTRIBUTING.md#documentation).

Drive integration needs `VITE_GOOGLE_CLIENT_ID`, `VITE_GOOGLE_API_KEY` and `VITE_GOOGLE_APP_ID` (see [docs/SETUP.md](docs/SETUP.md)). Without them the app runs in local mode only.

## Verifying a deployment

The Pages workflow builds from a tagged commit and publishes `SHA256SUMS.txt` at the site root. Build the same tag locally with the same public Google identifiers and compare the checksums.
The Pages workflow builds the web app from a release tag and publishes `BUILD.txt` and `SHA256SUMS.txt` at the site root. `BUILD.txt` names the release tag the app under `/app/` was built from and the commit the documentation site was built from (the same commit for a release; a later commit on `main` after a documentation-only deployment). Build the app from that tag with the same public Google identifiers, and the site from that commit, and compare the checksums.

## License

Expand Down
13 changes: 11 additions & 2 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,21 @@ None of these values is secret. They end up in the public JavaScript bundle by d

## 5. Deploy the site and the web app

Push a tag `v*` (e.g. `v0.1.0`), or run *Actions* → *Deploy to GitHub Pages* → *Run workflow*. `.github/workflows/pages.yml` builds the web app and the documentation site, then deploys both:
`.github/workflows/pages.yml` builds the web app and the documentation site, then deploys both:

- `/` – documentation site (`site/`, rendered from `docs/`)
- `/app/` – the web app (`web/`)
- `/app/` – the web app (`web/`), always built from a release tag
- `/BUILD.txt` – the release tag of the app and the commit of the site
- `/SHA256SUMS.txt` – checksums of every published file, also attached to the workflow run

It runs when:

- **a tag `v*` is pushed** (e.g. `v0.1.0`): site and app from that tag. This is how a release is published, and the first deployment needs one.
- **`docs/`, `site/` or `design/` change on `main`**: site from `main`, app from the latest release tag. Skipped while `main` contains app changes that are not released yet, so the site never describes an app that is not deployed; the documentation then goes live with the next tag.
- **started manually** (*Actions* → *Deploy to GitHub Pages* → *Run workflow*): site from the chosen branch or tag, app from that tag or else the latest release tag, without the skip. Use it to publish an urgent documentation fix (e.g. the privacy policy) ahead of a release.

The `github-pages` environment must allow deployments from `main` and from `v*` tags (*Settings* → *Environments* → *github-pages* → *Deployment branches and tags*).

Then check the deployment:

- **Local mode:** drop a protected file and unlock it. In the browser's network panel, verify that no request leaves the page's origin.
Expand Down
Loading
Loading