Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c5f2c3322c | |||
| 56ad0824c7 | |||
| ec65df2976 |
@@ -112,66 +112,47 @@ jobs:
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
|
||||
echo "Creating Gitea release for ${TAG}..."
|
||||
echo "Debug: GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
|
||||
echo "Debug: TAG=${TAG}"
|
||||
|
||||
# Use jq to build valid JSON with proper escaping
|
||||
BODY="Download binaries for your platform: Linux (amd64, arm64), macOS (Intel, Apple Silicon), FreeBSD (amd64)"
|
||||
# Simple body without special characters
|
||||
BODY="Download binaries for your platform"
|
||||
|
||||
JSON_PAYLOAD=$(jq -n \
|
||||
--arg tag "$TAG" \
|
||||
--arg name "$TAG" \
|
||||
--arg body "$BODY" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')
|
||||
|
||||
# Create release via API
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
# Create release via API with simple inline JSON
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" \
|
||||
-d '{"tag_name":"'"${TAG}"'","name":"'"${TAG}"'","body":"'"${BODY}"'","draft":false,"prerelease":false}' \
|
||||
"https://git.uuxo.net/api/v1/repos/${GITHUB_REPOSITORY}/releases")
|
||||
|
||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
|
||||
BODY_RESPONSE=$(echo "$RESPONSE" | sed '$d')
|
||||
|
||||
echo "HTTP Code: $HTTP_CODE"
|
||||
echo "Response: $BODY_RESPONSE"
|
||||
|
||||
RELEASE_ID=$(echo "$BODY_RESPONSE" | jq -r '.id')
|
||||
|
||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||
echo "Failed to create release. Response:"
|
||||
echo "$RESPONSE"
|
||||
echo "Failed to create release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Created release ID: $RELEASE_ID"
|
||||
|
||||
# Upload each binary
|
||||
echo "Files to upload:"
|
||||
ls -la release/
|
||||
|
||||
for file in release/dbbackup-*; do
|
||||
FILENAME=$(basename "$file")
|
||||
echo "Uploading $FILENAME..."
|
||||
curl -s -X POST \
|
||||
UPLOAD_RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@${file}" \
|
||||
"https://git.uuxo.net/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||
"https://git.uuxo.net/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}")
|
||||
echo "Upload response: $UPLOAD_RESPONSE"
|
||||
done
|
||||
|
||||
echo "Gitea release complete!"
|
||||
|
||||
# Mirror to GitHub (optional - runs if GITHUB_MIRROR_TOKEN secret is set)
|
||||
mirror-to-github:
|
||||
name: Mirror to GitHub
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-and-release]
|
||||
if: startsWith(github.ref, 'refs/tags/') && vars.GITHUB_MIRROR_TOKEN != ''
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- name: Mirror to GitHub
|
||||
env:
|
||||
GITHUB_MIRROR_TOKEN: ${{ vars.GITHUB_MIRROR_TOKEN }}
|
||||
run: |
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
|
||||
echo "Mirroring ${TAG} to GitHub..."
|
||||
|
||||
# Clone from Gitea
|
||||
git clone --bare "https://git.uuxo.net/${GITHUB_REPOSITORY}.git" repo.git
|
||||
cd repo.git
|
||||
|
||||
# Push to GitHub
|
||||
git push --mirror "https://${GITHUB_MIRROR_TOKEN}@github.com/PlusOne/dbbackup.git" || echo "Mirror push failed (non-critical)"
|
||||
|
||||
echo "GitHub mirror complete!"
|
||||
Reference in New Issue
Block a user