From cb2f03eeb8df2444aa6ab15045118ac05f3162a4 Mon Sep 17 00:00:00 2001 From: Vadim Stepanov Date: Tue, 30 Aug 2022 18:45:41 +0100 Subject: [PATCH] Add drone step for creating & pushing docker manifest list + cleanup (#434) * add drone step for creating & pushing docker manifest + cleanup * drone sign --- .drone.yml | 148 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 50 deletions(-) diff --git a/.drone.yml b/.drone.yml index 58274b4b..8bf3201a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -158,17 +158,10 @@ trigger: --- kind: pipeline type: docker -name: OSS Release +name: OSS plugin release steps: - - name: Check Promote - image: alpine - commands: - - if [ -z "$DRONE_DEPLOY_TO" ]; then echo "Missing DRONE_DEPLOY_TO (Target)"; exit 1; fi - - if [ -z "$DRONE_TAG" ]; then echo "Missing DRONE_TAG"; exit 1; fi - - echo Promoting $DRONE_TAG to $DRONE_DEPLOY_TO - - - name: Build Plugin + - name: build plugin image: node:14.6.0-stretch commands: - apt-get update @@ -178,23 +171,14 @@ steps: - yarn --network-timeout 500000 - yarn build - ls ./ - depends_on: - - Check Promote - when: - event: - - promote - target: - - oss - ref: - - refs/tags/v*.*.* - - name: Sign and Package Plugin + - name: sign and package plugin image: node:14.6.0-stretch environment: GRAFANA_API_KEY: from_secret: gcom_plugin_publisher_api_key depends_on: - - Build Plugin + - build plugin commands: - apt-get update - apt-get install zip @@ -206,7 +190,7 @@ steps: - zip -r grafana-oncall-app.zip ./grafana-oncall-app - if [ -z "$DRONE_TAG" ]; then echo "No tag, skipping archive"; else cp grafana-oncall-app.zip grafana-oncall-app-${DRONE_TAG}.zip; fi - - name: Publish Plugin to grafana.com (release) + - name: publish plugin to grafana.com (release) image: curlimages/curl:7.73.0 environment: GRAFANA_API_KEY: @@ -214,32 +198,36 @@ steps: commands: - "curl -f -s -H \"Authorization: Bearer $${GRAFANA_API_KEY}\" -d \"download[any][url]=https://storage.googleapis.com/grafana-oncall-app/releases/grafana-oncall-app-${DRONE_TAG}.zip\" -d \"download[any][md5]=$$(curl -sL https://storage.googleapis.com/grafana-oncall-app/releases/grafana-oncall-app-${DRONE_TAG}.zip | md5sum | cut -d' ' -f1)\" -d url=https://github.com/grafana/oncall/grafana-plugin https://grafana.com/api/plugins" depends_on: - - Sign and Package Plugin + - sign and package plugin - - name: Image Tag +trigger: + event: + - promote + target: + - oss + ref: + - refs/tags/v*.*.* + +--- +kind: pipeline +type: docker +name: OSS engine release (amd64) +platform: + os: linux + arch: amd64 +steps: + - name: set engine version image: alpine commands: - - apk add --no-cache bash git sed - - git fetch origin --tags - - chmod +x ./tools/image-tag.sh - - echo $(./tools/image-tag.sh) - - echo $(./tools/image-tag.sh) > .tags + - apk add --no-cache bash sed - if [ -z "$DRONE_TAG" ]; then echo "No tag, not modifying version"; else sed "0,/VERSION.*/ s/VERSION.*/VERSION = \"${DRONE_TAG}\"/g" engine/settings/base.py > engine/settings/base.temp && mv engine/settings/base.temp engine/settings/base.py; fi - cat engine/settings/base.py | grep VERSION | head -1 - depends_on: - - Check Promote - when: - event: - - promote - target: - - oss - ref: - - refs/tags/v*.*.* - - name: Build and Push Engine Docker Image Backend to Dockerhub + - name: build and push docker image image: plugins/docker settings: repo: grafana/oncall + tags: ${DRONE_TAG}-amd64-linux dockerfile: engine/Dockerfile context: engine/ password: @@ -247,21 +235,81 @@ steps: username: from_secret: docker_username depends_on: - - Image Tag - - - name: Unrecognized Promote Target - image: alpine - commands: - - echo $DRONE_DEPLOY_TO is not a recognized promote target! - - exit 1 - when: - target: - exclude: - - oss + - set engine version trigger: event: - promote + target: + - oss + ref: + - refs/tags/v*.*.* + +--- +kind: pipeline +type: docker +name: OSS engine release (arm64) +platform: + os: linux + arch: arm64 +steps: + - name: set engine version + image: alpine + commands: + - apk add --no-cache bash sed + - if [ -z "$DRONE_TAG" ]; then echo "No tag, not modifying version"; else sed "0,/VERSION.*/ s/VERSION.*/VERSION = \"${DRONE_TAG}\"/g" engine/settings/base.py > engine/settings/base.temp && mv engine/settings/base.temp engine/settings/base.py; fi + - cat engine/settings/base.py | grep VERSION | head -1 + + - name: build and push docker image + image: plugins/docker + settings: + repo: grafana/oncall + tags: ${DRONE_TAG}-arm64-linux + dockerfile: engine/Dockerfile + context: engine/ + password: + from_secret: docker_password + username: + from_secret: docker_username + depends_on: + - set engine version + +trigger: + event: + - promote + target: + - oss + ref: + - refs/tags/v*.*.* + +--- +kind: pipeline +type: docker +name: manifest +steps: + - name: manifest + image: plugins/manifest + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + target: grafana/oncall:${DRONE_TAG} + template: grafana/oncall:${DRONE_TAG}-ARCH-OS + platforms: + - linux/amd64 + - linux/arm64 +depends_on: + - OSS engine release (amd64) + - OSS engine release (arm64) + +trigger: + event: + - promote + target: + - oss + ref: + - refs/tags/v*.*.* --- # Secret for pulling docker images. @@ -334,6 +382,6 @@ kind: secret name: drone_token --- kind: signature -hmac: a74dd831a3d0a87b8fc1db45699a6a834ea769da9f437c55979ae665948c3b3f +hmac: a52e4cea86ef50bbf7b19a05bec619368281e58927206709ef1e9dfd1df44e0e ...