2023-09-15 00:05:00 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-09-22 14:19:26 -07:00
|
|
|
set -eux
|
2023-09-15 00:05:00 -07:00
|
|
|
|
|
|
|
# Function to check if the current version is a non-dev version
|
|
|
|
function is_non_dev_version {
|
2023-12-18 23:48:21 -08:00
|
|
|
local VERSION="$1"
|
|
|
|
[[ "$VERSION" != *"-dev"* ]]
|
2023-09-15 00:05:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Function to get the version from the current main branch
|
|
|
|
function get_main_branch_version {
|
2023-12-18 23:48:21 -08:00
|
|
|
local VERSION
|
|
|
|
git fetch origin main
|
|
|
|
VERSION=$(git show origin/main:unstructured/__version__.py | grep -o -m 1 -E "(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[a-zA-Z0-9.-]+)?")
|
|
|
|
echo "$VERSION"
|
2023-09-15 00:05:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the current version from the file
|
|
|
|
CURRENT_VERSION=$(grep -o -m 1 -E "(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-dev[0-9]+)?" "unstructured/__version__.py")
|
|
|
|
|
|
|
|
# Check if the current version is a non-dev version and not matching the main version
|
|
|
|
if is_non_dev_version "$CURRENT_VERSION" && [ "$(get_main_branch_version)" != "$CURRENT_VERSION" ]; then
|
2023-12-18 23:48:21 -08:00
|
|
|
echo "New release version: $CURRENT_VERSION"
|
2023-09-15 00:05:00 -07:00
|
|
|
fi
|