Drone: Separate pipeline for publishing packages (#27774)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-09-24 21:31:09 +02:00
committed by GitHub
parent 9ca12a7663
commit 02e648c42d
2 changed files with 99 additions and 17 deletions

View File

@ -522,10 +522,10 @@ steps:
depends_on: depends_on:
- end-to-end-tests - end-to-end-tests
- name: publish-packages - name: upload-packages
image: grafana/grafana-ci-deploy:1.2.6 image: grafana/grafana-ci-deploy:1.2.6
commands: commands:
- ./bin/grabpl publish-packages --edition oss - ./bin/grabpl upload-packages --edition oss
environment: environment:
GCP_GRAFANA_UPLOAD_KEY: GCP_GRAFANA_UPLOAD_KEY:
from_secret: gcp_key from_secret: gcp_key
@ -615,4 +615,49 @@ trigger:
depends_on: depends_on:
- build-master - build-master
---
kind: pipeline
type: docker
name: publish-master
platform:
os: linux
arch: amd64
steps:
- name: identify-runner
image: alpine:3.12
commands:
- echo $DRONE_RUNNER_NAME
- name: initialize
image: grafana/build-container:1.2.27
commands:
- curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.5.10/grabpl
- chmod +x grabpl
- mkdir -p bin
- mv grabpl bin
environment:
DOCKERIZE_VERSION: 0.6.1
- name: publish-packages
image: grafana/grafana-ci-deploy:1.2.6
commands:
- ./bin/grabpl publish-packages --edition oss
environment:
GRAFANA_COM_API_KEY:
from_secret: grafana_api_key
depends_on:
- upload-packages
trigger:
branch:
- master
event:
- push
depends_on:
- build-master
- windows-master
... ...

View File

@ -88,12 +88,16 @@ def master_steps(edition, is_downstream=False):
postgres_integration_tests_step(), postgres_integration_tests_step(),
mysql_integration_tests_step(), mysql_integration_tests_step(),
release_next_npm_packages_step(edition), release_next_npm_packages_step(edition),
publish_packages_step(edition, is_downstream), upload_packages_step(edition, is_downstream),
deploy_to_kubernetes_step(edition, is_downstream), deploy_to_kubernetes_step(edition, is_downstream),
] ]
windows_steps = get_windows_steps(edition=edition, version_mode='master', is_downstream=is_downstream) windows_steps = get_windows_steps(edition=edition, version_mode='master', is_downstream=is_downstream)
return steps, windows_steps publish_steps = [
publish_packages_step(edition, is_downstream),
]
return steps, windows_steps, publish_steps
def master_pipelines(edition): def master_pipelines(edition):
services = [ services = [
@ -121,7 +125,7 @@ def master_pipelines(edition):
'event': ['push',], 'event': ['push',],
'branch': 'master', 'branch': 'master',
} }
steps, windows_steps = master_steps(edition=edition) steps, windows_steps, publish_steps = master_steps(edition=edition)
pipelines = [ pipelines = [
pipeline( pipeline(
name='build-master', edition=edition, trigger=trigger, services=services, steps=steps name='build-master', edition=edition, trigger=trigger, services=services, steps=steps
@ -131,12 +135,17 @@ def master_pipelines(edition):
depends_on=['build-master'], depends_on=['build-master'],
), ),
] ]
if edition != 'enterprise':
pipelines.append(pipeline(
name='publish-master', edition=edition, trigger=trigger, steps=publish_steps,
depends_on=['build-master', 'windows-master',], install_deps=False,
))
if edition == 'enterprise': if edition == 'enterprise':
# Add downstream enterprise pipelines triggerable from OSS builds # Add downstream enterprise pipelines triggerable from OSS builds
trigger = { trigger = {
'event': ['custom',], 'event': ['custom',],
} }
steps, windows_steps = master_steps(edition=edition, is_downstream=True) steps, windows_steps, publish_steps = master_steps(edition=edition, is_downstream=True)
pipelines.append(pipeline( pipelines.append(pipeline(
name='build-master-downstream', edition=edition, trigger=trigger, services=services, steps=steps, name='build-master-downstream', edition=edition, trigger=trigger, services=services, steps=steps,
is_downstream=True, is_downstream=True,
@ -145,10 +154,15 @@ def master_pipelines(edition):
name='windows-master-downstream', edition=edition, trigger=trigger, steps=windows_steps, name='windows-master-downstream', edition=edition, trigger=trigger, steps=windows_steps,
platform='windows', depends_on=['build-master-downstream'], is_downstream=True, platform='windows', depends_on=['build-master-downstream'], is_downstream=True,
)) ))
pipelines.append(pipeline(
name='publish-master-downstream', edition=edition, trigger=trigger, steps=publish_steps,
depends_on=['build-master-downstream', 'windows-master-downstream'], is_downstream=True, install_deps=False,
))
return pipelines return pipelines
def pipeline(name, edition, trigger, steps, services=[], platform='linux', depends_on=[], is_downstream=False): def pipeline(name, edition, trigger, steps, services=[], platform='linux', depends_on=[], is_downstream=False,
install_deps=True):
if platform != 'windows': if platform != 'windows':
platform_conf = { platform_conf = {
'os': 'linux', 'os': 'linux',
@ -168,7 +182,7 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen
'name': name, 'name': name,
'trigger': trigger, 'trigger': trigger,
'services': services, 'services': services,
'steps': init_steps(edition, platform, is_downstream=is_downstream) + steps, 'steps': init_steps(edition, platform, is_downstream=is_downstream, install_deps=install_deps) + steps,
'depends_on': depends_on, 'depends_on': depends_on,
} }
@ -180,7 +194,7 @@ def pipeline(name, edition, trigger, steps, services=[], platform='linux', depen
return pipeline return pipeline
def init_steps(edition, platform, is_downstream=False): def init_steps(edition, platform, is_downstream=False, install_deps=True):
if platform == 'windows': if platform == 'windows':
return [ return [
{ {
@ -200,12 +214,15 @@ def init_steps(edition, platform, is_downstream=False):
], ],
} }
common_cmds = [ if install_deps:
'curl -fLO https://github.com/jwilder/dockerize/releases/download/v$${DOCKERIZE_VERSION}/dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz', common_cmds = [
'tar -C bin -xzvf dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz', 'curl -fLO https://github.com/jwilder/dockerize/releases/download/v$${DOCKERIZE_VERSION}/dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz',
'rm dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz', 'tar -C bin -xzvf dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz',
'yarn install --frozen-lockfile --no-progress', 'rm dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz',
] 'yarn install --frozen-lockfile --no-progress',
]
else:
common_cmds = []
if edition == 'enterprise': if edition == 'enterprise':
if is_downstream: if is_downstream:
source_commit = ' $${SOURCE_COMMIT}' source_commit = ' $${SOURCE_COMMIT}'
@ -730,12 +747,12 @@ def deploy_to_kubernetes_step(edition, is_downstream):
], ],
} }
def publish_packages_step(edition, is_downstream): def upload_packages_step(edition, is_downstream):
if edition == 'enterprise' and not is_downstream: if edition == 'enterprise' and not is_downstream:
return None return None
return { return {
'name': 'publish-packages', 'name': 'upload-packages',
'image': publish_image, 'image': publish_image,
'depends_on': [ 'depends_on': [
'package', 'package',
@ -760,6 +777,26 @@ def publish_packages_step(edition, is_downstream):
'from_secret': 'gpg_key_password', 'from_secret': 'gpg_key_password',
}, },
}, },
'commands': [
'./bin/grabpl upload-packages --edition {}'.format(edition),
],
}
def publish_packages_step(edition, is_downstream):
if edition == 'enterprise' and not is_downstream:
return None
return {
'name': 'publish-packages',
'image': publish_image,
'depends_on': [
'upload-packages',
],
'environment': {
'GRAFANA_COM_API_KEY': {
'from_secret': 'grafana_api_key',
},
},
'commands': [ 'commands': [
'./bin/grabpl publish-packages --edition {}'.format(edition), './bin/grabpl publish-packages --edition {}'.format(edition),
], ],