From 02fd35861185463a74d4915c034ed7992a8ee233 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Sat, 20 Dec 2025 12:47:54 -0500 Subject: [PATCH] Modify forgejo release to target our own runner --- .forgejo/workflows/release.yml | 40 ++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 5ac02ad..cda02ee 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -1,12 +1,14 @@ name: release on: - release: - types: [published] + push: + tags: + - '*' jobs: build: - runs-on: codeberg-small + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest steps: - uses: actions/checkout@v4 @@ -35,16 +37,32 @@ jobs: - name: Upload to release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} run: | - RELEASE_ID="${{ github.event.release.id }}" - API_URL="${{ github.api_url }}/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" + TAG="${{ github.ref_name }}" + API_BASE="${{ github.server_url }}/api/v1" + REPO="${{ github.repository }}" + + # 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}..." + 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}" for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do echo "Uploading $file..." - curl -X POST \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Content-Type: application/octet-stream" \ - --data-binary @"$file" \ - "${API_URL}?name=${file}" + curl -sf \ + -H "Authorization: token ${FORGEJO_TOKEN}" \ + -F "attachment=@${file}" \ + "${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${file}" done