revamp release uploads
This commit is contained in:
@@ -45,16 +45,32 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- pdf=$(ls *.pdf | head -n1)
|
- pdf=$(ls *.pdf | head -n1)
|
||||||
- tag=$(date +%F)
|
- tag=$(date +%F)
|
||||||
# Create the release (ignore error if it already exists)
|
|
||||||
- |
|
- |
|
||||||
curl -s -o /dev/null -w "%{http_code}" -X POST \
|
echo "Creating release for tag $tag..."
|
||||||
|
create_resp=$(curl -s -w "%{http_code}" -o /tmp/create.json -X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\": \"$tag\", \"name\": \"$tag\", \"draft\": false, \"prerelease\": false}" \
|
-d "{\"tag_name\":\"$tag\",\"name\":\"$tag\"}" \
|
||||||
https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases || true
|
https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases)
|
||||||
# Upload the PDF as a release asset
|
echo "Create release HTTP status: $create_resp"
|
||||||
- |
|
echo "Fetching release ID..."
|
||||||
curl -X POST \
|
release_id=$(curl -s \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases/tags/$tag |
|
||||||
|
awk -F: '/"id"[ ]*:/ {gsub(/[^0-9]/,"",$2); print $2; exit}')
|
||||||
|
echo "Release ID = $release_id"
|
||||||
|
echo "Checking if asset $pdf already exists..."
|
||||||
|
assets=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases/$release_id/assets)
|
||||||
|
echo "Assets response: $assets"
|
||||||
|
if echo "$assets" | grep -q "\"name\":\"$pdf\""; then
|
||||||
|
echo "Asset $pdf already uploaded, skipping."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Uploading $pdf to release $release_id..."
|
||||||
|
upload_resp=$(curl -s -w "%{http_code}" -o /tmp/upload.json -X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-F "attachment=@$pdf" \
|
-F "attachment=@$pdf" \
|
||||||
"https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases/$tag/assets"
|
https://git.keligrubb.com/api/v1/repos/keligrubb/scrollsmith/releases/$release_id/assets)
|
||||||
|
echo "Upload HTTP status: $upload_resp"
|
||||||
|
echo "Upload response: $(cat /tmp/upload.json)"
|
||||||
|
|||||||
Reference in New Issue
Block a user