Auto-fix Gitea release timestamp via SSH after release creation (workaround for Gitea created_unix=0 bug)
This commit is contained in:
@@ -219,20 +219,27 @@ create_gitea_release() {
|
||||
token=$(cat "$HOME/.gitea_token" | tr -d '\n\r')
|
||||
local api_url="https://git.laantungir.net/api/v1/repos/laantungir/n_signer"
|
||||
|
||||
# Include created_at timestamp to work around Gitea bug where releases
|
||||
# created without a timestamp get epoch zero and don't appear in the
|
||||
# releases list or web UI.
|
||||
local now_iso
|
||||
now_iso=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
local response
|
||||
response=$(curl -s -X POST "$api_url/releases" \
|
||||
-H "Authorization: token $token" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"$NEW_VERSION\", \"target_commitish\": \"master\", \"name\": \"$NEW_VERSION\", \"body\": \"$COMMIT_MESSAGE\", \"draft\": false, \"prerelease\": false, \"created_at\": \"$now_iso\"}")
|
||||
-d "{\"tag_name\": \"$NEW_VERSION\", \"target_commitish\": \"master\", \"name\": \"$NEW_VERSION\", \"body\": \"$COMMIT_MESSAGE\", \"draft\": false, \"prerelease\": false}")
|
||||
|
||||
if echo "$response" | grep -q '"id"'; then
|
||||
echo "$response" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2
|
||||
local release_id
|
||||
release_id=$(echo "$response" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
|
||||
|
||||
# Work around Gitea bug: releases created via API get created_unix=0
|
||||
# (epoch zero) in the database, causing them to not appear in the
|
||||
# releases list or web UI. Fix the timestamp directly in the DB.
|
||||
local now_unix
|
||||
now_unix=$(date +%s)
|
||||
print_status "Fixing release timestamp in Gitea database (workaround for Gitea bug)..."
|
||||
ssh -o ConnectTimeout=10 ubuntu@laantungir.net \
|
||||
"sudo sqlite3 /data/gitea/gitea.db \"UPDATE release SET created_unix=$now_unix WHERE id=$release_id;\"" \
|
||||
2>/dev/null || print_warning "Could not fix release timestamp via SSH (release may not appear in web UI)"
|
||||
|
||||
echo "$release_id"
|
||||
else
|
||||
print_error "Failed to create Gitea release: $response"
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user