ci: replace forgejo-release action with direct API call to attach assets
ci / JVM build + tests (push) Failing after 1m20s
release / Publish KMP libraries → caffeine Nexus (release) Failing after 1m13s
release / Build runnable fatjars (release) Successful in 3m39s

forgejo-release@v1 calls 'tea release create' which errors with
'There already is a release for this tag' when the release is
pre-created (which release.yml needs because the trigger is
'release.published').

Workaround: do the upload ourselves via POST /api/v1/repos/.../releases/{id}/assets
with binary body. This is what forgejo-release ends up doing internally
after it successfully creates the release.
This commit is contained in:
SubochevAV
2026-09-16 22:20:37 +03:00
parent b27ac622b4
commit eed1ab9a17
+37 -9
View File
@@ -127,13 +127,41 @@ jobs:
if-no-files-found: error if-no-files-found: error
retention-days: 90 retention-days: 90
- name: Attach to release # Ассеты прикрепляются через прямой Gitea API-вызов: forgejo-release
uses: https://code.forgejo.org/actions/forgejo-release@v1 # action всегда пытается tea release create с теми же tag+title,
# что уже опубликованный релиз, и валится с
# "There already is a release for this tag".
#
# Тонкость: redirect-тело от PUT на /releases/{id}/assets для
# бинарной загрузки обычно пустое. Используем POST (по текущему
# контракту Gitea API для ассетов).
- name: Attach fatjars to release via API
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: shell: bash
direction: upload env:
url: ${{ github.server_url }} RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
repo: ${{ github.repository }} run: |
token: ${{ secrets.RELEASE_TOKEN }} TAG="$GITHUB_REF_NAME"
tag: ${{ github.ref_name }} # strip leading "v" if present (artifact filename doesn't include it)
release-dir: standalone/build/libs VERSION="${TAG#v}"
REL_ID=$(curl -sS -H "Authorization: token $RELEASE_TOKEN" \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/tags/$TAG" \
| jq -r .id)
echo "release id: $REL_ID tag: $TAG version: $VERSION"
for f in \
"standalone/build/libs/standalone-${VERSION}-all.jar" \
"agentik-cli/build/libs/agentik-cli-${VERSION}-all.jar" \
"agentik-tui/build/libs/agentik-tui-${VERSION}-all.jar"
do
if [ -f "$f" ]; then
fname=$(basename "$f")
curl -sS -X POST \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$f" \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases/$REL_ID/assets?name=$fname" \
-w " upload: $fname -> HTTP %{http_code}\n"
else
echo " skip missing: $f"
fi
done