Run builds in parallel, robust release handling
Build and Release / build-amd64 (push) Failing after 14m5s
Build and Release / build-arm64 (push) Failing after 14m5s

This commit is contained in:
marauder-actual
2026-06-12 18:06:40 +02:00
parent 4ad2743f8a
commit 364697210d
+56 -40
View File
@@ -19,16 +19,9 @@ jobs:
- name: Build .deb
run: make deb
- name: Publish to apt registry
run: |
DEB=$(ls build/*.deb)
echo "Publishing ${DEB}..."
curl --fail -H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
--upload-file "${DEB}" \
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
- name: Create release and attach
- name: Publish and release
run: |
set -e
TAG="${{ gitea.ref_name }}"
API="${{ gitea.server_url }}/api/v1"
REPO="${{ gitea.repository }}"
@@ -36,38 +29,47 @@ jobs:
DEB=$(ls build/*.deb)
FILENAME=$(basename "${DEB}")
# Delete existing release for this tag if any
# Publish to apt
echo "Publishing to apt..."
curl --fail -H "Authorization: token ${TOKEN}" \
--upload-file "${DEB}" \
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
echo "apt: done"
# Delete old release if exists
OLD_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id // empty')
if [ -n "${OLD_ID}" ] && [ "${OLD_ID}" != "null" ]; then
echo "Deleting existing release ${OLD_ID}..."
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end')
if [ -n "${OLD_ID}" ]; then
echo "Deleting old release ${OLD_ID}..."
curl -s -X DELETE -H "Authorization: token ${TOKEN}" \
"${API}/repos/${REPO}/releases/${OLD_ID}"
fi
# Create release
RELEASE_ID=$(curl -s -X POST \
echo "Creating release..."
RESP=$(curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
"${API}/repos/${REPO}/releases" | jq -r '.id')
"${API}/repos/${REPO}/releases")
RELEASE_ID=$(echo "${RESP}" | jq -r '.id')
echo "Release ID: ${RELEASE_ID}"
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
echo "ERROR: Failed to create release"
echo "ERROR: ${RESP}"
exit 1
fi
# Attach amd64 deb
# Attach deb
echo "Attaching ${FILENAME}..."
curl --fail -X POST \
-H "Authorization: token ${TOKEN}" \
-F "attachment=@${DEB}" \
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
echo "Attached: ${FILENAME}"
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null
echo "Done: amd64 published and attached"
build-arm64:
runs-on: sin
needs: [build-amd64]
steps:
- name: Checkout
run: |
@@ -79,16 +81,9 @@ jobs:
- name: Build .deb
run: make deb
- name: Publish to apt registry
run: |
DEB=$(ls build/*.deb)
echo "Publishing ${DEB}..."
curl --fail -H "Authorization: token ${{ secrets.PACKAGES_TOKEN }}" \
--upload-file "${DEB}" \
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
- name: Attach to release
- name: Publish and attach
run: |
set -e
TAG="${{ gitea.ref_name }}"
API="${{ gitea.server_url }}/api/v1"
REPO="${{ gitea.repository }}"
@@ -96,20 +91,41 @@ jobs:
DEB=$(ls build/*.deb)
FILENAME=$(basename "${DEB}")
# Find existing release by tag
RELEASE_ID=$(curl -s \
-H "Authorization: token ${TOKEN}" \
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id')
echo "Release ID: ${RELEASE_ID}"
# Publish to apt
echo "Publishing to apt..."
curl --fail -H "Authorization: token ${TOKEN}" \
--upload-file "${DEB}" \
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
echo "apt: done"
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
echo "ERROR: Release not found for tag ${TAG}"
exit 1
# Wait for release to exist (created by amd64 job)
echo "Waiting for release..."
for i in $(seq 1 30); do
RELEASE_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end')
if [ -n "${RELEASE_ID}" ]; then
break
fi
echo " attempt ${i}/30..."
sleep 10
done
if [ -z "${RELEASE_ID}" ]; then
echo "Release not found, creating..."
RESP=$(curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
"${API}/repos/${REPO}/releases")
RELEASE_ID=$(echo "${RESP}" | jq -r '.id')
fi
# Attach arm64 deb
echo "Release ID: ${RELEASE_ID}"
# Attach deb
echo "Attaching ${FILENAME}..."
curl --fail -X POST \
-H "Authorization: token ${TOKEN}" \
-F "attachment=@${DEB}" \
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
echo "Attached: ${FILENAME}"
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null
echo "Done: arm64 published and attached"