ci: replace forgejo-release action with direct API call to attach assets
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:
@@ -127,13 +127,41 @@ jobs:
|
||||
if-no-files-found: error
|
||||
retention-days: 90
|
||||
|
||||
- name: Attach to release
|
||||
uses: https://code.forgejo.org/actions/forgejo-release@v1
|
||||
# Ассеты прикрепляются через прямой Gitea API-вызов: forgejo-release
|
||||
# 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/')
|
||||
with:
|
||||
direction: upload
|
||||
url: ${{ github.server_url }}
|
||||
repo: ${{ github.repository }}
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
tag: ${{ github.ref_name }}
|
||||
release-dir: standalone/build/libs
|
||||
shell: bash
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
TAG="$GITHUB_REF_NAME"
|
||||
# strip leading "v" if present (artifact filename doesn't include it)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user