feat: 支持buggy版本
Some checks failed
continuous-integration/drone/tag Build is failing

This commit is contained in:
2025-12-17 09:10:39 +08:00
parent 5a75acc4f6
commit db786d0100

View File

@@ -12,34 +12,62 @@ trigger:
- refs/tags/v*
steps:
- name: build-and-push
image: docker:dind
privileged: true
environment:
REGISTRY: harbor.seahi.me
IMAGE_NAME: stu/versions-for-swarm
HARBOR_USERNAME:
- name: build-and-push-normal
image: plugins/docker
settings:
registry: harbor.seahi.me
repo: harbor.seahi.me/stu/versions-for-swarm
username:
from_secret: harbor_username
HARBOR_PASSWORD:
password:
from_secret: harbor_password
commands:
- echo $HARBOR_PASSWORD | docker login $REGISTRY -u $HARBOR_USERNAME --password-stdin
- export VERSION=${DRONE_TAG}
- echo [BUILD] 构建版本 $VERSION
- |
if echo "$VERSION" | grep -q "buggy"; then
BUGGY_FLAG="--build-arg BUGGY=true"
echo [WARNING] 检测到 buggy 版本,启用故障模式
else
BUGGY_FLAG=""
fi
- docker build --build-arg APP_VERSION=$VERSION $BUGGY_FLAG -t $REGISTRY/$IMAGE_NAME:$VERSION .
- |
if [ "$VERSION" = "v2.1" ]; then
docker tag $REGISTRY/$IMAGE_NAME:$VERSION $REGISTRY/$IMAGE_NAME:latest
docker push $REGISTRY/$IMAGE_NAME:latest
echo [TAG] 已标记为 latest
fi
- docker push $REGISTRY/$IMAGE_NAME:$VERSION
- docker system prune -f
- echo [SUCCESS] 版本 $VERSION 构建并推送成功
insecure: true
tags:
- ${DRONE_TAG}
build_args:
- APP_VERSION=${DRONE_TAG}
auto_tag: false
when:
ref:
exclude:
- refs/tags/*buggy*
- name: build-and-push-buggy
image: plugins/docker
settings:
registry: harbor.seahi.me
repo: harbor.seahi.me/stu/versions-for-swarm
username:
from_secret: harbor_username
password:
from_secret: harbor_password
insecure: true
tags:
- ${DRONE_TAG}
build_args:
- APP_VERSION=${DRONE_TAG}
- BUGGY=true
auto_tag: false
when:
ref:
include:
- refs/tags/*buggy*
- name: tag-latest-if-v2.1
image: plugins/docker
settings:
registry: harbor.seahi.me
repo: harbor.seahi.me/stu/versions-for-swarm
username:
from_secret: harbor_username
password:
from_secret: harbor_password
insecure: true
tags:
- latest
build_args:
- APP_VERSION=${DRONE_TAG}
auto_tag: false
when:
ref:
- refs/tags/v2.1