Skip to content

Commit

Permalink
setup build and release packages (#262)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomek Kopacki <[email protected]>
  • Loading branch information
notrab and tk-o authored Feb 20, 2025
1 parent 7290e4e commit 6941f0b
Show file tree
Hide file tree
Showing 20 changed files with 557 additions and 46 deletions.
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"ignore": [
"ensnode",
"@ensnode/ensrainbow",
"@ensnode/utils",
"@docs/ensnode",
"@docs/ensrainbow"
]
Expand Down
11 changes: 11 additions & 0 deletions .changeset/hot-terms-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@ensnode/ponder-subgraph": minor
"@ensnode/ens-deployments": minor
"@ensnode/ensrainbow-sdk": minor
"@ensnode/shared-configs": minor
"@ensnode/utils": minor
"@ensnode/ponder-schema": minor
"ensadmin": minor
---

Initial Release
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ on:
- main

jobs:
changed-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changes.outputs.packages }}
steps:
- uses: actions/checkout@v4
- name: Check for package changes
id: changes
uses: dorny/paths-filter@v2
with:
filters: |
packages:
- 'packages/**'
static-analysis:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -36,6 +50,10 @@ jobs:
- name: Run TypeScript type checks
run: pnpm -r typecheck

- name: Build packages
if: needs.changed-packages.outputs.packages == 'true'
run: pnpm packages:prepublish

# This will run the dev command in background, wait for
# RUNTIME_CHECK_TIMEOUT_SECONDS seconds, and then kill the process if it
# is still running. If the command does not throw an error within that
Expand Down Expand Up @@ -84,4 +102,3 @@ jobs:

- name: Run unit tests
run: pnpm -r test

48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release Packages

on:
push:
branches:
- main
paths:
- "packages/**"
- ".changeset/**"
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
issues: write
pull-requests: write

jobs:
release:
name: Release Packages
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

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

- name: Create Release PR or Publish to NPM
id: changesets
uses: changesets/action@v1
with:
commit: "chore(release): version packages"
title: "chore(release): version packages"
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 4 additions & 14 deletions apps/ensadmin/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import js from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
import importPlugin from "eslint-plugin-import";

export default tseslint.config(
{
Expand All @@ -27,10 +27,7 @@ export default tseslint.config(
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
// Match Biome's formatting rules
quotes: ["error", "double"],
indent: ["error", 2, { SwitchCase: 1 }],
Expand All @@ -49,14 +46,7 @@ export default tseslint.config(
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
"newlines-between": "always",
alphabetize: {
order: "asc",
Expand All @@ -65,5 +55,5 @@ export default tseslint.config(
},
],
},
}
},
);
6 changes: 1 addition & 5 deletions apps/ensrainbow/src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { type EnsRainbow, ErrorCode, StatusCode, labelHashToBytes } from "@ensno
import { ByteArray } from "viem";
import { logger } from "../utils/logger";
import { parseNonNegativeInteger } from "../utils/number-utils";
import {
LABELHASH_COUNT_KEY,
ensureIngestionNotIncomplete,
isIngestionInProgress,
} from "./database";
import { LABELHASH_COUNT_KEY, ensureIngestionNotIncomplete } from "./database";
import { ENSRainbowDB, safeGet } from "./database";

