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
31 changes: 30 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,36 @@ jobs:
- uses: actions/setup-node@v7
with:
node-version: 26
# a draft: publish it once the staged version is approved on npm
# a draft until the staged version is approved on npm: the job below publishes it
- run: npx [email protected] --draft ${{ contains(github.ref_name, '-') && '--prerelease' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

published:
name: Wait for the approval on npm
needs: github_release
runs-on: ubuntu-latest
# as long as GitHub lets a job run; past it, publish the release and run the Website workflow by hand
timeout-minutes: 360
permissions:
contents: write
steps:
# the version answers once a maintainer approves it (`npm stage approve`): a staged one isn't public
- name: Wait for the version on npm
run: |
VERSION="${GITHUB_REF_NAME#v}"
until curl --silent --fail --output /dev/null "https://registry.npmjs.org/qwik-date/$VERSION"; do
sleep 30
done
echo "qwik-date@$VERSION is on npm"

- name: Publish the GitHub release
run: gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false
env:
GH_TOKEN: ${{ github.token }}

# the docs show the new version (the menu, the install commands, the changelog read npm when they build)
website:
needs: published
uses: ./.github/workflows/website.yml
secrets: inherit
46 changes: 46 additions & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Website

on:
# a change to the docs goes to production on its own
push:
branches: [main]
paths:
- "website/**"
- "vercel.json"
- ".github/workflows/website.yml"
# release.yml, once the new version is public on npm
workflow_call:
# by hand, e.g. when the approval on npm took longer than release.yml waits
workflow_dispatch:

concurrency:
group: website-production
# never stop a deploy halfway: a newer one waits for it
cancel-in-progress: false

permissions:
contents: read

jobs:
deploy:
name: Deploy to Vercel
runs-on: ubuntu-latest
timeout-minutes: 15
# the Vercel project, read by the CLI
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/setup

# Vercel builds nothing from Git for main (vercel.json): the build runs here, with the CI's pnpm and Node, and
# Vercel only serves it
- name: Production settings
run: npx --yes [email protected] pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

- name: Build
run: npx --yes [email protected] build --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy
run: npx --yes [email protected] deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ bun.lockb
# Tests
playwright-report
test-results

# Vercel CLI
.vercel
14 changes: 10 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ headless parts and `useCalendar()` fields are data in `website/src/data/`: the p
`llms-full.txt` read them. After changing them, or the use cases in `website/scripts/llms-full.md`,
run `pnpm -C website llms` to write `website/public/llms-full.txt` again.

Vercel builds it on every push (`vercel.json`). pnpm's version is the one in `package.json`'s
`packageManager`, for Vercel, the CI and your installs alike: to update it, change that line and run
`pnpm install`, which records it in the lockfile.
Vercel hosts it. Production deploys from GitHub Actions (`.github/workflows/website.yml`): after each
release, once the new version is on npm, and on each push to `main` that changes `website/` or
`vercel.json`. Vercel builds nothing from Git for `main`; a branch that changes the website gets a
preview, seen in Vercel's dashboard only (`website/scripts/vercel-preview.sh`). pnpm's version is the
one in `package.json`'s `packageManager`, for the deploys, the CI and your installs alike: to update it,
change that line and run `pnpm install`, which records it in the lockfile.

## Before opening a pull request

Expand Down Expand Up @@ -86,4 +89,7 @@ npm stage list qwik-date
npm stage approve <stage-id> # asks for the one-time password
```

Then publish the draft release on GitHub. To drop a staged version, `npm stage reject <stage-id>`.
The release workflow waits for that (up to 6 hours), then publishes the GitHub release and deploys the
website, which reads the new version from npm. If the approval takes longer, publish the draft release
by hand and run the Website workflow (Actions → Website → Run workflow). To drop a staged version,
`npm stage reject <stage-id>`.
2 changes: 2 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"framework": null,
"git": { "deploymentEnabled": { "main": false } },
"ignoreCommand": "sh website/scripts/vercel-preview.sh",
"buildCommand": "pnpm build.website",
"outputDirectory": "website/dist",
"trailingSlash": true,
Expand Down
28 changes: 20 additions & 8 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@ From the repo root, `pnpm build.website` runs the whole chain (library + client

## Deployment (Vercel)

The site is fully prerendered, so Vercel serves `dist/` as static files: no functions. Its GitHub
integration builds every push (production for `main`, a preview for the other branches); there is no
GitHub Actions workflow for it.
The site is fully prerendered, so Vercel serves `dist/` as static files: no functions.

**Production** deploys from GitHub Actions ([`website.yml`](../.github/workflows/website.yml)), which
builds with the Vercel CLI (`vercel build --prod`, then `vercel deploy --prebuilt --prod`):

- after each release, once the new version is public on npm (`release.yml` calls it);
- on each push to `main` that changes `website/` or `vercel.json`;
- by hand (Actions → Website → Run workflow).

It needs three repository secrets: `VERCEL_TOKEN`, `VERCEL_ORG_ID` (the team's ID) and
`VERCEL_PROJECT_ID`.

**Previews** come from Vercel's Git integration, which builds nothing for `main`
(`git.deploymentEnabled`). Its Ignored Build Step, [`scripts/vercel-preview.sh`](./scripts/vercel-preview.sh),
skips every branch that doesn't change `website/` or `vercel.json` compared with `main`. The previews
are only seen in Vercel's dashboard: in the project's Git settings, the pull request and commit comments,
the `deployment_status` events and the commit statuses are off. A pull request from a fork waits for a
maintainer to authorize it there (Git Fork Protection, in the Security settings).

The build settings live in [`vercel.json`](../vercel.json) at the repo root:

Expand All @@ -34,11 +49,8 @@ The build settings live in [`vercel.json`](../vercel.json) at the repo root:
| Build command | `pnpm build.website` |
| Output directory | `website/dist` |

Both run the pnpm of `package.json`'s `packageManager`: Vercel reads it and picks pnpm 12 (without it,
it would pick pnpm 10 for this lockfile), which then switches to that exact version.
pnpm is the one in `package.json`'s `packageManager`: the CI's setup installs it, and Vercel reads it
for the previews (without it, it would pick pnpm 10 for this lockfile).

`trailingSlash` matches the URLs of the pages (`/calendar/`), `404.html` answers the missing ones, and
`/build/` and `/assets/` (hashed file names) are cached for a year.

One-time setup in the dashboard: import the `diecodev/qwik-date` repo, keep the root directory as the
repo root, and add the custom domain `qwik-date.dieco.dev` (a `CNAME` to Vercel at the DNS provider).
9 changes: 9 additions & 0 deletions website/scripts/vercel-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# Vercel's Ignored Build Step (`ignoreCommand` in vercel.json), for the previews: Vercel builds nothing from Git for
# main, whose deploys come from .github/workflows/website.yml. Exit 0 skips the build and 1 builds it: a branch gets
# a preview only when it changes the website or vercel.json, compared with main. When that can't be told, it builds.
repo="https://github.com/${VERCEL_GIT_REPO_OWNER:-diecodev}/${VERCEL_GIT_REPO_SLUG:-qwik-date}.git"
git fetch --quiet --depth=50 "$repo" main || exit 1
base=$(git merge-base HEAD FETCH_HEAD) || exit 1
git diff --quiet "$base" HEAD -- website vercel.json && exit 0
exit 1
Loading