diff --git a/.woodpecker.yml b/.woodpecker.yml index ea1d685..e609ce4 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,26 +1,96 @@ -# .woodpecker.yml(放仓库根目录) -platform: darwin/arm64 # 选择“什么平台”的 agent -labels: # 进一步筛选 agent(匹配 custom_labels) +# 只调度到你的 macOS 本机 agent(local/exec) +labels: host: Mac-mini.local + platform: darwin/arm64 gpu: metal +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 # local/exec 后端这里写 shell 路径 + image: /bin/zsh commands: - - | - set -e - echo "Agent: ${CI_AGENT_NAME:-unknown}" - echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}" - sw_vers - xcodebuild -version || true + - sw_vers + - xcodebuild -version || true + - echo "Agent: ${CI_AGENT_NAME:-unknown}" + - echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}" + # 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 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: - | - set -e - cat > hello.swift <<'SWIFT' - print("Hello from Swift!") - SWIFT - swiftc hello.swift -o hello && ./hello + 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 版一致) + 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 才跑;未装就跳过) + - 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