Skip to content

Commit 8801647

Browse files
ci: add GitHub workflow for publishing dev releases
1 parent 8a77e9a commit 8801647

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed

.github/workflows/dev-release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Dev Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
package:
6+
description: "Package to release"
7+
required: true
8+
type: choice
9+
options:
10+
- "langchain"
11+
- "@langchain/core"
12+
- "@langchain/classic"
13+
- "@langchain/community"
14+
- "@langchain/textsplitters"
15+
- "@langchain/mcp-adapters"
16+
- "@langchain/anthropic"
17+
- "@langchain/aws"
18+
- "@langchain/azure-cosmosdb"
19+
- "@langchain/azure-dynamic-sessions"
20+
- "@langchain/baidu-qianfan"
21+
- "@langchain/cerebras"
22+
- "@langchain/cloudflare"
23+
- "@langchain/cohere"
24+
- "@langchain/deepseek"
25+
- "@langchain/exa"
26+
- "@langchain/google-cloud-sql-pg"
27+
- "@langchain/google-common"
28+
- "@langchain/google-gauth"
29+
- "@langchain/google-genai"
30+
- "@langchain/google-vertexai"
31+
- "@langchain/google-vertexai-web"
32+
- "@langchain/google-webauth"
33+
- "@langchain/groq"
34+
- "@langchain/mistralai"
35+
- "@langchain/mixedbread-ai"
36+
- "@langchain/mongodb"
37+
- "@langchain/nomic"
38+
- "@langchain/ollama"
39+
- "@langchain/openai"
40+
- "@langchain/pinecone"
41+
- "@langchain/qdrant"
42+
- "@langchain/redis"
43+
- "@langchain/tavily"
44+
- "@langchain/weaviate"
45+
- "@langchain/xai"
46+
- "@langchain/yandex"
47+
npm_tag:
48+
description: "NPM tag for the release"
49+
required: false
50+
default: "dev"
51+
type: string
52+
53+
env:
54+
CI: true
55+
56+
concurrency:
57+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.package }}
58+
cancel-in-progress: true
59+
60+
jobs:
61+
release:
62+
name: Dev Release ${{ inputs.package }}
63+
if: github.repository == 'langchain-ai/langchainjs'
64+
runs-on: ubuntu-latest
65+
permissions:
66+
contents: read
67+
id-token: write
68+
steps:
69+
- name: ⬇️ Checkout repo
70+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6
71+
with:
72+
fetch-depth: 0
73+
74+
- name: 📦 Setup pnpm
75+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
76+
77+
- name: ⎔ Setup node
78+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
79+
with:
80+
node-version-file: ".nvmrc"
81+
cache: "pnpm"
82+
83+
- name: 📥 Install deps
84+
run: pnpm install --frozen-lockfile
85+
86+
- name: 🔍 Get package directory
87+
id: package-dir
88+
run: |
89+
PACKAGE="${{ inputs.package }}"
90+
# Map package name to directory
91+
case "$PACKAGE" in
92+
"@langchain/core")
93+
DIR="libs/langchain-core"
94+
;;
95+
"langchain")
96+
DIR="libs/langchain"
97+
;;
98+
"@langchain/community")
99+
DIR="libs/langchain-community"
100+
;;
101+
"@langchain/textsplitters")
102+
DIR="libs/langchain-textsplitters"
103+
;;
104+
"@langchain/mcp-adapters")
105+
DIR="libs/langchain-mcp-adapters"
106+
;;
107+
"@langchain/standard-tests")
108+
DIR="libs/langchain-standard-tests"
109+
;;
110+
"@langchain/classic")
111+
DIR="libs/langchain-classic"
112+
;;
113+
*)
114+
# For provider packages, extract the package name without @langchain/
115+
PKG_NAME="${PACKAGE#@langchain/}"
116+
DIR="libs/providers/langchain-${PKG_NAME}"
117+
;;
118+
esac
119+
echo "dir=$DIR" >> $GITHUB_OUTPUT
120+
121+
- name: 🏷️ Get short SHA
122+
id: sha
123+
run: echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
124+
125+
- name: 📝 Update package version
126+
working-directory: ${{ steps.package-dir.outputs.dir }}
127+
run: |
128+
# Get current version from package.json
129+
CURRENT_VERSION=$(node -p "require('./package.json').version")
130+
# Create dev version with tag and short SHA
131+
DEV_VERSION="${CURRENT_VERSION}-${{ inputs.npm_tag }}.${{ steps.sha.outputs.short }}"
132+
echo "Publishing ${{ inputs.package }}@${DEV_VERSION}"
133+
# Update version in package.json
134+
npm version "$DEV_VERSION" --no-git-tag-version
135+
136+
- name: 🔨 Build package
137+
run: pnpm run build --filter "${{ inputs.package }}"
138+
139+
- name: 🔐 Setup npm auth
140+
run: |
141+
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
142+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
143+
144+
- name: 🚀 Publish to npm
145+
working-directory: ${{ steps.package-dir.outputs.dir }}
146+
run: npm publish --tag ${{ inputs.npm_tag }} --access public
147+
env:
148+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,37 @@ a developer and published to [npm](https://www.npmjs.com/package/langchain).
7676
If your contribution has made its way into a release, we will want to give you credit on Twitter (only if you want though)!
7777
If you have a Twitter account you would like us to mention, please let us know in the PR or in another manner.
7878

79+
#### 🧪 Dev Releases
80+
81+
For testing unreleased changes, maintainers can publish dev releases of individual packages. Dev releases are published to npm with a special tag and version format that includes the git commit SHA.
82+
83+
**To create a dev release:**
84+
85+
1. Go to [Actions → Dev Release](https://github.com/langchain-ai/langchainjs/actions/workflows/dev-release.yml)
86+
2. Click "Run workflow"
87+
3. Select the branch you want to release from (defaults to `main`, but you can choose your feature branch)
88+
4. Select the package you want to release from the dropdown
89+
5. Optionally change the npm tag (defaults to `dev`)
90+
6. Click "Run workflow"
91+
92+
**Version format:** `x.y.z-<tag>.<short-sha>` (e.g., `1.1.0-dev.abc1234`)
93+
94+
**To install a dev release:**
95+
96+
```bash
97+
# Install the latest dev release
98+
npm install @langchain/core@dev
99+
100+
# Install a specific dev version
101+
npm install @langchain/core@1.1.0-dev.abc1234
102+
```
103+
104+
Dev releases are useful for:
105+
106+
- Testing bug fixes before an official release
107+
- Validating new features in downstream projects
108+
- CI/CD pipelines that need to test against the latest changes
109+
79110
### 🛠️ Tooling
80111

81112
This project uses the following tools, which are worth getting familiar

0 commit comments

Comments
 (0)