mirror of
https://github.com/bentoml/OpenLLM.git
synced 2026-03-09 10:39:45 -04:00
147 lines
3.5 KiB
Bash
Executable File
147 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e -o pipefail
|
|
|
|
# Function to print script usage
|
|
print_usage() {
|
|
echo "Usage: $0 [--release <major|minor|patch|alpha>]"
|
|
}
|
|
|
|
# Function to validate release argument
|
|
validate_release() {
|
|
local release=$1
|
|
|
|
if [[ $release == "major" || $release == "minor" || $release == "patch" || $release == "alpha" ]]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_membership() {
|
|
local org="BentoML"
|
|
local username=$(gh api user | jq -r '.login')
|
|
if gh api orgs/$org/members/$username -q '.message' | grep -q "Not Found"; then
|
|
echo "ERROR: You must be a member of $org to run this script."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
for cmd in gh jq hatch; do
|
|
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', 'patch', or 'alpha' are allowed."
|
|
print_usage
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Error: Unknown option or no option provided."
|
|
print_usage
|
|
exit 1
|
|
fi
|
|
|
|
# Get the current version and separate the alpha part if it exists
|
|
version="$(git describe --tags "$(git rev-list --tags --max-count=1)")"
|
|
VERSION="${version#v}"
|
|
|
|
# Initialize variables for alpha versioning
|
|
ALPHA=""
|
|
ALPHA_NUM=0
|
|
|
|
# Check if current version is an alpha version and split accordingly
|
|
if [[ $VERSION =~ -alpha ]]; then
|
|
IFS='-' read -r BASE_VERSION ALPHA <<< "$VERSION"
|
|
if [[ $ALPHA =~ [.] ]]; then
|
|
IFS='.' read -r ALPHA ALPHA_NUM <<< "$ALPHA"
|
|
fi
|
|
else
|
|
BASE_VERSION="$VERSION"
|
|
fi
|
|
|
|
# Save the current value of IFS to restore it later and split the base version
|
|
OLD_IFS=$IFS
|
|
IFS='.'
|
|
read -ra VERSION_BITS <<< "$BASE_VERSION"
|
|
IFS=$OLD_IFS
|
|
|
|
# Assign split version numbers
|
|
VNUM1=${VERSION_BITS[0]}
|
|
VNUM2=${VERSION_BITS[1]}
|
|
VNUM3=${VERSION_BITS[2]}
|
|
|
|
# Adjust the version numbers based on the release type
|
|
if [[ $release == 'major' ]]; then
|
|
VNUM1=$((VNUM1 + 1))
|
|
VNUM2=0
|
|
VNUM3=0
|
|
ALPHA="" # Reset alpha for major release
|
|
elif [[ $release == 'minor' ]]; then
|
|
VNUM2=$((VNUM2 + 1))
|
|
VNUM3=0
|
|
ALPHA="" # Reset alpha for minor release
|
|
elif [[ $release == 'patch' ]]; then
|
|
VNUM3=$((VNUM3 + 1))
|
|
ALPHA="" # Reset alpha for patch release
|
|
elif [[ $release == 'alpha' ]]; then
|
|
if [ -n "$ALPHA" ]; then
|
|
ALPHA_NUM=$((ALPHA_NUM + 1))
|
|
else
|
|
VNUM2=$((VNUM2 + 1))
|
|
VNUM3=0
|
|
ALPHA="alpha"
|
|
ALPHA_NUM=0
|
|
fi
|
|
fi
|
|
|
|
# Construct the new version string
|
|
if [ -n "$ALPHA" ]; then
|
|
if ((ALPHA_NUM > 0)); then
|
|
RELEASE_TAG="v$VNUM1.$VNUM2.$VNUM3-alpha.$ALPHA_NUM"
|
|
else
|
|
RELEASE_TAG="v$VNUM1.$VNUM2.$VNUM3-alpha"
|
|
fi
|
|
else
|
|
RELEASE_TAG="v$VNUM1.$VNUM2.$VNUM3"
|
|
fi
|
|
|
|
echo "Releasing version: $RELEASE_TAG"
|
|
|
|
echo "Running release actions (create-releases.yml)..."
|
|
echo '{"release_type": "'"$release"'"}' | gh workflow run create-releases.yml --repo bentoml/openllm --json
|
|
|
|
sleep 20
|
|
|
|
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
|
|
done
|
|
|
|
echo "Sleeping for 7 minutes to allow the release to propagate and PyPI to be published..."
|
|
sleep 420
|
|
echo "Building OpenLLM container for ${RELEASE_TAG}..."
|
|
gh workflow run build.yml -R bentoml/openllm -r "${RELEASE_TAG}"
|