Skip to content

Commit

Permalink
build(ci): add npm publication to workflow (#158)
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit authored Oct 26, 2024
1 parent ee79e83 commit d39a236
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 138 deletions.
4 changes: 4 additions & 0 deletions .clean-publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"withoutPublish": true,
"tempDir": "package"
}
82 changes: 81 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,88 @@ on:
- 'v*'

jobs:
release:
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Type check
run: pnpm typecheck

- name: Lint
run: pnpm lint

- name: Run unit tests
run: pnpm test
env:
FORCE_COLOR: 2

- name: Run examples
run: cd examples && pnpm all
publish-npm:
runs-on: ubuntu-latest
needs: build-release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Read package.json version
id: package-version
uses: jaywcjlove/github-action-package@main

- name: Publish release
run: pnpm publish --no-git-checks
if: ${{ contains(steps.package-version.outputs.version, '-') == false }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish release candidate
if: ${{ contains(steps.package-version.outputs.version, '-rc') == true }}
run: pnpm publish --no-git-checks --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish beta release
if: ${{ contains(steps.package-version.outputs.version, '-beta') == true }}
run: pnpm publish --no-git-checks --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish alpha release
if: ${{ contains(steps.package-version.outputs.version, '-alpha') == true }}
run: pnpm publish --no-git-checks --tag alpha
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
changelog:
runs-on: ubuntu-latest
needs: publish-npm
steps:
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
_I'm transitioning to a full-time open source career. Your support would be greatly appreciated 🙌_
<a href="https://polar.sh/tinylibs/subscriptions"><picture><source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/embed/tiers.svg?org=tinylibs&darkmode"><img alt="Subscription Tiers on Polar" src="https://polar.sh/embed/tiers.svg?org=tinylibs"></picture></a>

# Tinybench 🔎

[![CI](https://github.com/tinylibs/tinybench/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/tinylibs/tinybench/actions/workflows/test.yml)
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
"engines": {
"node": ">=18.0.0"
},
"publishConfig": {
"directory": "package"
},
"scripts": {
"postinstall": "pnpm exec simple-git-hooks",
"dev": "tsup --watch",
"build": "tsup",
"publish": "pnpm build && clean-publish",
"prepublishOnly": "rm -rf ./package && clean-publish",
"postpublish": "rm -rf ./package",
"typecheck": "tsc --noEmit",
"lint": "eslint src test examples tsup.config.ts",
"lint:fix": "eslint --fix src test examples tsup.config.ts",
"release": "bumpp package.json --commit --push --tag && pnpm publish",
"release": "bumpp package.json --commit --push --tag",
"test": "vitest --retry=5 --run"
},
"main": "./dist/index.cjs",
Expand All @@ -44,7 +48,7 @@
"@commitlint/config-conventional": "^19.5.0",
"@size-limit/preset-small-lib": "^11.1.6",
"@size-limit/time": "^11.1.6",
"@types/node": "^22.8.0",
"@types/node": "^22.8.1",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"bumpp": "^9.7.1",
Expand All @@ -57,7 +61,7 @@
"p-limit": "^6.1.0",
"simple-git-hooks": "^2.11.1",
"size-limit": "^11.1.6",
"tsup": "^8.3.4",
"tsup": "^8.3.5",
"typescript": "~5.6.3",
"vitest": "^2.1.3"
},
Expand Down
Loading

0 comments on commit d39a236

Please sign in to comment.