diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 040df5a..06523ce 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -97,17 +97,32 @@ jobs: ASSET_NAME: ${{ steps.version.outputs.asset_name }} DESCRIPTION: ${{ inputs.description }} run: | - set -eu + nix-shell -p curl jq --run ' + set -eu - HTTP_STATUS=$(nix-shell -p curl --run "curl -s -w \"%{http_code}\" -o release_out.json -H \"Authorization: token $TOKEN\" \"$API/repos/$REPO/releases/tags/$TAG\"") + HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json \ + -H "Authorization: token $TOKEN" \ + "$API/repos/$REPO/releases/tags/$TAG") - if [ "$HTTP_STATUS" = "200" ]; then - echo "Release $TAG already exists." - RELEASE_ID="$(jq -r .id release_out.json)" - else - echo "Creating release for $TAG" - RELEASE_JSON="$(nix-shell -p curl --run "curl -f -sS -X POST \"$API/repos/$REPO/releases\" -H \"Authorization: token $TOKEN\" -H \"Content-Type: application/json\" -d \"$(jq -n --arg tag \"$TAG\" --arg name \"$TITLE\" --arg body \"$DESCRIPTION\" --arg target \"$SHA\" --argjson prerelease \"$PRERELEASE\" '{ tag_name: $tag, name: $name, body: $body, target_commitish: $target, draft: false, prerelease: $prerelease }')\"")" - RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)" - fi + if [ "$HTTP_STATUS" = "200" ]; then + echo "Release $TAG already exists." + RELEASE_ID="$(jq -r .id release_out.json)" + else + echo "Creating release for $TAG" + RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(jq -n \ + --arg tag "$TAG" \ + --arg name "$TITLE" \ + --arg body "$DESCRIPTION" \ + --arg target "$SHA" \ + --argjson prerelease "$PRERELEASE" \ + '"'"'{ tag_name: $tag, name: $name, body: $body, target_commitish: $target, draft: false, prerelease: $prerelease }'"'"')")" + RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)" + fi - nix-shell -p curl --run "curl -fsS -X POST \"$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$ASSET_NAME\" -H \"Authorization: token $TOKEN\" -F \"attachment=@$ASSET_PATH\"" + curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$ASSET_NAME" \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@$ASSET_PATH" + ' \ No newline at end of file