Holy shit this might have worked
All checks were successful
release / build (push) Successful in 3m25s

This commit is contained in:
Jared Miller 2025-12-20 12:41:24 -05:00
parent 3e47fd18f2
commit a7d0645d27
No known key found for this signature in database
2 changed files with 11 additions and 24 deletions

View file

@ -1,16 +1,9 @@
name: release name: release
on: on:
release:
types: [published]
push: push:
tags: tags:
- '*' - '*'
workflow_dispatch:
inputs:
tag:
description: 'Tag name for release (creates tag at HEAD)'
required: true
jobs: jobs:
build: build:
@ -46,35 +39,29 @@ jobs:
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: | run: |
echo "Token present: ${FORGEJO_TOKEN:+yes}" TAG="${{ github.ref_name }}"
echo "Token length: ${#FORGEJO_TOKEN}"
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 }}"
echo "Looking for release: ${API_BASE}/repos/${REPO}/releases/tags/${TAG}" # check if release exists
RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \ RELEASE_ID=$(curl -sf \
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}" 2>/dev/null || echo '{}') -H "Authorization: token ${FORGEJO_TOKEN}" \
echo "Lookup response: ${RESPONSE}" "${API_BASE}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id // empty')
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
if [ -z "$RELEASE_ID" ]; then if [ -z "$RELEASE_ID" ]; then
echo "Creating release for ${TAG}..." echo "Creating release for ${TAG}..."
RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \ RELEASE_ID=$(curl -sf \
--header="Content-Type: application/json" \ -H "Authorization: token ${FORGEJO_TOKEN}" \
--post-data='{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \ -H "Content-Type: application/json" \
"${API_BASE}/repos/${REPO}/releases" 2>&1) -d '{"tag_name":"'"${TAG}"'","name":"'"${TAG}"'"}' \
echo "Create response: ${RESPONSE}" "${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
fi fi
echo "Release ID: ${RELEASE_ID}" 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 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 \
-H "Authorization: token ${FORGEJO_TOKEN}" \ -H "Authorization: token ${FORGEJO_TOKEN}" \
-F "attachment=@${file}" \ -F "attachment=@${file}" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}" "${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}"