- Fix twine execution to use 'uv run twine' instead of direct execution - Update twine installation check to use 'uv pip show' instead of 'command -v' - Ensure script is executable
69 lines
1.8 KiB
Bash
Executable File
69 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script to build and upload Python package to Gitea PyPI registry
|
|
# Usage: ./scripts/build_and_upload.sh
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "=== Building and Uploading Package to Gitea ==="
|
|
|
|
# Create scripts directory if it doesn't exist
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
# Check if we're in the right directory
|
|
if [[ ! -f "pyproject.toml" ]]; then
|
|
echo "Error: pyproject.toml not found. Please run this script from the project root."
|
|
exit 1
|
|
fi
|
|
|
|
# Install twine if not already installed
|
|
if ! uv pip show twine &> /dev/null; then
|
|
echo "Installing twine..."
|
|
uv pip install twine
|
|
fi
|
|
|
|
# Clean previous builds
|
|
echo "Cleaning previous builds..."
|
|
rm -rf dist/
|
|
|
|
# Build the package
|
|
echo "Building package..."
|
|
uv build
|
|
|
|
# Check if build was successful
|
|
if [[ ! -d "dist" ]] || [[ -z "$(ls -A dist)" ]]; then
|
|
echo "Error: Build failed or no files created in dist/"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Build successful. Files created:"
|
|
ls -la dist/
|
|
|
|
# Upload to Gitea PyPI registry
|
|
echo "Uploading to Gitea PyPI registry..."
|
|
echo "Note: You need to have ~/.pypirc configured with Gitea credentials"
|
|
echo "See: https://docs.gitea.com/usage/packages/pypi"
|
|
|
|
# Check if .pypirc exists
|
|
if [[ ! -f "$HOME/.pypirc" ]]; then
|
|
echo "Warning: ~/.pypirc not found. Please create it with your Gitea credentials:"
|
|
echo ""
|
|
echo "[distutils]"
|
|
echo "index-servers = gitea"
|
|
echo ""
|
|
echo "[gitea]"
|
|
echo "repository = https://gitea.parano.ch/api/packages/herel/pypi"
|
|
echo "username = herel"
|
|
echo "password = YOUR_GITEA_TOKEN"
|
|
echo ""
|
|
echo "Replace YOUR_GITEA_TOKEN with a personal access token from Gitea."
|
|
exit 1
|
|
fi
|
|
|
|
# Upload using twine via uv
|
|
uv run twine upload --repository gitea dist/*
|
|
|
|
echo "Package uploaded successfully to Gitea!"
|