This commit is contained in:
parent
e4115f101c
commit
8ad189f9a3
1 changed files with 10 additions and 20 deletions
|
|
@ -50,38 +50,28 @@ jobs:
|
||||||
echo "Token length: ${#FORGEJO_TOKEN}"
|
echo "Token length: ${#FORGEJO_TOKEN}"
|
||||||
|
|
||||||
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
||||||
# use internal docker network URL instead of external
|
API_BASE="${{ github.server_url }}/api/v1"
|
||||||
API_BASE="http://forgejo:3000/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
|
|
||||||
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=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}" 2>/dev/null || echo '{}')
|
||||||
echo "Lookup response: ${RESPONSE}"
|
echo "Lookup response: ${RESPONSE}"
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
echo "Creating release for ${TAG}..."
|
echo "Creating release for ${TAG}..."
|
||||||
RESPONSE=$(curl -s -X POST \
|
RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
--header="Content-Type: application/json" \
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
--post-data='{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \
|
||||||
-d '{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \
|
"${API_BASE}/repos/${REPO}/releases" 2>&1)
|
||||||
"${API_BASE}/repos/${REPO}/releases")
|
|
||||||
echo "Create response: ${RESPONSE}"
|
echo "Create response: ${RESPONSE}"
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
|
||||||
# upload assets
|
# upload assets (still need curl for multipart)
|
||||||
for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do
|
for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do
|
||||||
echo "Uploading $file..."
|
echo "Uploading $file..."
|
||||||
curl -sf -X POST \
|
curl -sf -X POST \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue