diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 31e84fc..e4f8e0d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -32,26 +32,27 @@ jobs: chmod +x TinyWeb-linux-x64 ls -la TinyWeb-linux-x64 - - name: Create Release + - name: Get Release ID if: startsWith(github.ref, 'refs/tags/v') + id: release run: | TAG="${{ github.ref_name }}" REPO="${{ github.repository }}" TOKEN="${{ secrets.FORGEJO_TOKEN }}" - # Try to create release (ignore error if exists) - curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases" \ - -H "Authorization: token $TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}" || true + RELEASE_JSON=$(curl -s "https://git.derickphan.com/api/v1/repos/$REPO/releases/tags/$TAG" \ + -H "Authorization: token $TOKEN") + echo "$RELEASE_JSON" + RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id') + echo "release_id=$RELEASE_ID" >> $FORGEJO_OUTPUT - name: Upload to Release if: startsWith(github.ref, 'refs/tags/v') run: | FILE=TinyWeb-linux-x64 - TAG="${{ github.ref_name }}" + RELEASE_ID="${{ steps.release.outputs.release_id }}" REPO="${{ github.repository }}" TOKEN="${{ secrets.FORGEJO_TOKEN }}" - curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases/$TAG/assets" \ + curl -X POST "https://git.derickphan.com/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" \ -H "Authorization: token $TOKEN" \ -F "attachment=@$FILE"