-
Notifications
You must be signed in to change notification settings - Fork 0
Add publishing, lint, and type-drift gates from create-ts-lib #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||||
| name: Release | ||||||||||||||||
|
|
||||||||||||||||
| # Publishing is triggered by *publishing a GitHub release*, not by pushing a tag — a | ||||||||||||||||
| # tag is cheap to create by accident, a release is a deliberate act. | ||||||||||||||||
| on: | ||||||||||||||||
| release: | ||||||||||||||||
| types: [published] | ||||||||||||||||
|
|
||||||||||||||||
| permissions: | ||||||||||||||||
| contents: read | ||||||||||||||||
| # npm trusted publishing (OIDC). There is no NPM_TOKEN anywhere in this workflow; | ||||||||||||||||
| # the trust relationship lives in the package settings on npmjs.com. | ||||||||||||||||
| id-token: write | ||||||||||||||||
|
|
||||||||||||||||
| concurrency: | ||||||||||||||||
| group: release-${{ github.event.release.tag_name }} | ||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||
|
|
||||||||||||||||
| jobs: | ||||||||||||||||
| publish: | ||||||||||||||||
| name: Publish to npm | ||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
| steps: | ||||||||||||||||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||||||||||||||||
| with: | ||||||||||||||||
| ref: ${{ github.event.release.tag_name }} | ||||||||||||||||
| persist-credentials: false | ||||||||||||||||
|
|
||||||||||||||||
| - uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 | ||||||||||||||||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||||||||||||||||
| with: | ||||||||||||||||
| node-version: 22 | ||||||||||||||||
| cache: pnpm | ||||||||||||||||
| registry-url: https://registry.npmjs.org | ||||||||||||||||
|
|
||||||||||||||||
| # Node 22 ships npm 10, which predates trusted publishing. | ||||||||||||||||
| - name: Upgrade npm | ||||||||||||||||
| run: | | ||||||||||||||||
| npm config set prefix ~/.local | ||||||||||||||||
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | ||||||||||||||||
| PATH="$HOME/.local/bin:$PATH" npm install -g npm@latest | ||||||||||||||||
|
Comment on lines
+32
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/release.yml | sed -n '1,90p'
printf '%s\n' '--- repository toolchain declarations ---'
rg -n --hidden -S 'node-version|npm@|packageManager|engines|trusted|provenance|npm publish|actions/setup-node' \
.github package.json pnpm-lock.yaml 2>/dev/null || true
printf '%s\n' '--- local npm/node availability ---'
node --version 2>/dev/null || true
npm --version 2>/dev/null || trueRepository: hbmartin/tailwind-vite-font-kit Length of output: 12923 🌐 Web query:
💡 Result: Trusted publishing in npm allows you to publish packages directly from CI/CD workflows using OpenID Connect (OIDC) authentication, removing the requirement for long-lived npm access tokens [1][2]. As of the specified versions (npm 11.5.1 and Node.js 22.14.0), the requirements and details for using trusted publishing are: Core Version Requirements - npm CLI: Version 11.5.1 or later [1][2]. - Node.js: Version 22.14.0 or higher [1][2]. General Prerequisites - Existing Package: The npm package must already exist on the registry before a trusted publisher can be configured for it [3][4]. - Permissions: You must have write access (maintainer or owner) to the package [3][4]. - Account Security: Two-factor authentication (2FA) must be enabled at the npm account level [3][5]. - CI/CD Provider: You must use a supported cloud-based CI/CD provider (such as GitHub Actions, GitLab CI/CD, or CircleCI) with cloud-hosted runners [1][6][4]. Self-hosted runners are not supported [1]. Configuration and Usage - OIDC Authentication: Trusted publishing works by exchanging a short-lived OIDC token for an npm publish token at runtime [4][2]. - Provenance: When using trusted publishing, provenance attestations are automatically generated for your packages without requiring the --provenance flag [6]. - Command Flags: When configuring trust relationships, you must specify at least one permission flag: --allow-publish or --allow-stage-publish [3][5]. - Important Note: If you encounter an ENEEDAUTH error, ensure that all fields in your configuration (such as workflow filenames and IDs) are exact and case-sensitive [1]. Additionally, for GitHub Actions, verify that the id-token: write permission is set in your workflow file [1]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- package metadata ---'
cat -n package.json | sed -n '18,75p'
printf '%s\n' '--- npm 11.5.1 metadata ---'
curl -fsSL https://registry.npmjs.org/npm/11.5.1 |
jq '{version, engines, dist: {tarball, integrity}}'
printf '%s\n' '--- npm latest metadata ---'
curl -fsSL https://registry.npmjs.org/npm/latest |
jq '{version, engines}'
printf '%s\n' '--- setup-node version-resolution documentation references ---'
rg -n -S 'node-version: 22|22\.14\.0|semver|latest|check-latest' .github README.md package.json 2>/dev/null || trueRepository: hbmartin/tailwind-vite-font-kit Length of output: 3800 Pin the npm trusted-publishing toolchain. Set 🧰 Tools🪛 zizmor (1.29.0)[warning] 41-41: ad-hoc installation of packages (adhoc-packages): installs a package outside of a lockfile (adhoc-packages) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||
|
|
||||||||||||||||
| - name: Install | ||||||||||||||||
| run: pnpm install --frozen-lockfile | ||||||||||||||||
|
|
||||||||||||||||
| - name: Tag matches package.json version | ||||||||||||||||
| run: | | ||||||||||||||||
| tag="${{ github.event.release.tag_name }}" | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Do not interpolate the release tag into shell source. GitHub expands this expression before the shell parses the script. A release tag containing shell metacharacters can alter the command in this OIDC-enabled publish job. Pass the value through Proposed fix - name: Tag matches package.json version
+ env:
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
- tag="${{ github.event.release.tag_name }}"
+ tag="$RELEASE_TAG"
pkg="v$(node -p "require('./package.json').version")"📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.29.0)[error] 48-48: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||
| pkg="v$(node -p "require('./package.json').version")" | ||||||||||||||||
| if [ "$tag" != "$pkg" ]; then | ||||||||||||||||
| echo "::error::release tag $tag does not match package.json ($pkg)" | ||||||||||||||||
| exit 1 | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| - name: Release checks | ||||||||||||||||
| run: pnpm run release:check | ||||||||||||||||
|
|
||||||||||||||||
| - name: Report packed size | ||||||||||||||||
| run: pnpm run size:report | ||||||||||||||||
|
|
||||||||||||||||
| # `release:check` just ran `prepublishOnly` in full, so re-running it here would | ||||||||||||||||
| # only double the wall clock. There is no build step and no prepack hook: `files` | ||||||||||||||||
| # ships the sources as-is, so nothing is skipped by --ignore-scripts. | ||||||||||||||||
| - name: Publish | ||||||||||||||||
| run: | | ||||||||||||||||
| tag=latest | ||||||||||||||||
| if [ "${{ github.event.release.prerelease }}" = "true" ]; then tag=next; fi | ||||||||||||||||
| npm publish --tag "$tag" --access public --provenance --ignore-scripts | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,6 @@ node_modules | |
| test/fixture/dist | ||
| metrics.json | ||
| cls-metrics.json | ||
| coverage | ||
| *.tgz | ||
| *.tsbuildinfo | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "$schema": "./node_modules/oxfmt/configuration_schema.json", | ||
| "semi": false, | ||
| "singleQuote": true, | ||
| "printWidth": 100, | ||
| "ignorePatterns": [ | ||
| "**/*.json", | ||
| "**/*.jsonc", | ||
| "**/*.yml", | ||
| "**/*.md", | ||
| "**/*.css", | ||
| "**/*.html", | ||
| "test/fixture/dist/**" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "ignorePatterns": ["registry/r/**", "test/fixture/dist/**"], | ||
| "plugins": ["typescript", "unicorn", "oxc"], | ||
| "categories": { | ||
| "correctness": "error" | ||
| }, | ||
| "env": { | ||
| "builtin": true, | ||
| "node": true, | ||
| "es2024": true | ||
| }, | ||
| "rules": {} | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: hbmartin/tailwind-vite-font-kit
Length of output: 3052
🌐 Web query:
npm trusted publishing package manager caching release builds setup-node cache pnpm guidance💡 Result:
To set up npm trusted publishing with dependency caching in your CI/CD workflows, follow this guidance based on current best practices for August 2026. Trusted Publishing Overview Trusted publishing replaces long-lived NPM_TOKEN secrets with short-lived OpenID Connect (OIDC) tokens [1][2]. You must configure the trust relationship on npmjs.com under your package settings, specifying your CI provider, repository, and workflow constraints [3][2]. Your CI job requires id-token: write permissions [4][5][2]. When configured, the npm CLI automatically detects the environment and uses OIDC to authenticate, removing the need for an explicit authentication token [1][2]. Caching Guidance For release builds, it is common practice to disable automatic package manager caching to ensure the environment is clean and reproducible [4][5]. However, for general CI jobs or if you choose to cache dependencies for speed, note the following configurations: 1. Using setup-node with pnpm: The actions/setup-node action supports caching the pnpm store [6][7]. To implement this, set cache: 'pnpm' in your setup-node configuration [8][7]. Ensure your workflow defines cache-dependency-path: pnpm-lock.yaml to target the correct lockfile [7]. Example Configuration: - uses: actions/setup-node@v7 with: node-version: '24' cache: 'pnpm' cache-dependency-path: pnpm-lock.yaml - run: pnpm install --frozen-lockfile 2. Important Caching Considerations: - Caching for Release Builds: Official documentation often recommends setting package-manager-cache: false during the publish job to ensure build isolation [4][5]. - pnpm and setup-node: Always ensure pnpm is available (e.g., via corepack or pnpm/action-setup) before the setup-node step, as setup-node may fail if it cannot locate the pnpm executable [8][6][9]. - Cache Contents: Using cache: 'pnpm' caches the pnpm store, not the node_modules directory [6][7]. Running pnpm install --frozen-lockfile is still necessary to reconstruct the project layout and validate dependencies against the lockfile [7]. Provenance Trusted publishing automatically generates provenance attestations for your packages [4][10]. If you encounter issues, verify your npm CLI version (v11.15.0 or later is recommended) [1][10]. While automatic in many cases, you can explicitly ensure provenance by adding --provenance to your publish command or setting "provenance": true in your package.json under publishConfig [4][10].
Citations:
🏁 Script executed:
Repository: hbmartin/tailwind-vite-font-kit
Length of output: 318
🏁 Script executed:
Repository: hbmartin/tailwind-vite-font-kit
Length of output: 6005
🏁 Script executed:
Repository: hbmartin/tailwind-vite-font-kit
Length of output: 8157
🏁 Script executed:
Repository: hbmartin/tailwind-vite-font-kit
Length of output: 8002
Remove
cache: pnpmfrom the publishing job.package-manager-cache: falsedoes not disable an explicitly configuredcacheinput. The job must not restore or save the pnpm store in this release path.🤖 Prompt for AI Agents
Source: Linters/SAST tools