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
110 changes: 79 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,99 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- "v*"

concurrency:
group: release-${{ github.ref }}
# never interrupt a release halfway
cancel-in-progress: false

permissions:
contents: read

jobs:
npm_publish:
# the whole CI (lint, types, tests, builds) before anything leaves
ci:
uses: ./.github/workflows/ci.yml

stage:
name: Stage on npm
needs: ci
runs-on: ubuntu-latest
permissions:
contents: read
# the OIDC token of Trusted Publishing: no NPM_TOKEN
id-token: write
steps:
- name: clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/checkout@v7
- uses: ./.github/actions/setup

- name: installing pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: The tag is the version
run: |
VERSION=$(node -p "require('./package.json').version")
if [ "v$VERSION" != "$GITHUB_REF_NAME" ]; then
echo "::error::the tag $GITHUB_REF_NAME doesn't match the version in package.json ($VERSION)"
exit 1
fi

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Build the library
run: pnpm build.types && pnpm build.lib

- name: Building library
run: pnpm install --no-frozen-lockfile
# every file package.json points to (main, types, exports) goes in the package
- name: The package has the library
run: |
npm pack --dry-run --json > "$RUNNER_TEMP/pack.json"
node -e '
const pkg = require("./package.json");
const packed = new Set(require(process.env.RUNNER_TEMP + "/pack.json")[0].files.map((file) => file.path));
const entries = [pkg.main, pkg.qwik, pkg.types, ...Object.values(pkg.exports).flatMap(Object.values)];
const files = new Set(entries.map((entry) => entry.replace(/^\.\//, "")));
const missing = [...files].filter((file) => !packed.has(file));
if (missing.length) {
console.error(`::error::not in the package: ${missing.join(", ")}`);
process.exit(1);
}
'

- run: npm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# staged publishing needs npm 11.15 or later
- name: Recent npm
run: npm install -g npm@12

# a prerelease (2.0.0-beta.0) goes under its identifier (`beta`), so a plain install keeps the stable line
- name: npm dist-tag
id: dist-tag
run: |
VERSION=$(node -p "require('./package.json').version")
if [[ "$VERSION" == *-* ]]; then
TAG="${VERSION#*-}"
TAG="${TAG%%.*}"
else
TAG=latest
fi
echo "$VERSION goes under '$TAG'"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"

gh_release:
needs: [npm_publish]
# staged, not published: a maintainer approves it with 2FA (`npm stage approve`, see CONTRIBUTING.md)
- name: Stage the version
run: npm stage publish --access public --tag ${{ steps.dist-tag.outputs.tag }}

github_release:
name: GitHub release (draft)
needs: stage
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
# the changelog compares this tag with the one before
fetch-depth: 0

- uses: actions/setup-node@v4

- run: npx changelogithub # or [email protected] if ensure the stable result
- uses: actions/setup-node@v7
with:
node-version: 24
# a draft: publish it once the staged version is approved on npm
- run: npx [email protected] --draft ${{ contains(github.ref_name, '-') && '--prerelease' || '' }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ each one targets the branch below), and builds the website too. It runs on Linux

Commits follow [Conventional Commits](https://www.conventionalcommits.org/) with a gitmoji, like the
history: `fix(styled): πŸ› keep the focus on the month buttons after changing month`.

## Releases

Maintainers only. On an up-to-date `main`, `pnpm release` asks for the new version (`2.0.0-beta.1`…),
commits it, tags it and pushes. The tag runs `.github/workflows/release.yml`: the CI, then it stages the
package on npm through Trusted Publishing (a prerelease under its identifier, like `beta`; a plain
version under `latest`) and drafts a GitHub release with the changelog. Nothing is public until a
maintainer approves the staged version with 2FA (npm 11.15 or later):

```sh
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>`.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"fmt": "prettier --write .",
"fmt.check": "prettier --check .",
"lint": "biome check --write --unsafe",
"prepublishOnly": "pnpm build",
"release": "bumpp --commit --tag --push",
"prepublishOnly": "pnpm build.types && pnpm build.lib",
"release": "bumpp --commit \"chore(release): πŸ”– v%s\" --tag --push",
"start": "vite --open --mode ssr",
"test": "pnpm test.unit && pnpm test.e2e",
"test.unit": "vitest run",
Expand All @@ -82,7 +82,6 @@
"@qwik.dev/router": "2.0.0-rc.4",
"@types/node": "^22.12.0",
"bumpp": "9.4.1",
"np": "^10.0.7",
"tsx": "^4.16.3",
"typescript": "^5.9.3",
"undici": "^6.19.5",
Expand Down
Loading
Loading