This commit is contained in:
@@ -7,10 +7,6 @@ labels:
|
||||
when:
|
||||
event: [push, manual, pull_request]
|
||||
|
||||
# 给所有步骤补 PATH(launchd 环境常不带 /opt/homebrew/bin)
|
||||
environment:
|
||||
PATH: "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
steps:
|
||||
- name: env-info
|
||||
image: /bin/zsh
|
||||
@@ -19,80 +15,106 @@ steps:
|
||||
set -e
|
||||
echo "Agent: ${CI_AGENT_NAME:-unknown}"
|
||||
echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}"
|
||||
echo "PATH (runtime): $PATH"
|
||||
which git || true
|
||||
which git-lfs || true
|
||||
git lfs version || true
|
||||
sw_vers
|
||||
xcodebuild -version || true
|
||||
|
||||
# 1) woodpecker-cli / plugin-git / plugin-s3 / plugin-docker-buildx 的最小自检
|
||||
# 1) 四个工具自检
|
||||
- name: tools-versions
|
||||
image: /bin/zsh
|
||||
commands:
|
||||
- which woodpecker || true
|
||||
- woodpecker --version || true
|
||||
- which plugin-git || true
|
||||
- plugin-git --help | head -n1 || true
|
||||
- which plugin-s3 || true
|
||||
- plugin-s3 --help | head -n1 || true
|
||||
- which plugin-docker-buildx || true
|
||||
- plugin-docker-buildx --help | head -n1 || true
|
||||
- |
|
||||
set -e
|
||||
echo "[which]"
|
||||
which woodpecker || true
|
||||
which plugin-git || true
|
||||
which plugin-s3 || true
|
||||
which plugin-docker-buildx || true
|
||||
echo "[versions]"
|
||||
woodpecker --version || true
|
||||
plugin-git --help | head -n1 || true
|
||||
plugin-s3 --help | head -n1 || true
|
||||
plugin-docker-buildx --help | head -n1 || true
|
||||
|
||||
# 2) Swift 原生小程序(证明在 macOS 本机执行)
|
||||
- name: swift-hello
|
||||
image: /bin/zsh
|
||||
commands:
|
||||
- 'printf "print(\\"Hello from Swift!\\")\n" > hello.swift'
|
||||
- swiftc hello.swift -o hello
|
||||
- ./hello
|
||||
- |
|
||||
set -e
|
||||
cat > hello.swift <<'SWIFT'
|
||||
print("Hello from Swift!")
|
||||
SWIFT
|
||||
swiftc hello.swift -o hello
|
||||
./hello
|
||||
|
||||
# 3) (可选)用 plugin-git 再 clone 一份 repo(仅演示,可删)
|
||||
# 提示:本来 agent 在 clone 阶段就会用 plugin-git 了,这里只是验证二进制可用。
|
||||
# 3) (演示)plugin-git 可用性(clone 阶段已用过,这里只是确认二进制在 PATH)
|
||||
- name: plugin-git-smoke
|
||||
image: /bin/zsh
|
||||
commands:
|
||||
- 'echo "Smoketest plugin-git (help) ..."'
|
||||
- plugin-git --help | head -n3
|
||||
- 'echo "Skip real clone: working dir already contains the repo checked out by the agent."'
|
||||
- |
|
||||
set -e
|
||||
echo "Smoketest plugin-git (help) ..."
|
||||
plugin-git --help | head -n3
|
||||
echo "Skip real clone: agent 已经把仓库拉到工作目录了."
|
||||
|
||||
# 4) (可选)S3 演示(有 AK/SK 就传;没有就跳过)
|
||||
# 4) S3 演示(有 AK/SK 就传;没有就跳过)
|
||||
- name: s3-upload-demo
|
||||
image: /bin/zsh
|
||||
environment:
|
||||
# 如果你有 MinIO/S3 的账号,就把这些按需塞到仓库 Secrets 或 agent 环境里
|
||||
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
|
||||
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
|
||||
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
|
||||
S3_BUCKET: ${S3_BUCKET}
|
||||
S3_ENDPOINT: ${S3_ENDPOINT} # MinIO 就用 http(s)://host:port
|
||||
S3_ENDPOINT: ${S3_ENDPOINT}
|
||||
commands:
|
||||
- |
|
||||
set -e
|
||||
if [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" && -n "$S3_BUCKET" ]]; then
|
||||
echo "Hello S3 from Woodpecker at $(date)" > s3-demo.txt
|
||||
# plugin-s3 的环境变量约定:PLUGIN_*(与 docker 版一致)
|
||||
# plugin-s3 的环境变量(与容器版一致)
|
||||
export PLUGIN_SOURCE="s3-demo.txt"
|
||||
export PLUGIN_BUCKET="$S3_BUCKET"
|
||||
export PLUGIN_TARGET="woodpecker-demo/"
|
||||
# 如需自签/兼容 S3 端点(MinIO),通常还要:
|
||||
[[ -n "$S3_ENDPOINT" ]] && export PLUGIN_ENDPOINT="$S3_ENDPOINT" && export PLUGIN_PATH_STYLE=true
|
||||
plugin-s3
|
||||
else
|
||||
echo "No S3 creds found. Skipping s3-upload-demo."
|
||||
fi
|
||||
|
||||
# 5) (可选)Docker Buildx 演示(机器装了 Docker 才跑;未装就跳过)
|
||||
# 5) Docker Buildx 演示(装了 Docker 才跑;未装就跳过)
|
||||
- name: docker-buildx-demo
|
||||
image: /bin/zsh
|
||||
commands:
|
||||
- |
|
||||
set -e
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
echo 'FROM alpine:3.20 AS base' > Dockerfile
|
||||
echo 'RUN echo "hello" > /hello.txt' >> Dockerfile
|
||||
# plugin-docker-buildx 的常用配置
|
||||
export PLUGIN_CONTEXT="."
|
||||
export PLUGIN_DOCKERFILE="Dockerfile"
|
||||
export PLUGIN_TAGS="test:latest"
|
||||
export PLUGIN_BUILDKIT_INLINE_CACHE=true
|
||||
# 不推镜像,仅本地构建(避免登录/推送)
|
||||
export PLUGIN_PUSH=false
|
||||
plugin-docker-buildx
|
||||
else
|
||||
echo "Docker not found. Skipping docker-buildx-demo."
|
||||
fi
|
||||
|
||||
# (可选)Podman 演示:你机器没有 Docker 但有 Podman 时
|
||||
- name: podman-build-demo
|
||||
image: /bin/zsh
|
||||
commands:
|
||||
- |
|
||||
set -e
|
||||
if command -v podman >/dev/null 2>&1; then
|
||||
echo 'FROM alpine:3.20 AS base' > Dockerfile
|
||||
echo 'RUN echo "hello with podman" > /hello.txt' >> Dockerfile
|
||||
podman build -t local/test:latest .
|
||||
podman image ls | grep 'local/test' || true
|
||||
else
|
||||
echo "Podman not found. Skipping podman-build-demo."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user