This commit is contained in:
@@ -48,11 +48,36 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Publish Gitea Release
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
api_key: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ steps.tag.outputs.name }}
|
||||
title: ${{ steps.tag.outputs.name }}
|
||||
files: |-
|
||||
release/app.mjs
|
||||
release/install.sh
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ steps.tag.outputs.name }}
|
||||
run: |
|
||||
set -eu
|
||||
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases"
|
||||
parse_id='let d="";process.stdin.on("data",c=>d+=c).on("end",()=>{try{process.stdout.write(String(JSON.parse(d).id||""))}catch(e){}})'
|
||||
|
||||
rid=$(curl -sS -X POST "$API" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
|
||||
| node -e "$parse_id")
|
||||
|
||||
if [ -z "$rid" ]; then
|
||||
echo "release may already exist, fetching by tag $TAG"
|
||||
rid=$(curl -sS "$API/tags/$TAG" -H "Authorization: token $TOKEN" | node -e "$parse_id")
|
||||
fi
|
||||
|
||||
if [ -z "$rid" ]; then
|
||||
echo "failed to create or find release for $TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "release id=$rid"
|
||||
|
||||
for f in release/app.mjs release/install.sh; do
|
||||
name=$(basename "$f")
|
||||
echo "uploading $name"
|
||||
curl -sS -X POST "$API/$rid/assets?name=$name" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$f" \
|
||||
-o /dev/null -w " -> HTTP %{http_code}\n"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user