This commit is contained in:
parent
bd3dbca0c7
commit
140d51f181
1 changed files with 17 additions and 5 deletions
|
|
@ -46,10 +46,20 @@ jobs:
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
echo "Token present: ${FORGEJO_TOKEN:+yes}"
|
||||||
|
echo "Token length: ${#FORGEJO_TOKEN}"
|
||||||
|
|
||||||
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
||||||
API_BASE="${{ github.server_url }}/api/v1"
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
REPO="${{ github.repository }}"
|
REPO="${{ github.repository }}"
|
||||||
|
|
||||||
|
# ensure tag exists (create at HEAD if not)
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\"}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/tags" || true
|
||||||
|
|
||||||
# get or create release
|
# get or create release
|
||||||
echo "Looking for release: ${API_BASE}/repos/${REPO}/releases/tags/${TAG}"
|
echo "Looking for release: ${API_BASE}/repos/${REPO}/releases/tags/${TAG}"
|
||||||
RESPONSE=$(curl -s -H "Authorization: token ${FORGEJO_TOKEN}" \
|
RESPONSE=$(curl -s -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
|
@ -59,13 +69,15 @@ jobs:
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||||
echo "Creating release for ${TAG}..."
|
echo "Creating release for ${TAG}..."
|
||||||
RESPONSE=$(curl -s -X POST \
|
JSON_PAYLOAD=$(printf '{"tag_name": "%s", "name": "%s"}' "$TAG" "$TAG")
|
||||||
|
echo "Payload: ${JSON_PAYLOAD}"
|
||||||
|
RESPONSE=$(curl -sv -X POST \
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\"}" \
|
-d "$JSON_PAYLOAD" \
|
||||||
"${API_BASE}/repos/${REPO}/releases")
|
"${API_BASE}/repos/${REPO}/releases" 2>&1)
|
||||||
echo "Create response: ${RESPONSE}"
|
echo "Full response: ${RESPONSE}"
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue