|
|
@@ -81,21 +81,37 @@ jobs:
|
|
|
|
echo "Publishing release for $tag_name"
|
|
|
|
echo "Publishing release for $tag_name"
|
|
|
|
wheel_file=$(ls plugin/dist/*.whl | head -n 1)
|
|
|
|
wheel_file=$(ls plugin/dist/*.whl | head -n 1)
|
|
|
|
tar_file=$(ls plugin/dist/*.tar.gz | head -n 1)
|
|
|
|
tar_file=$(ls plugin/dist/*.tar.gz | head -n 1)
|
|
|
|
|
|
|
|
api_url="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
|
|
|
|
|
|
|
|
|
|
|
# Create release
|
|
|
|
# server_url is http and Gitea answers with a 308 redirect to https.
|
|
|
|
response=$(curl -s -k -X POST "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
|
|
|
|
# curl needs -L to follow, AND --location-trusted: without it curl
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
# drops the Authorization header on the scheme-changing redirect and
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
# Gitea replies "token is required". Release may already exist
|
|
|
|
-d "{\"tag_name\": \"$tag_name\", \"name\": \"$tag_name\", \"body\": \"Release $tag_name for hermes-meshtastic plugin\"}")
|
|
|
|
# (retried run) — reuse it instead of failing.
|
|
|
|
|
|
|
|
fetch_id() { python3 -c "import json,sys;print(json.load(sys.stdin).get('id') or '')" 2>/dev/null; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response=$(curl -s -k -L --location-trusted -H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
|
|
|
|
"$api_url/releases/tags/$tag_name")
|
|
|
|
|
|
|
|
release_id=$(printf '%s' "$response" | fetch_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$release_id" ]; then
|
|
|
|
|
|
|
|
response=$(curl -s -k -L --location-trusted -X POST "$api_url/releases" \
|
|
|
|
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
|
|
|
-d "{\"tag_name\": \"$tag_name\", \"name\": \"$tag_name\", \"body\": \"Release $tag_name for hermes-meshtastic plugin\"}")
|
|
|
|
|
|
|
|
release_id=$(printf '%s' "$response" | fetch_id)
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
release_id=$(echo "$response" | grep -o '"id":[0-9]*' | head -n 1 | cut -d: -f2)
|
|
|
|
|
|
|
|
if [ -n "$release_id" ]; then
|
|
|
|
if [ -n "$release_id" ]; then
|
|
|
|
curl -s -k -X POST "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $wheel_file)" \
|
|
|
|
curl -s -k -L --location-trusted -X POST "$api_url/releases/$release_id/assets?name=$(basename "$wheel_file")" \
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
-H "Content-Type: application/octet-stream" \
|
|
|
|
-H "Content-Type: application/octet-stream" \
|
|
|
|
--data-binary "@$wheel_file"
|
|
|
|
--data-binary "@$wheel_file"
|
|
|
|
curl -s -k -X POST "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $tar_file)" \
|
|
|
|
curl -s -k -L --location-trusted -X POST "$api_url/releases/$release_id/assets?name=$(basename "$tar_file")" \
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
|
|
-H "Content-Type: application/octet-stream" \
|
|
|
|
-H "Content-Type: application/octet-stream" \
|
|
|
|
--data-binary "@$tar_file"
|
|
|
|
--data-binary "@$tar_file"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "ERROR: could not create or fetch release $tag_name" >&2
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|