Skip to content

Commit

Permalink
all[major]: Better release workflow (#3717)
Browse files Browse the repository at this point in the history
* all[minor]: Better release workflow

* cr

* added release-it & config files to all pkgs, and template

* tmp: rename mistralai to brace from langchain

* tmp: rename mistralai to brace from langchain

* add missing test infra to libs

* cr

* cr

* cr

* cr

* cr

* chore: lint files

* cr

* revert mistral workspace name change

* chore: lint files

* update pkg json script

* tmp change names

* cr

* cr

* cr

* cr

* cr

* cr

* try/catch around yarn install

* cr

* cr

* cr

* cr

* cr

* cr

* cr

* update scripts

* tmp make mistral basproul npm

* account for npm 2fa

* cr

* cr

* cr

* cr

* support for npm tags

* cr

* revert basproul changes

* chore: lint files

* cr

* drop release it script

* verify version with semver

* drop empty tests

* fix dep

* docs

* Update CONTRIBUTING.md

---------

Co-authored-by: Jacob Lee <[email protected]>
  • Loading branch information
bracesproul and jacoblee93 authored Dec 21, 2023
1 parent ed29d6b commit c8ff957
Show file tree
Hide file tree
Showing 26 changed files with 448 additions and 16 deletions.
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ even patch releases may contain [non-backwards-compatible changes](https://semve
If your contribution has made its way into a release, we will want to give you credit on Twitter (only if you want though)!
If you have a Twitter account you would like us to mention, please let us know in the PR or in another manner.

#### Integration releases

You can invoke the release flow by calling `yarn release` from the package root.

There are three parameters which can be passed to this script, one required and two optional.

- __Required__: `--workspace <workspace name>`. eg: `--workspace @langchain/core` (always appended as the first flag when running `yarn release`)
- __Optional__: `--version <version number>` eg: `--version 1.0.8`. Defaults to adding one to the patch version.
- __Optional__: `--bump-deps` eg `--bump-deps` Will find all packages in the repo which depend on this workspace and checkout a new branch, update the dep version, run yarn install, commit & push to new branch.
- __Optional__: `--tag <tag>` eg `--tag beta` Add a tag to the NPM release.
- __Optional__: `--inc <inc>` eg `--inc patch` The semver increment to apply to the version. Can be one of `major`, `minor`, `patch`, `premajor`, `preminor`, `prepatch`, or `prerelease`. Defaults to `patch`.

This script automatically bumps the package version, creates a new release branch with the changes, pushes the branch to GitHub, uses `release-it` to automatically release to NPM, and more depending on the flags passed.

Halfway through this script, you'll be prompted to enter an NPM OTP (typically from an authenticator app). This value is not stored anywhere and is only used to authenticate the NPM release.

Full example: `yarn release @langchain/core --version 2.0.0 --bump-deps --tag beta --inc major`.

### πŸ› οΈ Tooling

This project uses the following tools, which are worth getting familiar
Expand Down
14 changes: 14 additions & 0 deletions libs/create-langchain-integration/helpers/default_file_contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,17 @@ yarn lint && yarn format
If you add a new file to be exported, either import & re-export from \`src/index.ts\`, or add it to \`scripts/create-entrypoints.js\` and run \`yarn build\` to generate the new entrypoint.
`;

export const DEFAULT_RELEASE_IT = `{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
`;
7 changes: 6 additions & 1 deletion libs/create-langchain-integration/helpers/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import fs from "fs/promises";
import os from "os";

import { copy } from "./copy";
import { DEFAULT_ESLINTRC, DEFAULT_README } from "./default_file_contents";
import {
DEFAULT_ESLINTRC,
DEFAULT_README,
DEFAULT_RELEASE_IT,
} from "./default_file_contents";

/**
* Install a internal template to a given `root` directory.
Expand Down Expand Up @@ -43,6 +47,7 @@ export async function installTemplate({ appName, root }: any) {

await fs.writeFile(path.join(root, ".eslintrc.cjs"), DEFAULT_ESLINTRC);
await fs.writeFile(path.join(root, "README.md"), DEFAULT_README);
await fs.writeFile(path.join(root, ".release-it.json"), DEFAULT_RELEASE_IT);

console.log("\nDone!\n");
}
2 changes: 1 addition & 1 deletion libs/create-langchain-integration/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"lint:fix": "yarn lint --fix",
"clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand All @@ -44,6 +43,7 @@
"@typescript-eslint/parser": "^6.12.0",
"dotenv": "^16.3.1",
"dpdm": "^3.12.0",
"release-it": "^15.10.1",
"eslint": "^8.33.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.6.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
12 changes: 12 additions & 0 deletions libs/langchain-anthropic/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
1 change: 1 addition & 0 deletions libs/langchain-anthropic/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ module.exports = {
],
setupFiles: ["dotenv/config"],
testTimeout: 20_000,
passWithNoTests: true
};
1 change: 0 additions & 1 deletion libs/langchain-anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
"clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down
3 changes: 3 additions & 0 deletions libs/langchain-anthropic/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
12 changes: 12 additions & 0 deletions libs/langchain-community/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
1 change: 0 additions & 1 deletion libs/langchain-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"lint:fix": "yarn lint --fix",
"clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down
3 changes: 3 additions & 0 deletions libs/langchain-community/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
12 changes: 12 additions & 0 deletions libs/langchain-google-genai/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
2 changes: 1 addition & 1 deletion libs/langchain-google-genai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"lint:fix": "yarn lint --fix",
"clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down Expand Up @@ -57,6 +56,7 @@
"jest": "^29.5.0",
"jest-environment-node": "^29.6.4",
"prettier": "^2.8.3",
"release-it": "^15.10.1",
"rollup": "^4.5.2",
"ts-jest": "^29.1.0",
"typescript": "<5.2.0"
Expand Down
3 changes: 3 additions & 0 deletions libs/langchain-google-genai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
12 changes: 12 additions & 0 deletions libs/langchain-mistralai/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
1 change: 1 addition & 0 deletions libs/langchain-mistralai/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ module.exports = {
],
setupFiles: ["dotenv/config"],
testTimeout: 20_000,
passWithNoTests: true
};
2 changes: 1 addition & 1 deletion libs/langchain-mistralai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"lint:fix": "yarn lint --fix",
"clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down Expand Up @@ -55,6 +54,7 @@
"jest": "^29.5.0",
"jest-environment-node": "^29.6.4",
"prettier": "^2.8.3",
"release-it": "^15.10.1",
"rollup": "^4.5.2",
"ts-jest": "^29.1.0",
"typescript": "<5.2.0"
Expand Down
3 changes: 3 additions & 0 deletions libs/langchain-mistralai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
12 changes: 12 additions & 0 deletions libs/langchain-openai/.release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"github": {
"release": true,
"autoGenerate": true,
"tokenRef": "GITHUB_TOKEN_RELEASE"
},
"npm": {
"versionArgs": [
"--workspaces-update=false"
]
}
}
1 change: 1 addition & 0 deletions libs/langchain-openai/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ module.exports = {
setupFiles: ["dotenv/config"],
setupFilesAfterEnv: ["./scripts/jest-setup-after-env.js"],
testTimeout: 20_000,
passWithNoTests: true
};
1 change: 0 additions & 1 deletion libs/langchain-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
"clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node scripts/create-entrypoints.js pre",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-openai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { awaitAllCallbacks } from "../src/callbacks/promises.js";
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";

afterAll(awaitAllCallbacks);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@
"example": "yarn workspace examples start",
"precommit": "turbo run precommit",
"docs": "yarn workspace core_docs start",
"docs:api_refs": "yarn workspace api_refs start"
"docs:api_refs": "yarn workspace api_refs start",
"release": "node release_workspace.js --workspace"
},
"author": "LangChain",
"license": "MIT",
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
"@types/jest": "^29.5.3",
"@types/semver": "^7",
"commander": "^11.1.0",
"dotenv": "^16.0.3",
"lint-staged": "^13.1.1",
"prettier": "^2.8.3",
"semver": "^7.5.4",
"typescript": "~5.1.6"
},
"dependencies": {
Expand Down
Loading

2 comments on commit c8ff957

@vercel
Copy link

@vercel vercel bot commented on c8ff957 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

langchainjs-docs – ./docs/core_docs/

langchainjs-docs-langchain.vercel.app
langchainjs-docs-git-main-langchain.vercel.app
js.langchain.com
langchainjs-docs-ruddy.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c8ff957 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.