diff --git a/.drone.yml b/.drone.yml index e5b2230ce8ead..380954e73ae9d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6750,7 +6750,7 @@ volumes: ################################################ # Generated using dronegen, do not edit by hand! # Use 'make dronegen' to update. -# Generated at dronegen/os_repos.go:250 +# Generated at dronegen/os_repos.go:253 ################################################ kind: pipeline @@ -6778,7 +6778,7 @@ steps: ################################################ # Generated using dronegen, do not edit by hand! # Use 'make dronegen' to update. -# Generated at dronegen/os_repos.go:274 +# Generated at dronegen/os_repos.go:277 ################################################ kind: pipeline @@ -6812,16 +6812,6 @@ steps: - git init && git remote add origin ${DRONE_REMOTE_URL} - git fetch origin --tags - git checkout -qf "${DRONE_TAG}" - depends_on: - - Verify build is tagged -- name: Check if tag is prerelease - image: golang:1.18-alpine - commands: - - cd "/go/src/github.com/gravitational/teleport/build.assets/tooling" - - go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is - a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78) - depends_on: - - Check out code - name: Assume Download AWS Role image: amazon/aws-cli commands: @@ -6849,12 +6839,11 @@ steps: depends_on: - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Download artifacts for "${DRONE_TAG}" image: amazon/aws-cli commands: - mkdir -pv "$ARTIFACT_PATH" - - rm -rf "$ARTIFACT_PATH/*" + - rm -rf "$ARTIFACT_PATH"/* - aws s3 sync --no-progress --delete --exclude "*" --include "*.deb*" s3://$AWS_S3_BUCKET/teleport/tag/${DRONE_TAG##v}/ "$ARTIFACT_PATH" environment: @@ -6865,9 +6854,9 @@ steps: - name: awsconfig path: /root/.aws depends_on: + - Assume Download AWS Role - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Assume Upload AWS Role image: amazon/aws-cli commands: @@ -6893,9 +6882,19 @@ steps: - name: awsconfig path: /root/.aws depends_on: + - Download artifacts for "${DRONE_TAG}" + - Verify build is tagged + - Check out code +- name: Check if tag is prerelease + image: golang:1.18-alpine + commands: + - cd "/go/src/github.com/gravitational/teleport/build.assets/tooling" + - go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is + a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78) + depends_on: + - Assume Upload AWS Role - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Publish debs to APT repos for "${DRONE_TAG}" image: golang:1.18.4-bullseye commands: @@ -6929,10 +6928,9 @@ steps: - name: awsconfig path: /root/.aws depends_on: - - Download artifacts for "${DRONE_TAG}" + - Check if tag is prerelease - Verify build is tagged - Check out code - - Check if tag is prerelease volumes: - name: apt-persistence claim: @@ -6947,7 +6945,7 @@ volumes: ################################################ # Generated using dronegen, do not edit by hand! # Use 'make dronegen' to update. -# Generated at dronegen/os_repos.go:250 +# Generated at dronegen/os_repos.go:253 ################################################ kind: pipeline @@ -6975,7 +6973,7 @@ steps: ################################################ # Generated using dronegen, do not edit by hand! # Use 'make dronegen' to update. -# Generated at dronegen/os_repos.go:274 +# Generated at dronegen/os_repos.go:277 ################################################ kind: pipeline @@ -7009,16 +7007,6 @@ steps: - git init && git remote add origin ${DRONE_REMOTE_URL} - git fetch origin --tags - git checkout -qf "${DRONE_TAG}" - depends_on: - - Verify build is tagged -- name: Check if tag is prerelease - image: golang:1.18-alpine - commands: - - cd "/go/src/github.com/gravitational/teleport/build.assets/tooling" - - go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is - a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78) - depends_on: - - Check out code - name: Assume Download AWS Role image: amazon/aws-cli commands: @@ -7046,12 +7034,11 @@ steps: depends_on: - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Download artifacts for "${DRONE_TAG}" image: amazon/aws-cli commands: - mkdir -pv "$ARTIFACT_PATH" - - rm -rf "$ARTIFACT_PATH/*" + - rm -rf "$ARTIFACT_PATH"/* - aws s3 sync --no-progress --delete --exclude "*" --include "*.rpm*" s3://$AWS_S3_BUCKET/teleport/tag/${DRONE_TAG##v}/ "$ARTIFACT_PATH" environment: @@ -7062,9 +7049,9 @@ steps: - name: awsconfig path: /root/.aws depends_on: + - Assume Download AWS Role - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Assume Upload AWS Role image: amazon/aws-cli commands: @@ -7090,9 +7077,19 @@ steps: - name: awsconfig path: /root/.aws depends_on: + - Download artifacts for "${DRONE_TAG}" + - Verify build is tagged + - Check out code +- name: Check if tag is prerelease + image: golang:1.18-alpine + commands: + - cd "/go/src/github.com/gravitational/teleport/build.assets/tooling" + - go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is + a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78) + depends_on: + - Assume Upload AWS Role - Verify build is tagged - Check out code - - Check if tag is prerelease - name: Publish rpms to YUM repos for "${DRONE_TAG}" image: golang:1.18.4-bullseye commands: @@ -7127,10 +7124,9 @@ steps: - name: awsconfig path: /root/.aws depends_on: - - Download artifacts for "${DRONE_TAG}" + - Check if tag is prerelease - Verify build is tagged - Check out code - - Check if tag is prerelease volumes: - name: yum-persistence claim: @@ -8007,6 +8003,6 @@ volumes: temp: {} --- kind: signature -hmac: 0d3063844a5f8bf25043a691517ab358dc32739e233b593267f1a0fec96351c5 +hmac: 9063bb609685ab20fc323ed494bab70ed5ea49593cf84458c14cc94afcacceec ... diff --git a/dronegen/common.go b/dronegen/common.go index c4de7725953f8..dd01c12c22fe9 100644 --- a/dronegen/common.go +++ b/dronegen/common.go @@ -232,19 +232,6 @@ func waitForDockerStep() step { } } -func verifyValidPromoteRunSteps(checkoutPath, commit string, isParallelismEnabled bool) []step { - tagStep := verifyTaggedStep() - cloneStep := cloneRepoStep(checkoutPath, commit) - verifyStep := verifyNotPrereleaseStep(checkoutPath) - - if isParallelismEnabled { - cloneStep.DependsOn = []string{tagStep.Name} - verifyStep.DependsOn = []string{cloneStep.Name} - } - - return []step{tagStep, cloneStep, verifyStep} -} - func verifyTaggedStep() step { return step{ Name: "Verify build is tagged", diff --git a/dronegen/os_repos.go b/dronegen/os_repos.go index d2ded7eceb330..8ae742f2323ab 100644 --- a/dronegen/os_repos.go +++ b/dronegen/os_repos.go @@ -191,7 +191,10 @@ func (optpb *OsPackageToolPipelineBuilder) buildPromoteOsPackagePipeline() pipel p.Trigger = triggerPromote p.Trigger.Repo.Include = []string{"gravitational/teleport"} - setupSteps := verifyValidPromoteRunSteps(checkoutPath, commitName, true) + setupSteps := []step{ + verifyTaggedStep(), + cloneRepoStep(checkoutPath, commitName), + } setupStepNames := make([]string, 0, len(setupSteps)) for _, setupStep := range setupSteps { @@ -354,12 +357,6 @@ func (optpb *OsPackageToolPipelineBuilder) getVersionSteps(codePath, version str } toolSetupCommands = append(toolSetupCommands, optpb.setupCommands...) - downloadStepName := fmt.Sprintf("Download artifacts for %q", version) - buildStepDependencies := []string{} - if enableParallelism { - buildStepDependencies = append(buildStepDependencies, downloadStepName) - } - assumeDownloadRoleStep := kubernetesAssumeAwsRoleStep(kubernetesRoleSettings{ awsRoleSettings: awsRoleSettings{ awsAccessKeyID: value{fromSecret: "AWS_ACCESS_KEY_ID"}, @@ -370,86 +367,99 @@ func (optpb *OsPackageToolPipelineBuilder) getVersionSteps(codePath, version str name: "Assume Download AWS Role", }) + downloadStep := step{ + Name: fmt.Sprintf("Download artifacts for %q", version), + Image: "amazon/aws-cli", + Environment: map[string]value{ + "AWS_S3_BUCKET": { + fromSecret: "AWS_S3_BUCKET", + }, + "ARTIFACT_PATH": { + raw: optpb.artifactPath, + }, + }, + Volumes: []volumeRef{volumeRefAwsConfig}, + Commands: []string{ + "mkdir -pv \"$ARTIFACT_PATH\"", + // Clear out old versions from previous steps + "rm -rf \"$ARTIFACT_PATH\"/*", + strings.Join( + []string{ + "aws s3 sync", + "--no-progress", + "--delete", + "--exclude \"*\"", + fmt.Sprintf("--include \"*.%s*\"", optpb.packageType), + fmt.Sprintf("s3://$AWS_S3_BUCKET/teleport/tag/%s/", bucketFolder), + "\"$ARTIFACT_PATH\"", + }, + " ", + ), + }, + } + assumeUploadRoleStep := kubernetesAssumeAwsRoleStep(kubernetesRoleSettings{ awsRoleSettings: optpb.bucketSecrets.awsRoleSettings, configVolume: volumeRefAwsConfig, name: "Assume Upload AWS Role", }) - return []step{ - assumeDownloadRoleStep, - { - Name: downloadStepName, - Image: "amazon/aws-cli", - Environment: map[string]value{ - "AWS_S3_BUCKET": { - fromSecret: "AWS_S3_BUCKET", - }, - "ARTIFACT_PATH": { - raw: optpb.artifactPath, - }, - }, - Volumes: []volumeRef{volumeRefAwsConfig}, - Commands: []string{ - "mkdir -pv \"$ARTIFACT_PATH\"", - // Clear out old versions from previous steps - "rm -rf \"$ARTIFACT_PATH/*\"", + verifyNotPrereleaseStep := verifyNotPrereleaseStep(codePath) + + buildAndUploadStep := step{ + Name: fmt.Sprintf("Publish %ss to %s repos for %q", optpb.packageType, strings.ToUpper(optpb.packageManagerName), version), + Image: "golang:1.18.4-bullseye", + Environment: optpb.environmentVars, + Commands: append( + toolSetupCommands, + []string{ + "mkdir -pv -m0700 \"$GNUPGHOME\"", + "echo \"$GPG_RPM_SIGNING_ARCHIVE\" | base64 -d | tar -xzf - -C $GNUPGHOME", + "chown -R root:root \"$GNUPGHOME\"", + fmt.Sprintf("cd %q", path.Join(codePath, "build.assets", "tooling")), + fmt.Sprintf("export VERSION=%q", version), + "export RELEASE_CHANNEL=\"stable\"", // The tool supports several release channels but I'm not sure where this should be configured strings.Join( - []string{ - "aws s3 sync", - "--no-progress", - "--delete", - "--exclude \"*\"", - fmt.Sprintf("--include \"*.%s*\"", optpb.packageType), - fmt.Sprintf("s3://$AWS_S3_BUCKET/teleport/tag/%s/", bucketFolder), - "\"$ARTIFACT_PATH\"", - }, + append( + []string{ + // This just makes the (long) command a little more readable + "go run ./cmd/build-os-package-repos", + optpb.packageManagerName, + "-bucket \"$REPO_S3_BUCKET\"", + "-local-bucket-path \"$BUCKET_CACHE_PATH\"", + "-artifact-version \"$VERSION\"", + "-release-channel \"$RELEASE_CHANNEL\"", + "-artifact-path \"$ARTIFACT_PATH\"", + "-log-level 4", // Set this to 5 for debug logging + }, + optpb.extraArgs..., + ), " ", ), + }..., + ), + Volumes: []volumeRef{ + { + Name: optpb.volumeName, + Path: optpb.pvcMountPoint, }, + volumeRefTmpfs, + volumeRefAwsConfig, }, + } + + if enableParallelism { + downloadStep.DependsOn = []string{assumeDownloadRoleStep.Name} + assumeUploadRoleStep.DependsOn = []string{downloadStep.Name} + verifyNotPrereleaseStep.DependsOn = []string{assumeUploadRoleStep.Name} + buildAndUploadStep.DependsOn = []string{verifyNotPrereleaseStep.Name} + } + + return []step{ + assumeDownloadRoleStep, + downloadStep, assumeUploadRoleStep, - { - Name: fmt.Sprintf("Publish %ss to %s repos for %q", optpb.packageType, strings.ToUpper(optpb.packageManagerName), version), - Image: "golang:1.18.4-bullseye", - Environment: optpb.environmentVars, - Commands: append( - toolSetupCommands, - []string{ - "mkdir -pv -m0700 \"$GNUPGHOME\"", - "echo \"$GPG_RPM_SIGNING_ARCHIVE\" | base64 -d | tar -xzf - -C $GNUPGHOME", - "chown -R root:root \"$GNUPGHOME\"", - fmt.Sprintf("cd %q", path.Join(codePath, "build.assets", "tooling")), - fmt.Sprintf("export VERSION=%q", version), - "export RELEASE_CHANNEL=\"stable\"", // The tool supports several release channels but I'm not sure where this should be configured - strings.Join( - append( - []string{ - // This just makes the (long) command a little more readable - "go run ./cmd/build-os-package-repos", - optpb.packageManagerName, - "-bucket \"$REPO_S3_BUCKET\"", - "-local-bucket-path \"$BUCKET_CACHE_PATH\"", - "-artifact-version \"$VERSION\"", - "-release-channel \"$RELEASE_CHANNEL\"", - "-artifact-path \"$ARTIFACT_PATH\"", - "-log-level 4", // Set this to 5 for debug logging - }, - optpb.extraArgs..., - ), - " ", - ), - }..., - ), - Volumes: []volumeRef{ - { - Name: optpb.volumeName, - Path: optpb.pvcMountPoint, - }, - volumeRefTmpfs, - volumeRefAwsConfig, - }, - DependsOn: buildStepDependencies, - }, + verifyNotPrereleaseStep, + buildAndUploadStep, } }