Skip to content

Commit 24d348f

Browse files
authored
CI: Split /bin/build artifacts * subcommand (grafana#66005)
* Split go files * Modify publishartifacts.go * Split main * FIXME: Temp add GCSCopy to gcloud/storage * Fix lint * Exported flags * Update starlark - make drone * Further backend lint fixes * Add fallback_test.go * Fix go imports order * make drone * Remove GCSCopy from static assets * Remove GCSCopy from storybook * Fix lint * Remove GCSCopy * Remove success logline * drone yaml cleanup * Add artifacts-editions flag * Fix starlark * Add default sting slice in artifacts packages command
1 parent 1290dc8 commit 24d348f

File tree

11 files changed

+500
-187
lines changed

11 files changed

+500
-187
lines changed

.drone.yml

+38-5
Original file line numberDiff line numberDiff line change
@@ -4171,7 +4171,7 @@ steps:
41714171
image: golang:1.20.1
41724172
name: compile-build-cmd
41734173
- commands:
4174-
- ./bin/build artifacts publish --security --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}
4174+
- ./bin/build artifacts packages --security --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}
41754175
depends_on:
41764176
- compile-build-cmd
41774177
environment:
@@ -4183,10 +4183,21 @@ steps:
41834183
from_secret: prerelease_bucket
41844184
SECURITY_DEST_BUCKET:
41854185
from_secret: security_dest_bucket
4186+
image: grafana/grafana-ci-deploy:1.3.3
4187+
name: publish-artifacts
4188+
- commands:
4189+
- ./bin/build artifacts static-assets --tag ${DRONE_TAG}
4190+
depends_on:
4191+
- compile-build-cmd
4192+
environment:
4193+
GCP_KEY:
4194+
from_secret: gcp_key
4195+
PRERELEASE_BUCKET:
4196+
from_secret: prerelease_bucket
41864197
STATIC_ASSET_EDITIONS:
41874198
from_secret: static_asset_editions
41884199
image: grafana/grafana-ci-deploy:1.3.3
4189-
name: publish-artifacts
4200+
name: publish-static-assets
41904201
trigger:
41914202
event:
41924203
- promote
@@ -4222,7 +4233,7 @@ steps:
42224233
image: golang:1.20.1
42234234
name: compile-build-cmd
42244235
- commands:
4225-
- ./bin/build artifacts publish --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}
4236+
- ./bin/build artifacts packages --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}
42264237
depends_on:
42274238
- compile-build-cmd
42284239
environment:
@@ -4234,10 +4245,32 @@ steps:
42344245
from_secret: prerelease_bucket
42354246
SECURITY_DEST_BUCKET:
42364247
from_secret: security_dest_bucket
4248+
image: grafana/grafana-ci-deploy:1.3.3
4249+
name: publish-artifacts
4250+
- commands:
4251+
- ./bin/build artifacts static-assets --tag ${DRONE_TAG}
4252+
depends_on:
4253+
- compile-build-cmd
4254+
environment:
4255+
GCP_KEY:
4256+
from_secret: gcp_key
4257+
PRERELEASE_BUCKET:
4258+
from_secret: prerelease_bucket
42374259
STATIC_ASSET_EDITIONS:
42384260
from_secret: static_asset_editions
42394261
image: grafana/grafana-ci-deploy:1.3.3
4240-
name: publish-artifacts
4262+
name: publish-static-assets
4263+
- commands:
4264+
- ./bin/build artifacts storybook --tag ${DRONE_TAG}
4265+
depends_on:
4266+
- compile-build-cmd
4267+
environment:
4268+
GCP_KEY:
4269+
from_secret: gcp_key
4270+
PRERELEASE_BUCKET:
4271+
from_secret: prerelease_bucket
4272+
image: grafana/grafana-ci-deploy:1.3.3
4273+
name: publish-storybook
42414274
trigger:
42424275
event:
42434276
- promote
@@ -6753,6 +6786,6 @@ kind: secret
67536786
name: enterprise2_security_prefix
67546787
---
67556788
kind: signature
6756-
hmac: 54bded4dc7c3ffbbf3859a4f8f6364f59f3b6e0696152a0b835211eca7119e50
6789+
hmac: 421b968fc475a71ac3367a4f9d2da3b6ff68208c04d28d5fd1074cf03688a52a
67576790

67586791
...

pkg/build/cmd/flags.go