export class ENSRainbowServer {
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
"scripts": {
"lint": "pnpm -r lint",
"lint:ci": "pnpm -r lint:ci",
"changeset": "changeset"
"changeset": "changeset",
"release": "changeset publish",
"packages:prepublish": "pnpm -r --filter='@ensnode/*' prepublish"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@changesets/cli": "^2.27.12",
"tsup": "catalog:",
"typescript": "catalog:"
},
"engines": {
Expand All @@ -20,6 +23,7 @@
"overrides": {
"ponder>vite": "5.4.14",
"astro>esbuild": "0.25.0",
"tsup>esbuild": "0.25.0",
"tsx>esbuild": "0.25.0",
"vite>esbuild": "0.25.0"
}
Expand Down
17 changes: 13 additions & 4 deletions packages/ens-deployments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@
"homepage": "https://github.com/namehash/ensnode/tree/main/packages/ens-deployments",
"keywords": ["ENS", "ENSNode"],
"exports": "./src/index.ts",
"files": ["dist"],
"publishConfig": {
"access": "public",
"exports": {
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"scripts": {
"prepublish": "tsup",
"lint:ci": "biome ci"
},
"peerDependencies": {
"viem": "^catalog:"
},
"devDependencies": {
"@ensnode/shared-configs": "workspace:",
"@biomejs/biome": "catalog:",
"@ensnode/shared-configs": "workspace:",
"tsup": "catalog:",
"typescript": "catalog:",
"viem": "catalog:"
},
"dependencies": {
"@ponder/utils": "^0.2.3"
},
"publishConfig": {
"access": "public"
}
}
18 changes: 18 additions & 0 deletions packages/ens-deployments/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
platform: "browser",
format: ["esm"],
target: "es2022",
bundle: true,
splitting: false,
sourcemap: true,
dts: true,
clean: true,
external: ["viem", "@ponder/utils"],
outDir: "./dist",
esbuildOptions(options) {
options.mainFields = ["browser", "module", "main"];
},
});
23 changes: 21 additions & 2 deletions packages/ensnode-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@ensnode/utils",
"private": true,
"version": "0.0.1",
"type": "module",
"description": "A utility library for interacting with ENS data",
Expand All @@ -16,7 +15,26 @@
"./subname-helpers": "./src/subname-helpers.ts",
"./types": "./src/types.ts"
},
"files": ["dist"],
"publishConfig": {
"access": "public",
"exports": {
"./cache": {
"types": "./dist/cache.d.ts",
"default": "./dist/cache.js"
},
"./subname-helpers": {
"types": "./dist/subname-helpers.d.ts",
"default": "./dist/subname-helpers.js"
},
"./types": {
"types": "./dist/types.d.ts",
"default": "./dist/types.js"
}
}
},
"scripts": {
"prepublish": "tsup",
"lint": "biome check --write .",
"lint:ci": "biome ci",
"test": "vitest",
Expand All @@ -26,9 +44,10 @@
"viem": "^catalog:"
},
"devDependencies": {
"@ensnode/shared-configs": "workspace:",
"@biomejs/biome": "catalog:",
"@ensnode/shared-configs": "workspace:",
"@types/node": "catalog:",
"tsup": "^8.3.6",
"typescript": "catalog:",
"viem": "catalog:",
"vitest": "catalog:"
Expand Down
21 changes: 21 additions & 0 deletions packages/ensnode-utils/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: {
"subname-helpers": "src/subname-helpers.ts",
types: "src/types.ts",
},
platform: "browser",
format: ["esm"],
target: "es2022",
bundle: true,
splitting: false,
sourcemap: true,
dts: true,
clean: true,
external: ["viem"],
outDir: "./dist",
esbuildOptions(options) {
options.mainFields = ["browser", "module", "main"];
},
});
32 changes: 28 additions & 4 deletions packages/ensrainbow-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,33 @@
"./consts": "./src/consts.ts",
"./label-utils": "./src/label-utils.ts"
},
"files": ["dist"],
"publishConfig": {
"access": "public",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./client": {
"types": "./dist/client.d.ts",
"default": "./dist/client.js"
},
"./consts": {
"types": "./dist/consts.d.ts",
"default": "./dist/consts.js"
},
"./label-utils": {
"types": "./dist/label-utils.d.ts",
"default": "./dist/label-utils.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"scripts": {
"prepublish": "tsup",
"test": "vitest",
"typecheck": "tsc --noEmit",
"lint": "biome check --write",
Expand All @@ -27,13 +53,11 @@
"viem": "catalog:"
},
"devDependencies": {
"@ensnode/shared-configs": "workspace:",
"@biomejs/biome": "catalog:",
"@ensnode/shared-configs": "workspace:",
"@ensnode/utils": "workspace:",
"tsup": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
},
"publishConfig": {
"access": "public"
}
}
24 changes: 24 additions & 0 deletions packages/ensrainbow-sdk/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: {
client: "src/client.ts",
consts: "src/consts.ts",
index: "src/index.ts",
labelUtils: "src/label-utils.ts",
"label-utils": "src/label-utils.ts",
},
platform: "browser",
format: ["esm"],
target: "es2022",
bundle: true,
splitting: false,
sourcemap: true,
dts: true,
clean: true,
external: ["viem", "@ensnode/utils"],
outDir: "./dist",
esbuildOptions(options) {
options.mainFields = ["browser", "module", "main"];
},
});
Loading

0 comments on commit 6941f0b

Please sign in to comment.