diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2c8afa..c59eed3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,10 @@ on: permissions: contents: write +concurrency: + group: release-${{ github.event.inputs.tag || github.ref_name }} + cancel-in-progress: true + env: DIST_DIR: dist @@ -340,7 +344,7 @@ jobs: rm -f /tmp/release_id.txt # If release already exists (e.g. Gitea auto-created it from tag push), - # find it and PATCH to update title + note + # find it by tag if [ -z "${RELEASE_ID}" ] && [ "${HOST}" != "github.com" ]; then echo ">>> Релиз не создан (возможно уже существует), ищем по тегу ${TAG}..." RELEASE_JSON=$(curl -sS \ @@ -351,22 +355,6 @@ jobs: RELEASE_ID=$(cat /tmp/release_id.txt) fi rm -f /tmp/release_id.txt - - # Update existing release with our generated title and note - if [ -n "${RELEASE_ID}" ]; then - echo ">>> Обновление существующего релиза (ID: ${RELEASE_ID}) — title + note..." - if [ "${HOST}" = "github.com" ]; then - PATCH_PAYLOAD="{\"name\":\"${RELEASE_TITLE}\",\"body\":${BODY_JSON}}" - else - PATCH_PAYLOAD="{\"title\":\"${RELEASE_TITLE}\",\"note\":${BODY_JSON}}" - fi - PATCH_RESP=$(curl -sS -X PATCH \ - -H "${AUTH_HEADER}" \ - -H "Content-Type: application/json" \ - "${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}" \ - -d "${PATCH_PAYLOAD}") - echo ">>> Релиз обновлён" - fi fi if [ -z "${RELEASE_ID}" ]; then @@ -375,6 +363,24 @@ jobs: exit 1 fi + # Always PATCH the release to guarantee title + note are set + # (handles race condition when parallel run creates empty release) + echo ">>> Обновление релиза (ID: ${RELEASE_ID}) — title + note..." + if [ "${HOST}" = "github.com" ]; then + PATCH_PAYLOAD="{\"name\":\"${RELEASE_TITLE}\",\"body\":${BODY_JSON}}" + PATCH_URL="https://api.github.com/repos/${REPO}/releases/${RELEASE_ID}" + else + PATCH_PAYLOAD="{\"title\":\"${RELEASE_TITLE}\",\"note\":${BODY_JSON}}" + PATCH_URL="${SERVER}/api/v1/repos/${REPO}/releases/${RELEASE_ID}" + fi + PATCH_RESP=$(curl -sS -X PATCH \ + -H "${AUTH_HEADER}" \ + -H "Content-Type: application/json" \ + "${EXTRA_HEADERS[@]}" \ + "${PATCH_URL}" \ + -d "${PATCH_PAYLOAD}") + echo ">>> Релиз обновлён" + if [ "${HOST}" = "github.com" ]; then UPLOAD_BASE=$(printf '%s' "${RELEASE_JSON}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('upload_url','').split('{')[0])") RELEASE_URL="https://github.com/${REPO}/releases/tag/${TAG}"