added site deployment building and packaging

This commit is contained in:
2025-03-25 19:20:48 -04:00
parent 629d4501af
commit 96c2445a84
41 changed files with 141 additions and 8 deletions

8
.gitignore vendored
View File

@ -1,8 +1,2 @@
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# OS directories
.DS_Store
/build/

130
site Executable file
View File

@ -0,0 +1,130 @@
#!/bin/bash
# Colors for that visual bass drop 🎵
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
MAGENTA='\033[35m'
CYAN='\033[36m'
RESET='\033[0m'
# Configuration
BUILD_DIRECTORY="build"
WEB_DIRECTORY="web"
GITEA_API_URL="https://gitea.thoughtpatterns.ai/api"
GITEA_ORGANIZATION="agreego"
GITEA_REPO="site"
env() {
# Check if GITEA_TOKEN is set
if [ -z "$GITEA_TOKEN" ]; then
# If not set, try to get it from kubectl
GITEA_TOKEN=$(kubectl get secret -n cellular gitea-git -o jsonpath='{.data.token}' | base64 --decode)
if [ -z "$GITEA_TOKEN" ]; then
echo -e "❌ ${RED}GITEA_TOKEN is not set and couldn't be retrieved from kubectl${RESET}" >&2
exit 1
fi
export GITEA_TOKEN
fi
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
# Just show current version
echo -e "📊 ${CYAN}Current version: ${GREEN}v$current_version${RESET}"
return 0
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)
# Create build directory
mkdir -p "$BUILD_DIRECTORY"
echo -e "📦 ${CYAN}Building site version ${GREEN}v$version${RESET}..."
# Create the tarball
tar -czf "$BUILD_DIRECTORY/site.tar.gz" -C "$WEB_DIRECTORY" .
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
env) env;;
build) env; site-build;;
package) env; site-package;;
*)
echo "Usage: $0 {env|build|package}"
exit 1;;
esac

1
version Normal file
View File

@ -0,0 +1 @@
1.0.1

8
web/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# OS directories
.DS_Store

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 169 KiB

View File

Before

Width:  |  Height:  |  Size: 708 KiB

After

Width:  |  Height:  |  Size: 708 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 201 KiB

View File

Before

Width:  |  Height:  |  Size: 430 KiB

After

Width:  |  Height:  |  Size: 430 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View File

Before

Width:  |  Height:  |  Size: 519 KiB

After

Width:  |  Height:  |  Size: 519 KiB

View File

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View File

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 307 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 288 KiB

After

Width:  |  Height:  |  Size: 288 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

Before

Width:  |  Height:  |  Size: 457 KiB

After

Width:  |  Height:  |  Size: 457 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 309 B

View File

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 193 KiB

View File

Before

Width:  |  Height:  |  Size: 544 KiB

After

Width:  |  Height:  |  Size: 544 KiB

View File

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 421 B

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File