Release workflow: release on any run, fail loudly
Build and Release / build (push) Failing after 16s

This commit is contained in:
dasemu committed 2026-11-26 00:06:54 +01:00
1 parent 9fcbc820ad
commit 205e2ad8a2
1 file changed
+17 -5
+17 -5
View File
@@ -2,6 +2,8 @@ name: Build and Release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
@@ -36,16 +38,26 @@ jobs:
ls -la dist-release
- name: Create release and upload assets
if: startsWith(github.ref, 'refs/tags/')
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
set -eu
[ -n "${TOKEN}" ] || { echo "ERROR: secret RELEASE_TOKEN is empty or not defined"; exit 1; }
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
TAG="${GITHUB_REF_NAME}"
RELEASE_ID=$(curl -sf -X POST "$API/releases" \
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
TAG="${GITHUB_REF_NAME}"
else
TAG="build-${GITHUB_RUN_NUMBER}"
fi
echo "Creating release ${TAG} on ${API}"
curl -sS --fail-with-body -X POST "$API/releases" \
-H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\"}" | sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\"}" \
-o release.json
RELEASE_ID=$(sed -n 's/.*"id":\([0-9]*\).*/\1/p' release.json | head -1)
echo "Release id: ${RELEASE_ID}"
for f in dist-release/*; do
curl -sf -X POST "$API/releases/${RELEASE_ID}/assets?name=$(basename "$f")" \
echo "Uploading $f"
curl -sS --fail-with-body -X POST "$API/releases/${RELEASE_ID}/assets?name=$(basename "$f")" \
-H "Authorization: token ${TOKEN}" -F "attachment=@${f}"
done