+18
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,22 @@ var (
5151
Name: "tag",
5252
Usage: "Grafana version tag",
5353
}
54+
securityFlag = cli.BoolFlag{
55+
Name: "security",
56+
Usage: "Security release",
57+
}
58+
srcFlag = cli.StringFlag{
59+
Name: "src-bucket",
60+
Value: "grafana-prerelease",
61+
Usage: "Google Cloud Storage bucket",
62+
}
63+
securityDestBucketFlag = cli.StringFlag{
64+
Name: "security-dest-bucket",
65+
Usage: "Google Cloud Storage bucket for security packages (or $SECURITY_DEST_BUCKET)",
66+
}
67+
destFlag = cli.StringFlag{
68+
Name: "dest-bucket",
69+
Value: "grafana-downloads",
70+
Usage: "Google Cloud Storage bucket for published packages",
71+
}
5472
)

pkg/build/cmd/main.go

+44-33
Original file line numberDiff line numberDiff line change
@@ -198,32 +198,57 @@ func main() {
198198
Usage: "Handle Grafana artifacts",
199199
Subcommands: cli.Commands{
200200
{
201-
Name: "publish",
202-
Usage: "Publish Grafana artifacts",
203-
Action: PublishArtifactsAction,
201+
Name: "storybook",
202+
Usage: "Publish Grafana storybook",
203+
Action: PublishStorybookAction,
204204
Flags: []cli.Flag{
205205
&editionFlag,
206-
&cli.BoolFlag{
207-
Name: "security",
208-
Usage: "Security release",
209-
},
206+
&tagFlag,
207+
&srcFlag,
210208
&cli.StringFlag{
211-
Name: "security-dest-bucket",
212-
Usage: "Google Cloud Storage bucket for security packages (or $SECURITY_DEST_BUCKET)",
209+
Name: "storybook-bucket",
210+
Value: "grafana-storybook",
211+
Usage: "Google Cloud Storage bucket for storybooks",
213212
},
213+
},
214+
},
215+
{
216+
Name: "static-assets",
217+
Usage: "Publish Grafana static assets",
218+
Action: PublishStaticAssetsAction,
219+
Flags: []cli.Flag{
220+
&editionFlag,
221+
&securityFlag,
222+
&securityDestBucketFlag,
223+
&tagFlag,
224+
&srcFlag,
225+
&destFlag,
214226
&cli.StringFlag{
215-
Name: "tag",
216-
Usage: "Grafana version tag",
227+
Name: "static-assets-bucket",
228+
Value: "grafana-static-assets",
229+
Usage: "Google Cloud Storage bucket for static assets",
217230
},
218-
&cli.StringFlag{
219-
Name: "src-bucket",
220-
Value: "grafana-prerelease",
221-
Usage: "Google Cloud Storage bucket",
231+
&cli.StringSliceFlag{
232+
Name: "static-asset-editions",
233+
Usage: "All the editions of the static assets (or $STATIC_ASSET_EDITIONS)",
222234
},
223-
&cli.StringFlag{
224-
Name: "dest-bucket",
225-
Value: "grafana-downloads",
226-
Usage: "Google Cloud Storage bucket for published packages",
235+
},
236+
},
237+
{
238+
Name: "packages",
239+
Usage: "Publish Grafana packages",
240+
Action: PublishArtifactsAction,
241+
Flags: []cli.Flag{
242+
&editionFlag,
243+
&securityFlag,
244+
&securityDestBucketFlag,
245+
&tagFlag,
246+
&srcFlag,
247+
&destFlag,
248+
&cli.StringSliceFlag{
249+
Name: "artifacts-editions",
250+
Value: cli.NewStringSlice("oss", "enterprise", "enterprise2"),
251+
Usage: "Editions for which the artifacts should be delivered (oss,enterprise,enterprise2), (or $ARTIFACTS_EDITIONS)",
227252
},
228253
&cli.StringFlag{
229254
Name: "enterprise2-dest-bucket",
@@ -234,20 +259,6 @@ func main() {
234259
Name: "enterprise2-security-prefix",
235260
Usage: "Bucket path prefix for enterprise2 security releases (or $ENTERPRISE2_SECURITY_PREFIX)",
236261
},
237-
&cli.StringFlag{
238-
Name: "static-assets-bucket",
239-
Value: "grafana-static-assets",
240-
Usage: "Google Cloud Storage bucket for static assets",
241-
},
242-
&cli.StringSliceFlag{
243-
Name: "static-asset-editions",
244-
Usage: "All the editions of the static assets (or $STATIC_ASSET_EDITIONS)",
245-
},
246-
&cli.StringFlag{
247-
Name: "storybook-bucket",
248-
Value: "grafana-storybook",
249-
Usage: "Google Cloud Storage bucket for storybooks",
250-
},
251262
},
252263
},
253264
{

0 commit comments

Comments
 (0)