v7.0.0 - Version 1.0.0
This commit is contained in:
BIN
c-relay-7.0.0.tar.gz
Normal file
BIN
c-relay-7.0.0.tar.gz
Normal file
Binary file not shown.
@@ -8,10 +8,10 @@ YELLOW='\033[1;33m'
|
|||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
print_status() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
print_status() { echo -e "${BLUE}[INFO]${NC} $1" >&2; }
|
||||||
print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" >&2; }
|
||||||
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" >&2; }
|
||||||
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
print_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
COMMIT_MESSAGE=""
|
COMMIT_MESSAGE=""
|
||||||
@@ -366,24 +366,39 @@ upload_release_assets() {
|
|||||||
|
|
||||||
local token=$(cat "$HOME/.gitea_token" | tr -d '\n\r')
|
local token=$(cat "$HOME/.gitea_token" | tr -d '\n\r')
|
||||||
local api_url="https://git.laantungir.net/api/v1/repos/laantungir/c-relay"
|
local api_url="https://git.laantungir.net/api/v1/repos/laantungir/c-relay"
|
||||||
|
local assets_url="$api_url/releases/$release_id/assets"
|
||||||
|
print_status "Assets URL: $assets_url"
|
||||||
|
|
||||||
# Upload binary
|
# Upload binary
|
||||||
if [[ -f "$binary_path" ]]; then
|
if [[ -f "$binary_path" ]]; then
|
||||||
print_status "Uploading binary: $(basename "$binary_path")"
|
print_status "Uploading binary: $(basename "$binary_path")"
|
||||||
print_status "Debug: API URL: $api_url/releases/$release_id/assets"
|
|
||||||
print_status "Debug: Binary path: $binary_path"
|
# Retry loop for eventual consistency
|
||||||
print_status "Debug: Binary exists: $(ls -la "$binary_path" 2>/dev/null || echo "NOT FOUND")"
|
local max_attempts=3
|
||||||
local binary_response=$(curl -v -X POST "$api_url/releases/$release_id/assets" \
|
local attempt=1
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
print_status "Upload attempt $attempt/$max_attempts"
|
||||||
|
local binary_response=$(curl -fS -X POST "$assets_url" \
|
||||||
-H "Authorization: token $token" \
|
-H "Authorization: token $token" \
|
||||||
-F "attachment=@$binary_path;filename=$(basename "$binary_path")" 2>&1)
|
-F "attachment=@$binary_path;filename=$(basename "$binary_path")" \
|
||||||
|
-F "name=$(basename "$binary_path")")
|
||||||
|
|
||||||
if echo "$binary_response" | grep -q '"id"'; then
|
if echo "$binary_response" | grep -q '"id"'; then
|
||||||
print_success "Uploaded binary successfully"
|
print_success "Uploaded binary successfully"
|
||||||
|
break
|
||||||
else
|
else
|
||||||
print_warning "Failed to upload binary"
|
print_warning "Upload attempt $attempt failed"
|
||||||
print_warning "Response: $binary_response"
|
if [[ $attempt -lt $max_attempts ]]; then
|
||||||
|
print_status "Retrying in 2 seconds..."
|
||||||
|
sleep 2
|
||||||
|
else
|
||||||
|
print_error "Failed to upload binary after $max_attempts attempts"
|
||||||
|
print_error "Response: $binary_response"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
((attempt++))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Upload source tarball
|
# Upload source tarball
|
||||||
if [[ -f "$tarball_path" ]]; then
|
if [[ -f "$tarball_path" ]]; then
|
||||||
@@ -434,8 +449,10 @@ create_gitea_release() {
|
|||||||
local release_id=$(echo "$check_response" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
local release_id=$(echo "$check_response" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||||
print_status "Using existing release ID: $release_id"
|
print_status "Using existing release ID: $release_id"
|
||||||
echo $release_id
|
echo $release_id
|
||||||
|
else
|
||||||
|
print_error "Could not find existing release ID"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
echo 0
|
|
||||||
else
|
else
|
||||||
print_error "Failed to create release $NEW_VERSION"
|
print_error "Failed to create release $NEW_VERSION"
|
||||||
print_error "Response: $response"
|
print_error "Response: $response"
|
||||||
@@ -449,7 +466,7 @@ create_gitea_release() {
|
|||||||
echo $release_id
|
echo $release_id
|
||||||
else
|
else
|
||||||
print_error "Release does not exist and creation failed"
|
print_error "Release does not exist and creation failed"
|
||||||
echo 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -510,12 +527,18 @@ main() {
|
|||||||
|
|
||||||
# Create Gitea release
|
# Create Gitea release
|
||||||
local release_id=""
|
local release_id=""
|
||||||
if release_id=$(create_gitea_release 2>&1); then
|
if release_id=$(create_gitea_release); then
|
||||||
|
# Validate release_id is numeric
|
||||||
|
if [[ "$release_id" =~ ^[0-9]+$ ]]; then
|
||||||
# Upload assets if we have a release ID and assets
|
# Upload assets if we have a release ID and assets
|
||||||
if [[ -n "$release_id" && (-n "$binary_path" || -n "$tarball_path") ]]; then
|
if [[ -n "$release_id" && (-n "$binary_path" || -n "$tarball_path") ]]; then
|
||||||
upload_release_assets "$release_id" "$binary_path" "$tarball_path"
|
upload_release_assets "$release_id" "$binary_path" "$tarball_path"
|
||||||
fi
|
fi
|
||||||
print_success "Release $NEW_VERSION completed successfully!"
|
print_success "Release $NEW_VERSION completed successfully!"
|
||||||
|
else
|
||||||
|
print_error "Invalid release_id: $release_id"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
print_error "Release creation failed"
|
print_error "Release creation failed"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user