Enhance GitHub Actions workflow for linux_amd64 build: add workspace status check, initialize submodules, build release, and compute package version before uploading to Gitea Packages.
This commit is contained in:
85
.github/workflows/build-linux-amd64.yml
vendored
85
.github/workflows/build-linux-amd64.yml
vendored
@@ -16,6 +16,11 @@ jobs:
|
|||||||
EXTENSION_NAME: ui
|
EXTENSION_NAME: ui
|
||||||
DUCKDB_PLATFORM: linux_amd64
|
DUCKDB_PLATFORM: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
|
- name: Show workspace status
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
test -d .git || { echo "Repository not checked out in workspace" >&2; exit 1; }
|
||||||
|
git --no-pager status | cat
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -24,9 +29,85 @@ jobs:
|
|||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
build-essential cmake ninja-build python3 python3-venv pkg-config \
|
build-essential cmake ninja-build python3 python3-venv pkg-config \
|
||||||
libssl-dev curl git ca-certificates
|
libssl-dev curl git ca-certificates
|
||||||
# ... submodule init, build release, find artifact ...
|
- name: Initialize submodules
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
- name: Build release (linux_amd64)
|
||||||
|
env:
|
||||||
|
GEN: ""
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
make -j"$(nproc)" release
|
||||||
|
|
||||||
|
- name: Find extension artifact
|
||||||
|
id: artifact
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
path="$(ls -1 build/release/extension/${EXTENSION_NAME}/${EXTENSION_NAME}.duckdb_extension 2>/dev/null || true)"
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
path="$(find build/release -type f -name '*.duckdb_extension' | head -n 1 || true)"
|
||||||
|
fi
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
echo "Extension artifact not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "file=$path" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Found: $path"
|
||||||
|
|
||||||
|
- name: Compute package version
|
||||||
|
id: ver
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
version='${{ inputs.version }}'
|
||||||
|
if [ -z "$version" ]; then
|
||||||
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||||
|
version='${{ github.ref_name }}'
|
||||||
|
else
|
||||||
|
version="dev-${GITHUB_SHA::8}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Using version: $version"
|
||||||
- name: Upload to Gitea Packages (generic)
|
- name: Upload to Gitea Packages (generic)
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL -X PUT -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file "$file" "$server/api/packages/$owner/generic/$pkg/$version/$name?replace=1"
|
set -euo pipefail
|
||||||
|
: "${GITEA_TOKEN:?GITEA_TOKEN secret is required}"
|
||||||
|
# Derive server/owner/pkg from env if not provided
|
||||||
|
server="${GITHUB_SERVER_URL:-${{ github.server_url }}}"
|
||||||
|
owner="${GITHUB_REPOSITORY_OWNER:-${{ github.repository_owner }}}"
|
||||||
|
repo_full="${GITHUB_REPOSITORY:-${{ github.repository }}}"
|
||||||
|
pkg="${repo_full##*/}"
|
||||||
|
# Use previously computed version & artifact if available
|
||||||
|
version='${{ steps.ver.outputs.version }}'
|
||||||
|
file='${{ steps.artifact.outputs.file }}'
|
||||||
|
# Fallbacks if steps were skipped
|
||||||
|
if [ -z "${version}" ]; then
|
||||||
|
if [ -n "${GITHUB_REF_TYPE:-}" ] && [ "${GITHUB_REF_TYPE}" = "tag" ]; then
|
||||||
|
version="${GITHUB_REF_NAME:-dev-${GITHUB_SHA::8}}"
|
||||||
|
else
|
||||||
|
version="dev-${GITHUB_SHA::8}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -z "${file}" ]; then
|
||||||
|
file="$(ls -1 build/release/extension/${EXTENSION_NAME}/${EXTENSION_NAME}.duckdb_extension 2>/dev/null || true)"
|
||||||
|
if [ -z "$file" ]; then
|
||||||
|
file="$(find build/release -type f -name '*.duckdb_extension' | head -n 1 || true)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
[ -n "$server" ] || { echo "server not set" >&2; exit 1; }
|
||||||
|
[ -n "$owner" ] || { echo "owner not set" >&2; exit 1; }
|
||||||
|
[ -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; }
|
||||||
|
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}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--upload-file "$file" "$url"
|
||||||
|
echo "Upload complete."
|
||||||
Reference in New Issue
Block a user