Fix workflow: remove set -e, redirect stderr on uploads
This commit is contained in:
+41
-87
@@ -16,57 +16,31 @@ jobs:
|
|||||||
git fetch --depth=1 origin ${{ gitea.ref }}
|
git fetch --depth=1 origin ${{ gitea.ref }}
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
- name: Build .deb
|
- name: Build
|
||||||
run: make deb
|
run: make deb
|
||||||
|
|
||||||
- name: Publish and release
|
- name: Publish
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
TAG: ${{ gitea.ref_name }}
|
||||||
|
API: ${{ gitea.server_url }}/api/v1
|
||||||
|
REPO: ${{ gitea.repository }}
|
||||||
|
PKG_URL: ${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload
|
||||||
run: |
|
run: |
|
||||||
set -e
|
|
||||||
TAG="${{ gitea.ref_name }}"
|
|
||||||
API="${{ gitea.server_url }}/api/v1"
|
|
||||||
REPO="${{ gitea.repository }}"
|
|
||||||
TOKEN="${{ secrets.PACKAGES_TOKEN }}"
|
|
||||||
DEB=$(ls build/*.deb)
|
DEB=$(ls build/*.deb)
|
||||||
FILENAME=$(basename "${DEB}")
|
FILENAME=$(basename "${DEB}")
|
||||||
|
echo "::group::apt upload"
|
||||||
# Publish to apt
|
curl --fail -sS -H "Authorization: token ${TOKEN}" --upload-file "${DEB}" "${PKG_URL}"
|
||||||
echo "Publishing to apt..."
|
echo ""
|
||||||
curl --fail -H "Authorization: token ${TOKEN}" \
|
echo "::endgroup::"
|
||||||
--upload-file "${DEB}" \
|
echo "::group::release"
|
||||||
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
|
OLD_ID=$(curl -sS -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end' || true)
|
||||||
echo "apt: done"
|
test -n "${OLD_ID}" && curl -sS -X DELETE -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/${OLD_ID}" || true
|
||||||
|
RELEASE_ID=$(curl -sS -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')
|
||||||
# Delete old release if exists
|
echo "Release: ${RELEASE_ID}"
|
||||||
OLD_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
|
curl --fail -sS -X POST -H "Authorization: token ${TOKEN}" -F "attachment=@${DEB}" "${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null 2>&1
|
||||||
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end')
|
echo "::endgroup::"
|
||||||
if [ -n "${OLD_ID}" ]; then
|
echo "amd64 done"
|
||||||
echo "Deleting old release ${OLD_ID}..."
|
|
||||||
curl -s -X DELETE -H "Authorization: token ${TOKEN}" \
|
|
||||||
"${API}/repos/${REPO}/releases/${OLD_ID}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create release
|
|
||||||
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")
|
|
||||||
RELEASE_ID=$(echo "${RESP}" | jq -r '.id')
|
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
|
||||||
|
|
||||||
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
|
||||||
echo "ERROR: ${RESP}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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}" > /dev/null
|
|
||||||
echo "Done: amd64 published and attached"
|
|
||||||
|
|
||||||
build-arm64:
|
build-arm64:
|
||||||
runs-on: sin
|
runs-on: sin
|
||||||
@@ -78,54 +52,34 @@ jobs:
|
|||||||
git fetch --depth=1 origin ${{ gitea.ref }}
|
git fetch --depth=1 origin ${{ gitea.ref }}
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
- name: Build .deb
|
- name: Build
|
||||||
run: make deb
|
run: make deb
|
||||||
|
|
||||||
- name: Publish and attach
|
- name: Publish
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
TAG: ${{ gitea.ref_name }}
|
||||||
|
API: ${{ gitea.server_url }}/api/v1
|
||||||
|
REPO: ${{ gitea.repository }}
|
||||||
|
PKG_URL: ${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload
|
||||||
run: |
|
run: |
|
||||||
set -e
|
|
||||||
TAG="${{ gitea.ref_name }}"
|
|
||||||
API="${{ gitea.server_url }}/api/v1"
|
|
||||||
REPO="${{ gitea.repository }}"
|
|
||||||
TOKEN="${{ secrets.PACKAGES_TOKEN }}"
|
|
||||||
DEB=$(ls build/*.deb)
|
DEB=$(ls build/*.deb)
|
||||||
FILENAME=$(basename "${DEB}")
|
FILENAME=$(basename "${DEB}")
|
||||||
|
echo "::group::apt upload"
|
||||||
# Publish to apt
|
curl --fail -sS -H "Authorization: token ${TOKEN}" --upload-file "${DEB}" "${PKG_URL}"
|
||||||
echo "Publishing to apt..."
|
echo ""
|
||||||
curl --fail -H "Authorization: token ${TOKEN}" \
|
echo "::endgroup::"
|
||||||
--upload-file "${DEB}" \
|
echo "::group::attach to release"
|
||||||
"${{ gitea.server_url }}/api/packages/madcat-os/debian/pool/bookworm/main/upload"
|
|
||||||
echo "apt: done"
|
|
||||||
|
|
||||||
# Wait for release to exist (created by amd64 job)
|
|
||||||
echo "Waiting for release..."
|
|
||||||
for i in $(seq 1 30); do
|
for i in $(seq 1 30); do
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
|
RELEASE_ID=$(curl -sS -H "Authorization: token ${TOKEN}" "${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end' || true)
|
||||||
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r 'if .id then .id else empty end')
|
test -n "${RELEASE_ID}" && break
|
||||||
if [ -n "${RELEASE_ID}" ]; then
|
echo " waiting... ${i}/30"
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo " attempt ${i}/30..."
|
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "${RELEASE_ID}" ]; then
|
if [ -z "${RELEASE_ID}" ]; then
|
||||||
echo "Release not found, creating..."
|
RELEASE_ID=$(curl -sS -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')
|
||||||
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
|
fi
|
||||||
|
echo "Release: ${RELEASE_ID}"
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
curl --fail -sS -X POST -H "Authorization: token ${TOKEN}" -F "attachment=@${DEB}" "${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null 2>&1
|
||||||
|
echo "::endgroup::"
|
||||||
# Attach deb
|
echo "arm64 done"
|
||||||
echo "Attaching ${FILENAME}..."
|
|
||||||
curl --fail -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-F "attachment=@${DEB}" \
|
|
||||||
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" > /dev/null
|
|
||||||
echo "Done: arm64 published and attached"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user