same treatment for the site script
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
/build/
|
/package/
|
||||||
103
site
103
site
@ -11,10 +11,16 @@ RESET='\033[0m'
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
BUILD_DIRECTORY="build"
|
BUILD_DIRECTORY="build"
|
||||||
WEB_DIRECTORY="web"
|
|
||||||
GITEA_API_URL="https://gitea.thoughtpatterns.ai/api"
|
# Source the release script
|
||||||
GITEA_ORGANIZATION="agreego"
|
GITEA_ORGANIZATION="agreego"
|
||||||
GITEA_REPO="site"
|
GITEA_REPOSITORY="site"
|
||||||
|
RELEASE_SCRIPT="../../thoughtpatterns/workspace/release.sh"
|
||||||
|
if [ ! -f "$RELEASE_SCRIPT" ]; then
|
||||||
|
echo -e "❌ ${RED}Release script not found at $RELEASE_SCRIPT${RESET}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
source "$RELEASE_SCRIPT"
|
||||||
|
|
||||||
env() {
|
env() {
|
||||||
# Check if GITEA_TOKEN is set
|
# Check if GITEA_TOKEN is set
|
||||||
@ -31,100 +37,29 @@ env() {
|
|||||||
echo -e "💰 ${GREEN}Environment variables set${RESET}"
|
echo -e "💰 ${GREEN}Environment variables set${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get-version() {
|
|
||||||
grep -E '^[0-9]+\.[0-9]+\.[0-9]+' version
|
|
||||||
}
|
|
||||||
|
|
||||||
site-version() {
|
|
||||||
local current_version=$(get-version)
|
|
||||||
local new_version="$1"
|
|
||||||
local increment_type="$2"
|
|
||||||
|
|
||||||
if [ -z "$new_version" ] && [ -z "$increment_type" ]; then
|
build() {
|
||||||
# Just show current version
|
# Create build directory if it doesn't exist
|
||||||
echo -e "📊 ${CYAN}Current version: ${GREEN}v$current_version${RESET}"
|
mkdir -p "$PACKAGE_DIRECTORY"
|
||||||
return 0
|
# Get version
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$new_version" = "increment" ]; then
|
|
||||||
# Auto-increment based on type
|
|
||||||
local major minor patch
|
|
||||||
IFS='.' read -r major minor patch <<< "$current_version"
|
|
||||||
|
|
||||||
case "${increment_type:-patch}" in
|
|
||||||
major)
|
|
||||||
major=$((major + 1))
|
|
||||||
minor=0
|
|
||||||
patch=0
|
|
||||||
;;
|
|
||||||
minor)
|
|
||||||
minor=$((minor + 1))
|
|
||||||
patch=0
|
|
||||||
;;
|
|
||||||
patch|*)
|
|
||||||
patch=$((patch + 1))
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
new_version="$major.$minor.$patch"
|
|
||||||
echo -e "📈 ${CYAN}Auto-incrementing ${increment_type:-patch} version: ${GREEN}v$current_version${RESET} → ${GREEN}v$new_version${RESET}"
|
|
||||||
else
|
|
||||||
echo -e "📝 ${CYAN}Setting manual version: ${GREEN}v$current_version${RESET} → ${GREEN}v$new_version${RESET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update version in version file
|
|
||||||
echo "$new_version" > version
|
|
||||||
}
|
|
||||||
|
|
||||||
site-build() {
|
|
||||||
# Auto-increment patch version
|
|
||||||
site-version increment patch
|
|
||||||
# Get current version
|
|
||||||
local version=$(get-version)
|
local version=$(get-version)
|
||||||
# Create build directory
|
|
||||||
mkdir -p "$BUILD_DIRECTORY"
|
|
||||||
|
|
||||||
echo -e "📦 ${CYAN}Building site version ${GREEN}v$version${RESET}..."
|
echo -e "📦 ${CYAN}Building site version ${GREEN}v$version${RESET}..."
|
||||||
|
|
||||||
# Create the tarball
|
# Create the tarball
|
||||||
tar -czf "$BUILD_DIRECTORY/site.tar.gz" -C "$WEB_DIRECTORY" .
|
tar -czf "$PACKAGE_DIRECTORY/$GITEA_REPOSITORY.tar.gz" -C "$BUILD_DIRECTORY" .
|
||||||
|
|
||||||
echo -e "✨ ${GREEN}Build complete${RESET}"
|
echo -e "✨ ${GREEN}Build complete${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
site-package() {
|
|
||||||
# Ensure we have a build
|
|
||||||
if [ ! -f "$BUILD_DIRECTORY/site.tar.gz" ]; then
|
|
||||||
echo -e "❌ ${RED}No build found. Run 'site build' first${RESET}" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get current version
|
|
||||||
local version=$(get-version)
|
|
||||||
echo -e "📊 ${CYAN}Packaging version: ${GREEN}v$version${RESET}"
|
|
||||||
|
|
||||||
# Upload the site
|
|
||||||
echo -e "📦 ${CYAN}Uploading site.tar.gz...${RESET}"
|
|
||||||
if curl -X PUT \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
"$GITEA_API_URL/packages/$GITEA_ORGANIZATION/generic/$GITEA_REPO/$version/site.tar.gz" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
-T "$BUILD_DIRECTORY/site.tar.gz" \
|
|
||||||
-f > /dev/null; then
|
|
||||||
echo -e "✨ ${GREEN}Successfully uploaded site.tar.gz${RESET}"
|
|
||||||
else
|
|
||||||
echo -e "❌ ${RED}Failed to upload site.tar.gz${RESET}" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "🚀 ${GREEN}Site published to v$version${RESET}"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
env) env;;
|
env) env;;
|
||||||
build) env; site-build;;
|
build) env; build;;
|
||||||
package) env; site-package;;
|
tag) env; tag;;
|
||||||
|
package) env; package;;
|
||||||
|
release) env; release;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {env|build|package}"
|
echo "Usage: $0 {env|build|tag|package|release}"
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
Reference in New Issue
Block a user