diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ecf80dd..abc258a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ -# Request review from the default repository maintainer. -* @pei-tinybird +# Pull requests need a review from the RawTree engineering team. +* @rawtreedb/engineering diff --git a/.github/workflows/release-sdk.yml b/.github/workflows/release-sdk.yml new file mode 100644 index 0000000..119f4bd --- /dev/null +++ b/.github/workflows/release-sdk.yml @@ -0,0 +1,48 @@ +name: Release SDK + +# Publishes @rawtree/analytics to npm when a tag like `analytics-v0.1.0` is pushed. +# The tag must match packages/analytics/package.json. Auth uses npm trusted publishing +# (OIDC, no stored token) once it's configured for this workflow on npmjs.com; an +# NPM_TOKEN repository secret works as a fallback. + +on: + push: + tags: ["analytics-v*"] + +permissions: + contents: read + id-token: write # npm trusted publishing and provenance + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + registry-url: https://registry.npmjs.org + + - name: Use an npm that supports trusted publishing + run: npm install -g npm@^11.5.1 + + - name: Check the tag matches the package version + run: | + expected="analytics-v$(node -p 'require("./packages/analytics/package.json").version')" + if [ "$GITHUB_REF_NAME" != "$expected" ]; then + echo "Tag $GITHUB_REF_NAME does not match $expected" >&2 + exit 1 + fi + + - name: Install dependencies + run: npm ci + + - name: Test + run: npm test + + - name: Publish + run: npm publish -w @rawtree/analytics --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 264376c..7df8357 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,16 @@ CI runs the same three checks on every pull request. Every pull request also get [AGENTS.md](AGENTS.md) has the same rules in more detail, for people and coding agents. +## Releasing the SDK (maintainers) + +`@rawtree/analytics` is published to npm by the [Release SDK](.github/workflows/release-sdk.yml) workflow, with provenance. + +1. Bump `version` in `packages/analytics/package.json` in a pull request (semver: breaking changes to the event contract or the public API need a major version once we're past 0.x) and merge it. +2. Tag the merge commit and push the tag: `git tag analytics-v0.2.0 && git push origin analytics-v0.2.0`. +3. The workflow checks that the tag matches the version, runs the tests, and publishes. + +One-time setup: an npm account with publish rights on the `@rawtree` scope, and on npmjs.com a trusted publisher for this repository and the `release-sdk.yml` workflow (or an `NPM_TOKEN` repository secret). Provenance requires the repository to be public. + ## License By contributing, you agree that your contributions are licensed under the [Apache License 2.0](LICENSE). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..294d8c1 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security policy + +## Reporting a vulnerability + +Please don't open a public issue for security problems. Report them privately through GitHub: on this repository's **Security** tab, choose **Report a vulnerability**. We'll acknowledge the report and keep you updated while we fix it. + +Include what's affected (the SDK, the collector, the dashboard, sign-in, or the console), how to reproduce it, and the impact you see. Never include real API keys, tokens, or other people's data. + +## Supported versions + +Security fixes go into the latest release of `@rawtree/analytics` and the `main` branch.