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