forked from colin/simple-glitchtip
61 lines
1.7 KiB
Bash
Executable File
61 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit on any error
|
|
set -e
|
|
|
|
# Ensure environment variables are set
|
|
if [[ -z "$REGISTRY_USER" || -z "$REGISTRY_PASSWORD" ]]; then
|
|
echo "Error: REGISTRY_USER and REGISTRY_PASSWORD must be set in the environment."
|
|
exit 1
|
|
fi
|
|
|
|
# Variables
|
|
ZIP_FILE="simple-glitchtip-c5.zip"
|
|
REGISTRY_URL="https://git.nixc.us/api/packages/nixius/composer"
|
|
|
|
# Ensure composer.json exists
|
|
if [[ ! -f "composer.json" ]]; then
|
|
echo "Error: composer.json not found in the current directory."
|
|
exit 1
|
|
fi
|
|
|
|
# Increment version in composer.json
|
|
echo "Incrementing version in composer.json..."
|
|
VERSION=$(jq -r '.version' composer.json)
|
|
if [[ $VERSION == "null" ]]; then
|
|
echo "Error: version is missing in composer.json."
|
|
exit 1
|
|
fi
|
|
|
|
# Extract version components
|
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
|
PATCH=$((PATCH + 1)) # Increment patch version
|
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
|
|
|
# Update composer.json with the new version
|
|
jq --arg version "$NEW_VERSION" '.version = $version' composer.json > composer.json.tmp && mv composer.json.tmp composer.json
|
|
echo "Updated version to $NEW_VERSION."
|
|
|
|
# Zip the current directory
|
|
echo "Creating zip file: $ZIP_FILE..."
|
|
zip -r "$ZIP_FILE" . >/dev/null
|
|
echo "Zip file created."
|
|
|
|
# Upload to Gitea registry
|
|
echo "Uploading $ZIP_FILE to $REGISTRY_URL..."
|
|
RESPONSE=$(curl --silent --write-out "%{http_code}" --output /dev/null \
|
|
--user "$REGISTRY_USER:$REGISTRY_PASSWORD" \
|
|
--upload-file "$ZIP_FILE" \
|
|
"$REGISTRY_URL")
|
|
|
|
if [[ $RESPONSE -eq 201 ]]; then
|
|
echo "Package successfully uploaded with version $NEW_VERSION."
|
|
else
|
|
echo "Error: Failed to upload package. HTTP response code: $RESPONSE."
|
|
exit 1
|
|
fi
|
|
|
|
# Cleanup
|
|
rm -f "$ZIP_FILE"
|
|
echo "Cleanup complete. Done!"
|