fix(ci): replace release-action with direct Gitea API calls
The gitea.com/actions/release-action is archived and requires go to build from source, which isn't available in the ubuntu-latest runner. Replace with curl calls to the Gitea release API: create release, upload assets. Handles existing releases by deleting and recreating.
This commit is contained in:
@@ -315,22 +315,66 @@ jobs:
|
|||||||
ls -lah release/
|
ls -lah release/
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
uses: https://gitea.com/actions/release-action@main
|
env:
|
||||||
with:
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
files: release/*
|
GITEA_URL: ${{ github.server_url }}
|
||||||
title: "Kindred Create ${{ env.BUILD_TAG }}"
|
REPO: ${{ github.repository }}
|
||||||
body: |
|
run: |
|
||||||
## Kindred Create ${{ env.BUILD_TAG }}
|
TAG="${BUILD_TAG}"
|
||||||
|
PRERELEASE=false
|
||||||
|
if echo "$TAG" | grep -qE '(rc|beta|alpha)'; then
|
||||||
|
PRERELEASE=true
|
||||||
|
fi
|
||||||
|
|
||||||
### Downloads
|
BODY="## Kindred Create ${TAG}
|
||||||
|
|
||||||
| Platform | File |
|
### Downloads
|
||||||
|----------|------|
|
|
||||||
| Linux (AppImage) | `KindredCreate-*-Linux-x86_64.AppImage` |
|
|
||||||
| Linux (Debian/Ubuntu) | `kindred-create_*.deb` |
|
|
||||||
|
|
||||||
*macOS and Windows builds are not yet available.*
|
| Platform | File |
|
||||||
|
|----------|------|
|
||||||
|
| Linux (AppImage) | \`KindredCreate-*-Linux-x86_64.AppImage\` |
|
||||||
|
| Linux (Debian/Ubuntu) | \`kindred-create_*.deb\` |
|
||||||
|
|
||||||
SHA256 checksums are provided alongside each artifact.
|
*macOS and Windows builds are not yet available.*
|
||||||
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
|
|
||||||
api_key: ${{ secrets.RELEASE_TOKEN }}
|
SHA256 checksums are provided alongside each artifact."
|
||||||
|
|
||||||
|
# Delete existing release for this tag (if any) so we can recreate
|
||||||
|
existing=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}")
|
||||||
|
if [ "$existing" = "200" ]; then
|
||||||
|
release_id=$(curl -s \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" | \
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
curl -s -X DELETE \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${release_id}"
|
||||||
|
echo "Deleted existing release ${release_id} for tag ${TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create release
|
||||||
|
release_id=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$(python3 -c "import json; print(json.dumps({
|
||||||
|
'tag_name': '${TAG}',
|
||||||
|
'name': 'Kindred Create ${TAG}',
|
||||||
|
'body': '''${BODY}''',
|
||||||
|
'prerelease': ${PRERELEASE}
|
||||||
|
}))")" \
|
||||||
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases" | \
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
echo "Created release ${release_id}"
|
||||||
|
|
||||||
|
# Upload assets
|
||||||
|
for file in release/*; do
|
||||||
|
filename=$(basename "$file")
|
||||||
|
echo "Uploading ${filename}..."
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-F "attachment=@${file}" \
|
||||||
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${release_id}/assets?name=${filename}"
|
||||||
|
echo " done."
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user