1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p common-updater-scripts jq
3
4set -euo pipefail
5
6declare -ar packages=(
7 langchain
8 langchain-anthropic
9 langchain-azure-dynamic-sessions
10 langchain-chroma
11 langchain-community
12 langchain-core
13 langchain-deepseek
14 langchain-fireworks
15 langchain-groq
16 langchain-huggingface
17 langchain-mistralai
18 langchain-mongodb
19 langchain-ollama
20 langchain-openai
21 langchain-perplexity
22 langchain-tests
23 langchain-text-splitters
24 langchain-xai
25)
26
27tags=$(git ls-remote --tags --refs "https://github.com/langchain-ai/langchain" | cut --delimiter=/ --field=3-)
28
29# Will be printed as JSON at the end to list what needs updating
30updates=""
31
32for package in ${packages[@]}
33do
34 pyPackage="python3Packages.$package"
35 oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion $pyPackage" | tr -d '"')"
36 newVersion=$(echo "$tags" | grep -Po "(?<=$package==)\d+\.\d+\.\d+$" | sort --version-sort --reverse | head -1 )
37 if [[ "$newVersion" != "$oldVersion" ]]; then
38 update-source-version $pyPackage "$newVersion"
39 updates+="{
40 \"attrPath\": \"$pyPackage\",
41 \"oldVersion\": \"$oldVersion\",
42 \"newVersion\": \"$newVersion\",
43 \"files\": [
44 \"$PWD/pkgs/development/python-modules/${package}/default.nix\"
45 ]
46},"
47 fi
48done
49# Remove trailing comma
50updates=${updates%,}
51# Print the updates in JSON format
52echo "[ $updates ]"