CI: Add automation for github assets publishing (#59491)
* Add github.star
* Make step depend on fetch images
* artifacts -> path
* Add github token
* Fix custom path
* Add case where path is absent
* Add GH_REGISTRY secret
(cherry picked from commit e9cf8fa751)
This commit is contained in:
+20
-6
@@ -9,14 +9,28 @@ load('scripts/drone/events/main.star', 'main_pipelines')
|
||||
load('scripts/drone/pipelines/docs.star', 'docs_pipelines')
|
||||
load('scripts/drone/events/release.star', 'release_pipelines', 'publish_artifacts_pipelines', 'publish_npm_pipelines', 'publish_packages_pipeline', 'artifacts_page_pipeline')
|
||||
load('scripts/drone/pipelines/publish_images.star', 'publish_image_pipelines_public', 'publish_image_pipelines_security')
|
||||
load('scripts/drone/pipelines/github.star', 'publish_github_pipeline')
|
||||
load('scripts/drone/version.star', 'version_branch_pipelines')
|
||||
load('scripts/drone/events/cron.star', 'cronjobs')
|
||||
load('scripts/drone/vault.star', 'secrets')
|
||||
|
||||
edition = 'oss'
|
||||
|
||||
def main(ctx):
|
||||
edition = 'oss'
|
||||
return pr_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \
|
||||
publish_image_pipelines_public() + publish_image_pipelines_security() + \
|
||||
publish_artifacts_pipelines('security') + publish_artifacts_pipelines('public') + \
|
||||
publish_npm_pipelines('public') + publish_packages_pipeline() + artifacts_page_pipeline() + \
|
||||
version_branch_pipelines() + cronjobs(edition=edition) + secrets()
|
||||
return (
|
||||
pr_pipelines(edition=edition)
|
||||
+ main_pipelines(edition=edition)
|
||||
+ release_pipelines()
|
||||
+ publish_image_pipelines_public()
|
||||
+ publish_image_pipelines_security()
|
||||
+ publish_github_pipeline('public')
|
||||
+ publish_github_pipeline('security')
|
||||
+ publish_artifacts_pipelines('security')
|
||||
+ publish_artifacts_pipelines('public')
|
||||
+ publish_npm_pipelines('public')
|
||||
+ publish_packages_pipeline()
|
||||
+ artifacts_page_pipeline()
|
||||
+ version_branch_pipelines()
|
||||
+ cronjobs(edition=edition)
|
||||
+ secrets()
|
||||
)
|
||||
|
||||
+123
-1
@@ -3554,6 +3554,128 @@ volumes:
|
||||
clone:
|
||||
retries: 3
|
||||
depends_on: []
|
||||
environment:
|
||||
EDITION: enterprise2
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
name: publish-github-public
|
||||
node:
|
||||
type: no-parallel
|
||||
platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
image: golang:1.19.3
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- ./bin/build artifacts docker fetch --edition enterprise2
|
||||
depends_on:
|
||||
- compile-build-cmd
|
||||
environment:
|
||||
DOCKER_PASSWORD:
|
||||
from_secret: docker_password
|
||||
DOCKER_USER:
|
||||
from_secret: docker_username
|
||||
GCP_KEY:
|
||||
from_secret: gcp_key
|
||||
image: google/cloud-sdk
|
||||
name: fetch-images-enterprise2
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- ./bin/build publish github --repo $${GH_REGISTRY} --create
|
||||
depends_on:
|
||||
- fetch-images-enterprise2
|
||||
environment:
|
||||
GH_REGISTRY:
|
||||
from_secret: gh_registry
|
||||
GH_TOKEN:
|
||||
from_secret: github_token
|
||||
image: grafana/grafana-ci-deploy:1.3.3
|
||||
name: publish-github
|
||||
trigger:
|
||||
event:
|
||||
- promote
|
||||
target:
|
||||
- public
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
depends_on: []
|
||||
environment:
|
||||
EDITION: enterprise2
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
name: publish-github-security
|
||||
node:
|
||||
type: no-parallel
|
||||
platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
image: golang:1.19.3
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- ./bin/build artifacts docker fetch --edition enterprise2
|
||||
depends_on:
|
||||
- compile-build-cmd
|
||||
environment:
|
||||
DOCKER_PASSWORD:
|
||||
from_secret: docker_password
|
||||
DOCKER_USER:
|
||||
from_secret: docker_username
|
||||
GCP_KEY:
|
||||
from_secret: gcp_key
|
||||
image: google/cloud-sdk
|
||||
name: fetch-images-enterprise2
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- ./bin/build publish github --repo $${GH_REGISTRY} --create
|
||||
depends_on:
|
||||
- fetch-images-enterprise2
|
||||
environment:
|
||||
GH_REGISTRY:
|
||||
from_secret: gh_registry
|
||||
GH_TOKEN:
|
||||
from_secret: github_token
|
||||
image: grafana/grafana-ci-deploy:1.3.3
|
||||
name: publish-github
|
||||
trigger:
|
||||
event:
|
||||
- promote
|
||||
target:
|
||||
- security
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
depends_on: []
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
@@ -5512,6 +5634,6 @@ kind: secret
|
||||
name: packages_secret_access_key
|
||||
---
|
||||
kind: signature
|
||||
hmac: 2b1b5ade4e8007a9d5b76ec2dbc9e647ca0938e00713b3ad8e8163bce2db40a6
|
||||
hmac: c2c81ccb90eff41fcf2929631f42c7d81d1d6b9965a39320be9f6da55128d2dd
|
||||
|
||||
...
|
||||
|
||||
@@ -200,9 +200,8 @@ func main() {
|
||||
Flags: []cli.Flag{
|
||||
&dryRunFlag,
|
||||
&cli.StringFlag{
|
||||
Name: "path",
|
||||
Required: true,
|
||||
Usage: "Path to the asset to be published",
|
||||
Name: "path",
|
||||
Usage: "Path to the asset to be published",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo",
|
||||
|
||||
@@ -114,6 +114,10 @@ func getFlags(ctx *cli.Context) (*publishGithubFlags, error) {
|
||||
name := strings.Split(fullRepo, "/")[1]
|
||||
create := ctx.Value("create").(bool)
|
||||
artifactPath := ctx.Value("path").(string)
|
||||
if artifactPath == "" {
|
||||
artifactPath = fmt.Sprintf("grafana-enterprise2-%s-amd64.img", metadata.GrafanaVersion)
|
||||
fmt.Printf("path argument is not provided, resolving to default %s...\n", artifactPath)
|
||||
}
|
||||
return &publishGithubFlags{
|
||||
artifactPath: artifactPath,
|
||||
create: create,
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
load(
|
||||
'scripts/drone/steps/lib.star',
|
||||
'download_grabpl_step',
|
||||
'publish_images_step',
|
||||
'compile_build_cmd',
|
||||
'fetch_images_step',
|
||||
'publish_image',
|
||||
)
|
||||
|
||||
load('scripts/drone/vault.star', 'from_secret')
|
||||
|
||||
load(
|
||||
'scripts/drone/utils/utils.star',
|
||||
'pipeline',
|
||||
)
|
||||
|
||||
def publish_github_step():
|
||||
return {
|
||||
'name': 'publish-github',
|
||||
'image': publish_image,
|
||||
'commands': ['./bin/build publish github --repo $${GH_REGISTRY} --create'],
|
||||
'depends_on': ['fetch-images-enterprise2'],
|
||||
'environment': {
|
||||
'GH_TOKEN': from_secret('github_token'),
|
||||
'GH_REGISTRY': from_secret('gh_registry'),
|
||||
},
|
||||
}
|
||||
|
||||
def publish_github_pipeline(mode):
|
||||
trigger = {
|
||||
'event': ['promote'],
|
||||
'target': [mode],
|
||||
}
|
||||
return [pipeline(
|
||||
name='publish-github-{}'.format(mode), trigger=trigger, steps=[compile_build_cmd(), fetch_images_step('enterprise2'), publish_github_step()], edition="", environment = {'EDITION': 'enterprise2'}
|
||||
),]
|
||||
Reference in New Issue
Block a user