From 2a1ce80d06ff11791b21ee00a642b6178b6866ff Mon Sep 17 00:00:00 2001 From: niklascfw Date: Thu, 5 Mar 2026 19:26:12 +0100 Subject: [PATCH] Updated CI --- .github/workflows/sync-release.yml | 44 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/sync-release.yml b/.github/workflows/sync-release.yml index cbf6529..e3122bc 100644 --- a/.github/workflows/sync-release.yml +++ b/.github/workflows/sync-release.yml @@ -25,26 +25,25 @@ jobs: echo "tag=$TAG" >> "$GITHUB_OUTPUT" - # name defaults to tag when upstream leaves it empty if [ -z "$NAME" ]; then echo "name=$TAG" >> "$GITHUB_OUTPUT" else echo "name=$NAME" >> "$GITHUB_OUTPUT" fi - # body via file to preserve newlines echo "$BODY" > /tmp/release_body.md - # collect asset download URLs echo "$RELEASE" | jq -r '.assets[].browser_download_url' > /tmp/asset_urls.txt - name: Check if release already exists id: check - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TAG="${{ steps.upstream.outputs.tag }}" - if gh release view "$TAG" >/dev/null 2>&1; then + API_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${TAG}" + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "$API_URL") + if [ "$HTTP_CODE" = "200" ]; then echo "exists=true" >> "$GITHUB_OUTPUT" else echo "exists=false" >> "$GITHUB_OUTPUT" @@ -61,18 +60,33 @@ jobs: - name: Create release with assets if: steps.check.outputs.exists == 'false' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TAG="${{ steps.upstream.outputs.tag }}" NAME="${{ steps.upstream.outputs.name }}" + BODY=$(cat /tmp/release_body.md) + API_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" + + RESPONSE=$(curl -sf \ + -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "$(jq -n --arg tag "$TAG" --arg name "$NAME" --arg body "$BODY" \ + '{tag_name: $tag, name: $name, body: $body}')" \ + "$API_URL") + + RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') + echo "Created release $RELEASE_ID" + + UPLOAD_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" - ASSET_ARGS="" for f in /tmp/assets/*; do - ASSET_ARGS="$ASSET_ARGS $f" + FILENAME=$(basename "$f") + echo "Uploading $FILENAME" + curl -sf \ + -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary "@$f" \ + "${UPLOAD_URL}?name=${FILENAME}" + echo " -> done" done - - gh release create "$TAG" \ - --title "$NAME" \ - --notes-file /tmp/release_body.md \ - $ASSET_ARGS