This commit is contained in:
2025-10-04 16:05:50 +08:00
parent 00f135a19c
commit 6981dbdd14

View File

@@ -1,26 +1,96 @@
# .woodpecker.yml放仓库根目录 # 只调度到你的 macOS 本机 agentlocal/exec
platform: darwin/arm64 # 选择“什么平台”的 agent labels:
labels: # 进一步筛选 agent匹配 custom_labels
host: Mac-mini.local host: Mac-mini.local
platform: darwin/arm64
gpu: metal gpu: metal
when:
event: [push, manual, pull_request]
# 给所有步骤补 PATHlaunchd 环境常不带 /opt/homebrew/bin
environment:
PATH: "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
steps: steps:
- name: env-info - name: env-info
image: /bin/zsh # local/exec 后端这里写 shell 路径 image: /bin/zsh
commands: commands:
- | - sw_vers
set -e - xcodebuild -version || true
echo "Agent: ${CI_AGENT_NAME:-unknown}" - echo "Agent: ${CI_AGENT_NAME:-unknown}"
echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}" - echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}"
sw_vers
xcodebuild -version || true
# 1) woodpecker-cli / plugin-git / plugin-s3 / plugin-docker-buildx 的最小自检
- 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
# 2) Swift 原生小程序(证明在 macOS 本机执行)
- name: swift-hello - name: swift-hello
image: /bin/zsh image: /bin/zsh
commands:
- 'printf "print(\\"Hello from Swift!\\")\n" > hello.swift'
- swiftc hello.swift -o hello
- ./hello
# 3) (可选)用 plugin-git 再 clone 一份 repo仅演示可删
# 提示:本来 agent 在 clone 阶段就会用 plugin-git 了,这里只是验证二进制可用。
- 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."'
# 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
commands: commands:
- | - |
set -e if [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" && -n "$S3_BUCKET" ]]; then
cat > hello.swift <<'SWIFT' echo "Hello S3 from Woodpecker at $(date)" > s3-demo.txt
print("Hello from Swift!") # plugin-s3 的环境变量约定PLUGIN_*(与 docker 版一致)
SWIFT export PLUGIN_SOURCE="s3-demo.txt"
swiftc hello.swift -o hello && ./hello 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 才跑;未装就跳过)
- name: docker-buildx-demo
image: /bin/zsh
commands:
- |
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