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