Spaces:
Running
Running
set -e # Exit on any error | |
echo "Starting release process..." | |
# Execute build script | |
echo "Running build script..." | |
./build.sh | |
# Check if build was successful | |
if [ $? -ne 0 ]; then | |
echo "Error: Build failed, aborting release" | |
exit 1 | |
fi | |
echo "Build completed successfully, preparing git operations..." | |
# Add all new build artifacts | |
echo "Adding build artifacts to git..." | |
git add .output/ | |
git add .env 2>/dev/null || echo "No .env file to add" | |
git add .env.example 2>/dev/null || echo "No .env.example file to add" | |
# Check if there are any changes to commit | |
if git diff --staged --quiet; then | |
echo "No changes to commit, release process completed" | |
exit 0 | |
fi | |
# Get current timestamp for commit message | |
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') | |
# Commit changes | |
echo "Committing changes..." | |
git commit -m "chore: update build artifacts - $TIMESTAMP" | |
# Push changes | |
echo "Pushing changes to remote..." | |
git push | |
# Get git remote URL and generate HF Space short link | |
echo "Generating Hugging Face Space link..." | |
GIT_URL=$(git remote get-url origin) | |
echo "Git remote URL: $GIT_URL" | |
# Extract repo path from HF Space URL and generate short link | |
if [[ $GIT_URL == *"huggingface.co"* ]]; then | |
# Extract the repo path (remove .git suffix if present) | |
REPO_PATH=$(echo "$GIT_URL" | sed -E 's|.*huggingface\.co/spaces/([^/]+/[^/]+)(\.git)?.*|\1|') | |
HF_SHORT_LINK="https://hf.co/spaces/$REPO_PATH" | |
echo "π Hugging Face Space: $HF_SHORT_LINK" | |
else | |
echo "Note: This doesn't appear to be a Hugging Face Space repository" | |
fi | |
echo "Release completed successfully!" | |
echo "Build artifacts have been committed and pushed to remote repository" |