From 40f695eecbcb4a0cd8ccbfa24aa00576c8c10f81 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Mon, 25 Mar 2024 15:29:12 -0600 Subject: [PATCH] ci: prepare 3.0 release workflow (#12344) Release-As: 3.0.0-alpha.1 --- .github/jsonnetfile.lock.json | 4 +-- .github/release-workflows.jsonnet | 4 +-- .../loki-release/workflows/build.libsonnet | 4 +-- .../loki-release/workflows/main.jsonnet | 6 ++++ .../loki-release/workflows/release.libsonnet | 7 ++-- .../loki-release/workflows/workflows.jsonnet | 33 +++++++++++++++++-- .github/workflows/minor-release-pr.yml | 28 +++++++++------- .github/workflows/patch-release-pr.yml | 27 ++++++++------- .github/workflows/release.yml | 4 ++- 9 files changed, 81 insertions(+), 36 deletions(-) diff --git a/.github/jsonnetfile.lock.json b/.github/jsonnetfile.lock.json index 7d51f277c194..3806723e517b 100644 --- a/.github/jsonnetfile.lock.json +++ b/.github/jsonnetfile.lock.json @@ -8,8 +8,8 @@ "subdir": "workflows" } }, - "version": "d9bfe17ed706fdfbd02445a576eb820dea4811a3", - "sum": "RCFmsb2FD3ZQmjSVfAo+5/GNi2mit/T9BZ474iE2u2o=" + "version": "d3fa90c124d13a4e0359a46c8708704e92ee8a50", + "sum": "TQ2X5sm7o+BCrytzSbJ7Th2YqNZ2ZPx9Wg62x5mEVJ0=" } ], "legacyImports": false diff --git a/.github/release-workflows.jsonnet b/.github/release-workflows.jsonnet index a5f0dde9093a..ff977b7f124e 100644 --- a/.github/release-workflows.jsonnet +++ b/.github/release-workflows.jsonnet @@ -46,7 +46,7 @@ local imagePrefix = 'grafana'; ), 'minor-release-pr.yml': std.manifestYamlDoc( lokiRelease.releasePRWorkflow( - branches=['k[0-9]+'], + branches=['k[0-9]+', 'main'], buildImage=buildImage, checkTemplate=checkTemplate, golangCiLintVersion=golangCiLintVersion, @@ -63,7 +63,7 @@ local imagePrefix = 'grafana'; ), 'release.yml': std.manifestYamlDoc( lokiRelease.releaseWorkflow( - branches=['release-[0-9]+.[0-9]+.x', 'k[0-9]+'], + branches=['release-[0-9]+.[0-9]+.x', 'k[0-9]+', 'main'], getDockerCredsFromVault=true, imagePrefix='grafana', releaseLibRef=releaseLibRef, diff --git a/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet b/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet index 1f0fd6382e81..6a2749b62ee2 100644 --- a/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet +++ b/.github/vendor/github.com/grafana/loki-release/workflows/build.libsonnet @@ -60,7 +60,7 @@ local releaseLibStep = common.releaseLibStep; + step.withIf('${{ fromJSON(needs.version.outputs.pr_created) }}') + step.with({ path: 'release/images/%s-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar' % name, - destination: 'loki-build-artifacts/${{ github.sha }}/images', //TODO: make bucket configurable + destination: '${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images', //TODO: make bucket configurable process_gcloudignore: false, }), ]), @@ -211,7 +211,7 @@ local releaseLibStep = common.releaseLibStep; + step.withIf('${{ fromJSON(needs.version.outputs.pr_created) }}') + step.with({ path: 'release/dist', - destination: 'loki-build-artifacts/${{ github.sha }}', //TODO: make bucket configurable + destination: '${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}', //TODO: make bucket configurable process_gcloudignore: false, }), ]), diff --git a/.github/vendor/github.com/grafana/loki-release/workflows/main.jsonnet b/.github/vendor/github.com/grafana/loki-release/workflows/main.jsonnet index a53d541a8a5a..fb401d315882 100644 --- a/.github/vendor/github.com/grafana/loki-release/workflows/main.jsonnet +++ b/.github/vendor/github.com/grafana/loki-release/workflows/main.jsonnet @@ -8,10 +8,12 @@ validateGel: import 'validate-gel.libsonnet', releasePRWorkflow: function( branches=['release-[0-9]+.[0-9]+.x', 'k[0-9]+'], + buildArtifactsBucket='loki-build-artifacts', buildImage='grafana/loki-build-image:0.33.0', changelogPath='CHANGELOG.md', checkTemplate='./.github/workflows/check.yml', distMakeTargets=['dist', 'packages'], + dryRun=false, dockerUsername='grafana', golangCiLintVersion='v1.55.1', imageBuildTimeoutMin=25, @@ -40,9 +42,11 @@ group: 'create-release-pr-${{ github.sha }}', }, env: { + BUILD_ARTIFACTS_BUCKET: buildArtifactsBucket, BUILD_TIMEOUT: imageBuildTimeoutMin, CHANGELOG_PATH: changelogPath, DOCKER_USERNAME: dockerUsername, + DRY_RUN: dryRun, IMAGE_PREFIX: imagePrefix, RELEASE_LIB_REF: releaseLibRef, RELEASE_REPO: releaseRepo, @@ -72,6 +76,7 @@ }, releaseWorkflow: function( branches=['release-[0-9].[0-9].x', 'k[0-9]*'], + buildArtifactsBucket='loki-build-artifacts', dockerUsername='grafanabot', getDockerCredsFromVault=false, imagePrefix='grafana', @@ -96,6 +101,7 @@ group: 'create-release-${{ github.sha }}', }, env: { + BUILD_ARTIFACTS_BUCKET: buildArtifactsBucket, IMAGE_PREFIX: imagePrefix, RELEASE_LIB_REF: releaseLibRef, RELEASE_REPO: releaseRepo, diff --git a/.github/vendor/github.com/grafana/loki-release/workflows/release.libsonnet b/.github/vendor/github.com/grafana/loki-release/workflows/release.libsonnet index 96edd7f422db..dc9978b2335d 100644 --- a/.github/vendor/github.com/grafana/loki-release/workflows/release.libsonnet +++ b/.github/vendor/github.com/grafana/loki-release/workflows/release.libsonnet @@ -9,7 +9,7 @@ local releaseLibStep = common.releaseLibStep; // sha to release and pull aritfacts from. If you need to change this, make sure // to change it in both places. //TODO: make bucket configurable -local pullRequestFooter = 'Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/loki-build-artifacts/${SHA}) of ${SHA}'; +local pullRequestFooter = 'Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/${BUILD_ARTIFACTS_BUCKET}/${SHA}) of ${SHA}'; { createReleasePR: @@ -45,7 +45,8 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https:// --separate-pull-requests false \ --target-branch "${{ steps.extract_branch.outputs.branch }}" \ --token "${{ steps.github_app_token.outputs.token }}" \ - --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" + --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" \ + --dry-run ${{ fromJSON(env.DRY_RUN) }} ||| % pullRequestFooter), ]), @@ -89,7 +90,7 @@ local pullRequestFooter = 'Merging this PR will release the [artifacts](https:// releaseStep('download binaries') + step.withRun(||| echo "downloading binaries to $(pwd)/dist" - gsutil cp -r gs://loki-build-artifacts/${{ needs.shouldRelease.outputs.sha }}/dist . + gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${{ needs.shouldRelease.outputs.sha }}/dist . |||), releaseStep('check if release exists') diff --git a/.github/vendor/github.com/grafana/loki-release/workflows/workflows.jsonnet b/.github/vendor/github.com/grafana/loki-release/workflows/workflows.jsonnet index 917c8a753478..1992d23f0d3b 100644 --- a/.github/vendor/github.com/grafana/loki-release/workflows/workflows.jsonnet +++ b/.github/vendor/github.com/grafana/loki-release/workflows/workflows.jsonnet @@ -6,23 +6,52 @@ local build = lokiRelease.build; imageJobs={ loki: build.image('fake-loki', 'cmd/loki'), }, + buildArtifactsBucket='loki-build-artifacts', branches=['release-[0-9]+.[0-9]+.x'], imagePrefix='trevorwhitney075', releaseLibRef='release-1.12.x', releaseRepo='grafana/loki-release', skipValidation=false, versioningStrategy='always-bump-patch', - ), false, false + ) + { + name: 'Create Release PR', + }, false, false + ), + '.github/workflows/test-release-pr.yml': std.manifestYamlDoc( + lokiRelease.releasePRWorkflow( + imageJobs={ + loki: build.image('fake-loki', 'cmd/loki'), + }, + buildArtifactsBucket='loki-build-artifacts', + branches=['release-[0-9]+.[0-9]+.x'], + dryRun=true, + imagePrefix='trevorwhitney075', + releaseLibRef='release-1.12.x', + releaseRepo='grafana/loki-release', + skipValidation=false, + versioningStrategy='always-bump-patch', + ) + { + name: 'Test Create Release PR Action', + on+: { + pull_request: {}, + }, + }, false, false ), '.github/workflows/release.yml': std.manifestYamlDoc( lokiRelease.releaseWorkflow( branches=['release-[0-9]+.[0-9]+.x'], + buildArtifactsBucket='loki-build-artifacts', getDockerCredsFromVault=true, imagePrefix='trevorwhitney075', releaseLibRef='release-1.12.x', releaseRepo='grafana/loki-release', useGitHubAppToken=false, - ), false, false + ) + { + name: 'Create Release', + on+: { + pull_request: {}, + }, + }, false, false ), '.github/workflows/check.yml': std.manifestYamlDoc( lokiRelease.check diff --git a/.github/workflows/minor-release-pr.yml b/.github/workflows/minor-release-pr.yml index adc01a54343a..2704a770dbf9 100644 --- a/.github/workflows/minor-release-pr.yml +++ b/.github/workflows/minor-release-pr.yml @@ -1,9 +1,11 @@ concurrency: group: "create-release-pr-${{ github.sha }}" env: + BUILD_ARTIFACTS_BUCKET: "loki-build-artifacts" BUILD_TIMEOUT: 40 CHANGELOG_PATH: "CHANGELOG.md" DOCKER_USERNAME: "grafana" + DRY_RUN: false IMAGE_PREFIX: "grafana" RELEASE_LIB_REF: "main" RELEASE_REPO: "grafana/loki" @@ -81,14 +83,15 @@ jobs: --group-pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \ --label "backport main,autorelease: pending,product-approved" \ --manifest-file .release-please-manifest.json \ - --pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/loki-build-artifacts/${SHA}) of ${SHA}" \ + --pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/${BUILD_ARTIFACTS_BUCKET}/${SHA}) of ${SHA}" \ --pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \ --release-type simple \ --repo-url "${{ env.RELEASE_REPO }}" \ --separate-pull-requests false \ --target-branch "${{ steps.extract_branch.outputs.branch }}" \ --token "${{ steps.github_app_token.outputs.token }}" \ - --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" + --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" \ + --dry-run ${{ fromJSON(env.DRY_RUN) }} working-directory: "lib" dist: @@ -146,7 +149,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}" path: "release/dist" process_gcloudignore: false fluent-bit: @@ -203,7 +206,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/fluent-bit-plugin-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -265,7 +268,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/fluent-plugin-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -327,7 +330,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/logcli-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -391,7 +394,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/logstash-output-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -453,7 +456,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -517,7 +520,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-canary-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -581,7 +584,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-canary-boringcrypto-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -645,7 +648,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/promtail-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -709,7 +712,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-query-tee-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -801,6 +804,7 @@ name: "create release PR" push: branches: - "k[0-9]+" + - "main" permissions: contents: "write" id-token: "write" diff --git a/.github/workflows/patch-release-pr.yml b/.github/workflows/patch-release-pr.yml index cf5119cf4301..a388035df98c 100644 --- a/.github/workflows/patch-release-pr.yml +++ b/.github/workflows/patch-release-pr.yml @@ -1,9 +1,11 @@ concurrency: group: "create-release-pr-${{ github.sha }}" env: + BUILD_ARTIFACTS_BUCKET: "loki-build-artifacts" BUILD_TIMEOUT: 40 CHANGELOG_PATH: "CHANGELOG.md" DOCKER_USERNAME: "grafana" + DRY_RUN: false IMAGE_PREFIX: "grafana" RELEASE_LIB_REF: "main" RELEASE_REPO: "grafana/loki" @@ -81,14 +83,15 @@ jobs: --group-pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \ --label "backport main,autorelease: pending,product-approved" \ --manifest-file .release-please-manifest.json \ - --pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/loki-build-artifacts/${SHA}) of ${SHA}" \ + --pull-request-footer "Merging this PR will release the [artifacts](https://console.cloud.google.com/storage/browser/${BUILD_ARTIFACTS_BUCKET}/${SHA}) of ${SHA}" \ --pull-request-title-pattern "chore\${scope}: release\${component} \${version}" \ --release-type simple \ --repo-url "${{ env.RELEASE_REPO }}" \ --separate-pull-requests false \ --target-branch "${{ steps.extract_branch.outputs.branch }}" \ --token "${{ steps.github_app_token.outputs.token }}" \ - --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" + --versioning-strategy "${{ env.VERSIONING_STRATEGY }}" \ + --dry-run ${{ fromJSON(env.DRY_RUN) }} working-directory: "lib" dist: @@ -146,7 +149,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}" path: "release/dist" process_gcloudignore: false fluent-bit: @@ -203,7 +206,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/fluent-bit-plugin-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -265,7 +268,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/fluent-plugin-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -327,7 +330,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/logcli-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -391,7 +394,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/logstash-output-loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -453,7 +456,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -517,7 +520,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-canary-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -581,7 +584,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-canary-boringcrypto-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -645,7 +648,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/promtail-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: @@ -709,7 +712,7 @@ jobs: name: "upload artifacts" uses: "google-github-actions/upload-cloud-storage@v2" with: - destination: "loki-build-artifacts/${{ github.sha }}/images" + destination: "${{ env.BUILD_ARTIFACTS_BUCKET }}/${{ github.sha }}/images" path: "release/images/loki-query-tee-${{ needs.version.outputs.version}}-${{ steps.platform.outputs.platform }}.tar" process_gcloudignore: false strategy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69909c242ebe..cecbee6513b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ concurrency: group: "create-release-${{ github.sha }}" env: + BUILD_ARTIFACTS_BUCKET: "loki-build-artifacts" IMAGE_PREFIX: "grafana" PUBLISH_TO_GCS: false RELEASE_LIB_REF: "main" @@ -61,7 +62,7 @@ jobs: - name: "download binaries" run: | echo "downloading binaries to $(pwd)/dist" - gsutil cp -r gs://loki-build-artifacts/${{ needs.shouldRelease.outputs.sha }}/dist . + gsutil cp -r gs://${BUILD_ARTIFACTS_BUCKET}/${{ needs.shouldRelease.outputs.sha }}/dist . working-directory: "release" - env: GH_TOKEN: "${{ steps.github_app_token.outputs.token }}" @@ -214,6 +215,7 @@ name: "create release" branches: - "release-[0-9]+.[0-9]+.x" - "k[0-9]+" + - "main" permissions: contents: "write" id-token: "write"