5 Commits

Author SHA1 Message Date
baca4b7761 Refactor GitHub Actions workflow for Gitea Packages: streamline preflight upload process, enhance authentication handling using GitHub actor, and remove redundant debug outputs for improved clarity.
All checks were successful
Build linux_amd64 extension and upload to Packages / build-linux-amd64 (push) Successful in 25m15s
2025-09-13 17:23:52 +00:00
5d4321cb36 Update GitHub Actions workflow to use RELEASE_TOKEN for Gitea Packages upload, ensuring consistent authentication across steps.
Some checks failed
Build linux_amd64 extension and upload to Packages / build-linux-amd64 (push) Has been cancelled
2025-09-13 17:21:46 +00:00
3481b914b1 Refactor GitHub Actions workflow for Gitea Packages: update to use RELEASE_TOKEN for authentication, enhance server URL normalization, and improve error handling for HTTP responses during uploads.
Some checks failed
Build linux_amd64 extension and upload to Packages / build-linux-amd64 (push) Has been cancelled
2025-09-13 17:20:04 +00:00
63c713dab0 Enhance GitHub Actions workflow for Gitea Packages by adding jq to dependencies, improving server URL normalization, and refining error handling for preflight uploads with support for HTTP redirects.
Some checks failed
Build linux_amd64 extension and upload to Packages / build-linux-amd64 (push) Failing after 12s
2025-09-13 17:15:49 +00:00
2be3632ac7 Add preflight upload step to GitHub Actions workflow for Gitea Packages, including token validation and error handling for uploads.
Some checks failed
Build linux_amd64 extension and upload to Packages / build-linux-amd64 (push) Failing after 13s
2025-09-13 17:10:47 +00:00

View File

@@ -53,6 +53,46 @@ jobs:
apt-get install -y --no-install-recommends \
build-essential cmake ninja-build python3 python3-venv pkg-config \
libssl-dev curl git ca-certificates
- name: Preflight Gitea upload (fast-fail)
env:
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
ACTOR: ${{ github.actor }}
run: |
set -euo pipefail
: "${GITEA_TOKEN:?GITEA_TOKEN secret is required}"
server="${GITHUB_SERVER_URL:-${{ github.server_url }}}"
owner="${GITHUB_REPOSITORY_OWNER:-${{ github.repository_owner }}}"
repo_full="${GITHUB_REPOSITORY:-${{ github.repository }}}"
pkg="${repo_full##*/}-preflight"
version="preflight-${GITHUB_RUN_ID:-0}-${GITHUB_RUN_ATTEMPT:-0}-$(date +%s)"
name="check.bin"
tmpfile="$(mktemp)"
printf "auth check %s\n" "$(date -u +%FT%TZ)" > "$tmpfile"
# Normalize server to effective scheme+host (handles http->https redirects)
base_no_trail="$(echo "$server" | sed 's#/*$##')"
# Use GET (not HEAD) to avoid servers that don't support HEAD on this endpoint
effective_version_url=$(curl -sS -L -o /dev/null -w '%{url_effective}' "$base_no_trail/api/v1/version" || echo "")
normalized_server=$(echo "$effective_version_url" | sed -E 's#^(https?://[^/]+).*$#\1#')
if [ -n "$normalized_server" ]; then
server="$normalized_server"
fi
url="$server/api/packages/$owner/generic/$pkg/$version/$name?replace=1"
auth_user="${ACTOR:-$owner}"
echo "Preflight: server=$server owner=$owner package=$pkg version=$version"
# Perform preflight upload using Basic auth directly
if curl -fS -L -X PUT \
-u "$auth_user:${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--upload-file "$tmpfile" "$url" >/dev/null; then
echo "Preflight upload succeeded, cleaning up"
else
echo "Preflight upload failed" >&2
exit 1
fi
# Cleanup the uploaded dummy package version (best effort)
curl -sS -L -o /dev/null -w " delete -> HTTP %{http_code}\n" \
-u "$auth_user:${GITEA_TOKEN}" -X DELETE \
"$server/api/packages/$owner/generic/$pkg/$version" || true
- name: Initialize submodules
run: |
set -e
@@ -96,7 +136,8 @@ jobs:
echo "Using version: $version"
- name: Upload to Gitea Packages (generic)
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
ACTOR: ${{ github.actor }}
run: |
set -euo pipefail
: "${GITEA_TOKEN:?GITEA_TOKEN secret is required}"
@@ -127,11 +168,24 @@ jobs:
[ -n "$pkg" ] || { echo "pkg not set" >&2; exit 1; }
[ -n "$version" ] || { echo "version not set" >&2; exit 1; }
[ -n "$file" ] || { echo "file not set" >&2; exit 1; }
# Normalize server using effective URL of /api/v1/version (handles http->https)
base_no_trail="$(echo "$server" | sed 's#/*$##')"
effective_version_url=$(curl -sS -L -o /dev/null -w '%{url_effective}' "$base_no_trail/api/v1/version" || echo "")
normalized_server=$(echo "$effective_version_url" | sed -E 's#^(https?://[^/]+).*$#\1#')
if [ -n "$normalized_server" ]; then
server="$normalized_server"
fi
# Use the GitHub actor as basic auth username by default
auth_user="${ACTOR:-$owner}"
name="$(basename "$file")"
url="$server/api/packages/$owner/generic/$pkg/$version/$name?replace=1"
echo "Uploading $file to $url"
curl -fsSL -X PUT \
-H "Authorization: token ${GITEA_TOKEN}" \
echo " auth user=$auth_user"
# Use Basic auth directly (works with package registry)
curl -fS -L -X PUT \
-u "$auth_user:${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--retry 2 --retry-delay 2 --max-time 300 \
--upload-file "$file" "$url"
echo "Upload complete."