75 lines
2.2 KiB
YAML
75 lines
2.2 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: pybuild
|
|
spec:
|
|
params:
|
|
- name: context
|
|
type: string
|
|
default: ""
|
|
description: home directory
|
|
|
|
- name: pythonImageName
|
|
type: string
|
|
default: "python:3.11-slim"
|
|
description: Python version to use
|
|
|
|
workspaces:
|
|
- name: base
|
|
description: Workspace containing the cloned Git repository
|
|
|
|
results:
|
|
- name: build-artifact-path
|
|
description: Path to the built artifact directory (e.g., dist/)
|
|
|
|
steps:
|
|
- name: build-package
|
|
image: $(params.pythonImageName)
|
|
workingDir: /workspace/base/$(params.context)/source
|
|
env:
|
|
- name: HOME
|
|
value: /workspace/base/$(params.context)/home
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
echo "🔧 Installing base tools..."
|
|
pip install --upgrade pip --root-user-action=ignore
|
|
|
|
# Poetry 프로젝트 처리
|
|
if [ -f pyproject.toml ]; then
|
|
echo "[INFO] Poetry project detected"
|
|
pip install poetry --root-user-action=ignore
|
|
|
|
poetry lock || echo "[WARN] poetry lock skipped"
|
|
poetry install --no-root || echo "[WARN] poetry install skipped"
|
|
|
|
echo "📦 Building with Poetry..."
|
|
poetry build
|
|
|
|
# setup.py 기반 빌드
|
|
elif [ -f setup.py ] && [ -f requirements.txt ]; then
|
|
echo "[INFO] setup.py project detected"
|
|
pip install -r requirements.txt --root-user-action=ignore
|
|
pip install build --root-user-action=ignore
|
|
|
|
echo "📦 Building with Python Build module..."
|
|
python -m build
|
|
|
|
else
|
|
echo "❌ No valid build configuration found (pyproject.toml or setup.py required)"
|
|
exit 1
|
|
fi
|
|
|
|
echo "📂 Checking built artifacts..."
|
|
BUILD_PATH="/workspace/base/$(params.context)/source/dist"
|
|
echo -n "$BUILD_PATH" > /tekton/results/build-artifact-path
|
|
|
|
if [ -d "$BUILD_PATH" ] && [ -n "$(ls -A "$BUILD_PATH")" ]; then
|
|
echo "✅ Build artifacts created in $BUILD_PATH:"
|
|
ls -l "$BUILD_PATH"
|
|
else
|
|
echo "❌ No artifacts found in $BUILD_PATH"
|
|
exit 1
|
|
fi
|