From db786d0100e7c122de929c95399a438227e7f3c3 Mon Sep 17 00:00:00 2001 From: seahi Date: Wed, 17 Dec 2025 09:10:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81buggy=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 86 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index 559e8ce..986700d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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