infra: update generate notes and better local handle (#701)

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
Aaron Pham
2023-11-19 17:50:23 -05:00
committed by GitHub
parent 83f95c74ff
commit 44f05da845
5 changed files with 180 additions and 96 deletions

View File

@@ -4,8 +4,8 @@ TAG="${1#v}"
# Check if an argument is provided
if [ $# -eq 0 ]; then
echo "No argument provided."
exit 1
echo "No argument provided."
exit 1
fi
cat > release_notes.txt << EOF
@@ -24,11 +24,9 @@ pip install --upgrade openllm==${TAG}
All available models: \`\`\`openllm models\`\`\`
To start a LLM: \`\`\`python -m openllm start opt\`\`\`
To start a LLM: \`\`\`python -m openllm start HuggingFaceH4/zephyr-7b-beta\`\`\`
To run OpenLLM within a container environment (requires GPUs): \`\`\`docker run --gpus all -it -P ghcr.io/bentoml/openllm:${TAG} start opt\`\`\`
To run OpenLLM Clojure UI (community-maintained): \`\`\`docker run -p 8420:80 ghcr.io/bentoml/openllm-ui-clojure:${TAG}\`\`\`
To run OpenLLM within a container environment (requires GPUs): \`\`\`docker run --gpus all -it -P -v \$PWD/data:\$HOME/.cache/huggingface/ ghcr.io/bentoml/openllm:${TAG} start HuggingFaceH4/zephyr-7b-beta\`\`\`
Find more information about this release in the [CHANGELOG.md](https://github.com/bentoml/OpenLLM/blob/main/CHANGELOG.md)

View File

@@ -4,63 +4,63 @@ set -e
# Function to print script usage
print_usage() {
echo "Usage: $0 [--release <major|minor|patch>]"
echo "Usage: $0 [--release <major|minor|patch>]"
}
# Function to validate release argument
validate_release() {
local release=$1
local release=$1
if [[ $release == "major" || $release == "minor" || $release == "patch" ]]; then
return 0
else
return 1
fi
if [[ $release == "major" || $release == "minor" || $release == "patch" ]]; then
return 0
else
return 1
fi
}
if ! [ "$GITHUB_ACTIONS" = true ]; then
echo "This script should only be run on GitHub Actions. Aborting."
exit 1
echo "This script should only be run on GitHub Actions. Aborting."
exit 1
fi
# Check if release flag is provided
if [[ $1 == "--release" ]]; then
# Check if release argument is provided
if [[ -z $2 ]]; then
echo "Error: No release argument provided."
print_usage
exit 1
fi
release=$2
if ! validate_release "$release"; then
echo "Error: Invalid release argument. Only 'major', 'minor', or 'patch' are allowed."
print_usage
exit 1
fi
else
echo "Error: Unknown option or no option provided."
# Check if release argument is provided
if [[ -z $2 ]]; then
echo "Error: No release argument provided."
print_usage
exit 1
fi
release=$2
if ! validate_release "$release"; then
echo "Error: Invalid release argument. Only 'major', 'minor', or 'patch' are allowed."
print_usage
exit 1
fi
else
echo "Error: Unknown option or no option provided."
print_usage
exit 1
fi
release_package() {
local version="$1"
echo "Releasing version ${version}..."
jq --arg release_version "${version}" '.version = $release_version' < package.json > package.json.tmp && mv package.json.tmp package.json
pushd openllm-node &>/dev/null
jq --arg release_version "${version}" '.version = $release_version' < package.json > package.json.tmp && mv package.json.tmp package.json
popd &>/dev/null
towncrier build --yes --version "${version}"
./tools/dependencies.py --release-version "${version}"
cp CHANGELOG.md openllm-python/CHANGELOG.md
git add CHANGELOG.md openllm-python/pyproject.toml openllm-python/CHANGELOG.md changelog.d package.json openllm-node/package.json
git commit -S -sm "infra: prepare for release ${version} [generated] [skip ci]"
git push origin main
echo "Releasing tag ${version}..." && git tag -a "v${version}" -sm "Release ${version} [generated by GitHub Actions]"
git push origin "v${version}"
echo "Finish releasing version ${version}"
local version="$1"
echo "Releasing version ${version}..."
jq --arg release_version "${version}" '.version = $release_version' < package.json > package.json.tmp && mv package.json.tmp package.json
pushd openllm-node &>/dev/null
jq --arg release_version "${version}" '.version = $release_version' < package.json > package.json.tmp && mv package.json.tmp package.json
popd &>/dev/null
towncrier build --yes --version "${version}"
./tools/dependencies.py --release-version "${version}"
cp CHANGELOG.md openllm-python/CHANGELOG.md
git add CHANGELOG.md openllm-python/pyproject.toml openllm-python/CHANGELOG.md changelog.d package.json openllm-node/package.json
git commit -S -sm "infra: prepare for release ${version} [generated] [skip ci]"
git push origin main
echo "Releasing tag ${version}..." && git tag -a "v${version}" -sm "Release ${version} [generated by GitHub Actions]"
git push origin "v${version}"
echo "Finish releasing version ${version}"
}
#get highest tags across all branches, not just the current branch
@@ -78,14 +78,14 @@ VNUM2=${VERSION_BITS[1]}
VNUM3=${VERSION_BITS[2]}
if [[ $release == 'major' ]]; then
VNUM1=$((VNUM1 + 1))
VNUM2=0
VNUM3=0
VNUM1=$((VNUM1 + 1))
VNUM2=0
VNUM3=0
elif [[ $release == 'minor' ]]; then
VNUM2=$((VNUM2 + 1))
VNUM3=0
VNUM2=$((VNUM2 + 1))
VNUM3=0
else
VNUM3=$((VNUM3 + 1))
VNUM3=$((VNUM3 + 1))
fi
echo "Commit count: $(git rev-list --count HEAD)"

View File

@@ -1,10 +1,96 @@
#!/usr/bin/env bash
set -ex
set -e
GIT_ROOT=$(git rev-parse --show-toplevel)
cd "$GIT_ROOT" || exit 1
pip install -e "$GIT_ROOT/openllm-core" -v
pip install -e "$GIT_ROOT/openllm-client" -v
pip install -e "$GIT_ROOT/openllm-python" -v
print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -e, -E, --ext Specify extensions for OpenLLM. Can be used multiple times or as a comma-separated list."
echo " Example: $0 -e ext1,ext2"
echo " Example: $0 --ext ext1 --ext ext2"
echo ""
echo "This script installs various components with optional extensions."
}
split_csv() {
local IFS=','
read -ra ADDR <<< "$1"
for i in "${ADDR[@]}"; do
EXTENSIONS+=("$i")
done
}
# Function to ensure tomlkit is installen# Function to ensure tomlkit is installed
ensure_tomlkit() {
if ! python -c "import tomlkit" > /dev/null 2>&1; then
echo "Installing tomlkit..."
pip install tomlkit
fi
}
# Function to validate extensions
validate_extensions() {
ensure_tomlkit
local valid_extensions
valid_extensions=$(python -c "
import tomlkit
with open('$GIT_ROOT/openllm-python/pyproject.toml', 'r') as file:
data = tomlkit.load(file)
optional_dependencies = data['project']['optional-dependencies']
print(' '.join(optional_dependencies.keys()))
")
COMMENT="[${valid_extensions[*]}]"
COMMENT=${COMMENT// /,} # Replace spaces with commas
for ext in "${EXTENSIONS[@]}"; do
if ! [[ $valid_extensions =~ (^|[[:space:]])$ext($|[[:space:]]) ]]; then
echo "Invalid extension: $ext. Available extensions are: $COMMENT"
exit 1
fi
done
}
EXTENSIONS=()
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--extensions|-e|-E|--ext)
if [[ -n $2 && $2 != -* ]]; then
split_csv "$2"
shift
else
print_usage
exit 1
fi
;;
--help|-h)
print_usage
exit 0
;;
*)
print_usage
exit 1
;;
esac
shift
done
validate_extensions
# Check if the EXTENSIONS array is empty
if [ ${#EXTENSIONS[@]} -eq 0 ]; then
echo "No extensions specified"
EXTENSIONS_STR=""
else
EXTENSIONS_STR="[${EXTENSIONS[*]}]"
EXTENSIONS_STR=${EXTENSIONS_STR// /,} # Replace spaces with commas
fi
pip install -e "$GIT_ROOT/openllm-core"
pip install -e "$GIT_ROOT/openllm-client"
pip install -e "$GIT_ROOT/openllm-python$EXTENSIONS_STR" -v

View File

@@ -7,8 +7,8 @@ GIT_ROOT=$(git rev-parse --show-toplevel)
cd "$GIT_ROOT" || exit 1
[[ -x "$(command -v docker)" ]] || (
echo "docker not found. Make sure to have docker running to run this job."
exit 1
echo "docker not found. Make sure to have docker running to run this job."
exit 1
)
RATCHET_EXP_KEEP_NEWLINES=true find "${GIT_ROOT}/.github/workflows" -type f -iname '*.yml' -exec docker run -it --rm -v "${PWD}":"${PWD}" -w "${PWD}" -e RATCHET_EXP_KEEP_NEWLINES=true ghcr.io/sethvargo/ratchet:0.4.0 pin {} \;

View File

@@ -4,18 +4,18 @@ set -e -o pipefail
# Function to print script usage
print_usage() {
echo "Usage: $0 [--release <major|minor|patch>]"
echo "Usage: $0 [--release <major|minor|patch>]"
}
# Function to validate release argument
validate_release() {
local release=$1
local release=$1
if [[ $release == "major" || $release == "minor" || $release == "patch" ]]; then
return 0
else
return 1
fi
if [[ $release == "major" || $release == "minor" || $release == "patch" ]]; then
return 0
else
return 1
fi
}
check_membership() {
@@ -28,34 +28,34 @@ check_membership() {
}
for cmd in gh jq hatch; do
if ! command -v "$cmd" @ >&1 > /dev/null; then
echo "ERROR: $cmd not installed. Aborting..."
exit 1
fi
if ! command -v "$cmd" @ >&1 > /dev/null; then
echo "ERROR: $cmd not installed. Aborting..."
exit 1
fi
done
check_membership
# Check if release flag is provided
if [[ $1 == "--release" ]]; then
# Check if release argument is provided
if [[ -z $2 ]]; then
echo "Error: No release argument provided."
print_usage
exit 1
fi
release=$2
if ! validate_release "$release"; then
echo "Error: Invalid release argument. Only 'major', 'minor', or 'patch' are allowed."
print_usage
exit 1
fi
else
echo "Error: Unknown option or no option provided."
# Check if release argument is provided
if [[ -z $2 ]]; then
echo "Error: No release argument provided."
print_usage
exit 1
fi
release=$2
if ! validate_release "$release"; then
echo "Error: Invalid release argument. Only 'major', 'minor', or 'patch' are allowed."
print_usage
exit 1
fi
else
echo "Error: Unknown option or no option provided."
print_usage
exit 1
fi
#get highest tags across all branches, not just the current branch
@@ -73,14 +73,14 @@ VNUM2=${VERSION_BITS[1]}
VNUM3=${VERSION_BITS[2]}
if [[ $release == 'major' ]]; then
VNUM1=$((VNUM1 + 1))
VNUM2=0
VNUM3=0
VNUM1=$((VNUM1 + 1))
VNUM2=0
VNUM3=0
elif [[ $release == 'minor' ]]; then
VNUM2=$((VNUM2 + 1))
VNUM3=0
VNUM2=$((VNUM2 + 1))
VNUM3=0
else
VNUM3=$((VNUM3 + 1))
VNUM3=$((VNUM3 + 1))
fi
#create new tag
RELEASE_TAG="v$VNUM1.$VNUM2.$VNUM3"
@@ -94,11 +94,11 @@ set -x
echo "Waiting for new tags to be released from 'create-releases.yml'"
while true; do
git pull --autostash --no-edit --gpg-sign --ff origin main
if git ls-remote -t --exit-code origin "refs/tags/${RELEASE_TAG}" &> /dev/null; then
break
fi
sleep 10
git pull --autostash --no-edit --gpg-sign --ff origin main
if git ls-remote -t --exit-code origin "refs/tags/${RELEASE_TAG}" &> /dev/null; then
break
fi
sleep 10
done
sleep 5