Holy shit this might have worked
All checks were successful
release / build (push) Successful in 3m25s
All checks were successful
release / build (push) Successful in 3m25s
This commit is contained in:
parent
3e47fd18f2
commit
a7d0645d27
2 changed files with 11 additions and 24 deletions
|
|
@ -1,16 +1,9 @@
|
|||
name: release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag name for release (creates tag at HEAD)'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -46,35 +39,29 @@ jobs:
|
|||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
run: |
|
||||
echo "Token present: ${FORGEJO_TOKEN:+yes}"
|
||||
echo "Token length: ${#FORGEJO_TOKEN}"
|
||||
|
||||
TAG="${{ github.event.inputs.tag || github.ref_name }}"
|
||||
TAG="${{ github.ref_name }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
echo "Looking for release: ${API_BASE}/repos/${REPO}/releases/tags/${TAG}"
|
||||
RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}" 2>/dev/null || echo '{}')
|
||||
echo "Lookup response: ${RESPONSE}"
|
||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
|
||||
# check if release exists
|
||||
RELEASE_ID=$(curl -sf \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id // empty')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Creating release for ${TAG}..."
|
||||
RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \
|
||||
--header="Content-Type: application/json" \
|
||||
--post-data='{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \
|
||||
"${API_BASE}/repos/${REPO}/releases" 2>&1)
|
||||
echo "Create response: ${RESPONSE}"
|
||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
||||
RELEASE_ID=$(curl -sf \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"tag_name":"'"${TAG}"'","name":"'"${TAG}"'"}' \
|
||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
||||
fi
|
||||
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
|
||||
# upload assets (still need curl for multipart)
|
||||
for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do
|
||||
echo "Uploading $file..."
|
||||
curl -sf -X POST \
|
||||
curl -sf \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-F "attachment=@${file}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}"
|
||||
Loading…
Reference in a new issue