From 428d8626130f6096724fbbdff426929ed843859f Mon Sep 17 00:00:00 2001 From: Ivo Jimenez Date: Wed, 30 Aug 2023 01:39:42 -0400 Subject: [PATCH 1/4] goreleaser: consolidate config in a single file Avoid creating duplicate github releases when a tagged commit is pushed to github and corresponding rpk CI workflow gets executed. Signed-off-by: Ivo Jimenez (cherry picked from commit 7f754a03d341ec7aecb741f146535241be1352b2) --- src/go/{rpk => }/.goreleaser.yaml | 50 +++++++++++++++-- .../.goreleaser.yaml | 53 ------------------- 2 files changed, 46 insertions(+), 57 deletions(-) rename src/go/{rpk => }/.goreleaser.yaml (68%) delete mode 100644 src/go/cluster-to-redpanda-migration/.goreleaser.yaml diff --git a/src/go/rpk/.goreleaser.yaml b/src/go/.goreleaser.yaml similarity index 68% rename from src/go/rpk/.goreleaser.yaml rename to src/go/.goreleaser.yaml index eb96339ebb12..865634cf52e7 100644 --- a/src/go/rpk/.goreleaser.yaml +++ b/src/go/.goreleaser.yaml @@ -1,6 +1,7 @@ project_name: rpk builds: - - id: windows-and-linux + - id: rpk-windows-and-linux + dir: ./rpk/ main: ./cmd/rpk binary: rpk ldflags: @@ -16,7 +17,8 @@ builds: - amd64 - arm64 # we need separate build for darwin to sign/notarize using quill - - id: darwin + - id: rpk-darwin + dir: ./rpk/ main: ./cmd/rpk binary: rpk ldflags: @@ -40,13 +42,51 @@ builds: - cmd: quill sign-and-notarize "{{ .Path }}" --dry-run={{ .IsSnapshot }} --ad-hoc={{ .IsSnapshot }} -vv env: - QUILL_LOG_FILE=dist/quill-{{ .Target }}.log + - id: migration-tool-windows-and-linux + dir: ./cluster-to-redpanda-migration/ + main: ./main.go + binary: cluster-to-redpanda-migration + ldflags: + - -X github.com/redpanda-data/redpanda/src/go/cluster-to-redpanda-migration/cmd/version.version={{.Tag}} + env: + - CGO_ENABLED=0 + goos: + - windows + - linux + goarch: + - amd64 + - arm64 + - id: migration-tool-darwin + dir: ./cluster-to-redpanda-migration/ + main: ./main.go + binary: cluster-to-redpanda-migration + ldflags: + - -X github.com/redpanda-data/redpanda/src/go/cluster-to-redpanda-migration/cmd/version.version={{.Tag}} + env: + - CGO_ENABLED=0 + goos: + - darwin + goarch: + - amd64 + - arm64 + hooks: + post: + - cmd: quill sign-and-notarize "{{ .Path }}" --dry-run={{ .IsSnapshot }} --ad-hoc={{ .IsSnapshot }} -vv + env: + - QUILL_LOG_FILE=dist/quill-{{ .Target }}.log archives: - id: rpk builds: - - windows-and-linux - - darwin + - rpk-windows-and-linux + - rpk-darwin format: zip name_template: "rpk-{{ .Os }}-{{ .Arch }}" + - id: migration-tool + builds: + - migration-tool-windows-and-linux + - migration-tool-darwin + format: zip + name_template: "cluster-to-redpanda-migration-{{ .Os }}-{{ .Arch }}" release: github: owner: redpanda-data @@ -62,6 +102,8 @@ brews: name: homebrew-tap folder: Formula skip_upload: auto + ids: + - rpk caveats: | Redpanda Keeper (rpk) is Redpanda's command line interface (CLI) utility. The rpk commands let you configure, manage, and tune diff --git a/src/go/cluster-to-redpanda-migration/.goreleaser.yaml b/src/go/cluster-to-redpanda-migration/.goreleaser.yaml deleted file mode 100644 index ea66dd51fdbf..000000000000 --- a/src/go/cluster-to-redpanda-migration/.goreleaser.yaml +++ /dev/null @@ -1,53 +0,0 @@ -project_name: cluster-to-redpanda-migration -builds: - - id: windows-and-linux - main: ./main.go - binary: cluster-to-redpanda-migration - ldflags: - - -X github.com/redpanda-data/redpanda/src/go/cluster-to-redpanda-migration/cmd/version.version={{.Tag}} - env: - - CGO_ENABLED=0 - goos: - - windows - - linux - goarch: - - amd64 - - arm64 - # we need separate build for darwin to sign/notarize using quill - - id: darwin - main: ./main.go - binary: cluster-to-redpanda-migration - ldflags: - - -X github.com/redpanda-data/redpanda/src/go/cluster-to-redpanda-migration/cmd/version.version={{.Tag}} - env: - - CGO_ENABLED=0 - goos: - - darwin - goarch: - - amd64 - - arm64 - hooks: - post: - # The binary is signed and notarized when running a production release, but for snapshot builds notarization is - # skipped and only ad-hoc signing is performed (not cryptographic material is needed). - # - # note: environment variables required for signing and notarization (set in CI) but are not needed for snapshot builds - # QUILL_SIGN_P12, QUILL_SIGN_PASSWORD, QUILL_NOTARY_KEY, QUILL_NOTARY_KEY_ID, QUILL_NOTARY_ISSUER - - cmd: quill sign-and-notarize "{{ .Path }}" --dry-run={{ .IsSnapshot }} --ad-hoc={{ .IsSnapshot }} -vv - env: - - QUILL_LOG_FILE=dist/quill-{{ .Target }}.log -archives: - - id: cluster-to-redpanda-migration - builds: - - windows-and-linux - - darwin - format: zip - name_template: "cluster-to-redpanda-migration-{{ .Os }}-{{ .Arch }}" -release: - github: - owner: redpanda-data - name: redpanda - draft: true - discussion_category_name: Releases -announce: - skip: "true" From 41efda50397c5fcd2b1a17b0f0517a5891ce97ee Mon Sep 17 00:00:00 2001 From: Ivo Jimenez Date: Wed, 30 Aug 2023 01:45:10 -0400 Subject: [PATCH 2/4] goreleaser: change deprecated option Replaces `brew.tap` with `brew.repository` Signed-off-by: Ivo Jimenez (cherry picked from commit f31ae78a199e4a6dfd76240de4811bfd9a27777d) --- src/go/.goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/.goreleaser.yaml b/src/go/.goreleaser.yaml index 865634cf52e7..299bcddd8c08 100644 --- a/src/go/.goreleaser.yaml +++ b/src/go/.goreleaser.yaml @@ -97,7 +97,7 @@ brews: - name: redpanda homepage: "https://redpanda.com" description: "Redpanda CLI & toolbox" - tap: + repository: owner: redpanda-data name: homebrew-tap folder: Formula From b54b015ff6c57791e944b9eeb38db8b401e75425 Mon Sep 17 00:00:00 2001 From: Ivo Jimenez Date: Wed, 30 Aug 2023 03:16:16 -0400 Subject: [PATCH 3/4] gha: remove release jobs from these workflows This job will be moved to a separate workflow file Signed-off-by: Ivo Jimenez (cherry picked from commit 44665c6572a145621aa41740087701210b9bbd80) --- .../workflows/redpanda-migration-build.yml | 62 ------------------ .github/workflows/rpk-build.yml | 64 ------------------- 2 files changed, 126 deletions(-) diff --git a/.github/workflows/redpanda-migration-build.yml b/.github/workflows/redpanda-migration-build.yml index 9c484cc03122..c871475bd7ec 100644 --- a/.github/workflows/redpanda-migration-build.yml +++ b/.github/workflows/redpanda-migration-build.yml @@ -10,8 +10,6 @@ name: cluster-to-redpanda-migration on: push: - tags: - - 'v2**' branches: - '*' pull_request: @@ -41,64 +39,4 @@ jobs: working-directory: src/go/cluster-to-redpanda-migration/ run: go test -v ./... - release: - name: Release using goreleaser - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install quill - run: | - mkdir -p "$HOME/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b "$HOME/.local/bin" v0.2.0 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: stable - - - name: Create empty release notes - run: | - echo "" > /tmp/empty_notes - - name: Invoke goreleaser - uses: goreleaser/goreleaser-action@v4 - env: - QUILL_SIGN_P12: ${{ secrets.QUILL_SIGN_P12_BASE64 }} - QUILL_SIGN_PASSWORD: ${{ secrets.QUILL_SIGN_PASSWORD }} - QUILL_NOTARY_KEY_ID: ${{ secrets.QUILL_NOTARY_KEY_ID }} - QUILL_NOTARY_KEY: ${{ secrets.QUILL_NOTARY_KEY_BASE64 }} - QUILL_NOTARY_ISSUER: ${{ secrets.QUILL_NOTARY_ISSUER }} - GITHUB_TOKEN: ${{ secrets.VBOT_GITHUB_API_TOKEN }} - GORELEASER_CURRENT_TAG: ${{ github.ref_name }} - with: - distribution: goreleaser - version: ${{ env.GITHUB_REF_NAME }} - workdir: src/go/cluster-to-redpanda-migration/ - args: release --clean --release-notes /tmp/empty_notes - - - name: Archive quill output - if: failure() - uses: actions/upload-artifact@v3 - with: - name: quill-logs - path: src/go/cluster-to-redpanda-migration/dist/quill-*.log - - notify-release-failure: - name: Notify of release failures - runs-on: ubuntu-latest - if: failure() - needs: [release] - steps: - - name: Notify release failure - uses: slackapi/slack-github-action@v1.21.0 - with: - channel-id: ${{ secrets.INTERNAL_RELEASES_SLACK_CHANNEL }} - slack-message: "ERROR: release of `cluster-to-redpanda-migration` binaries for `${{ github.ref_name }}` failed in ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.VBOTBUILDOVICH_SLACK_BOT_TOKEN }} diff --git a/.github/workflows/rpk-build.yml b/.github/workflows/rpk-build.yml index de042d523d5a..e178e97da6a5 100644 --- a/.github/workflows/rpk-build.yml +++ b/.github/workflows/rpk-build.yml @@ -10,8 +10,6 @@ name: rpk on: push: - tags: - - 'v2**' branches: - '*' pull_request: @@ -40,65 +38,3 @@ jobs: - name: Run tests working-directory: src/go/rpk/ run: go test -v ./... - - release: - name: Release using goreleaser - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install quill - run: | - mkdir -p "$HOME/.local/bin" - echo "$HOME/.local/bin" >> $GITHUB_PATH - curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b "$HOME/.local/bin" v0.4.1 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: stable - - - name: Create empty release notes - run: | - echo "" > /tmp/empty_notes - - - name: Invoke goreleaser - uses: goreleaser/goreleaser-action@v4 - env: - QUILL_SIGN_P12: ${{ secrets.QUILL_SIGN_P12_BASE64 }} - QUILL_SIGN_PASSWORD: ${{ secrets.QUILL_SIGN_PASSWORD }} - QUILL_NOTARY_KEY_ID: ${{ secrets.QUILL_NOTARY_KEY_ID }} - QUILL_NOTARY_KEY: ${{ secrets.QUILL_NOTARY_KEY_BASE64 }} - QUILL_NOTARY_ISSUER: ${{ secrets.QUILL_NOTARY_ISSUER }} - GITHUB_TOKEN: ${{ secrets.VBOT_GITHUB_API_TOKEN }} - GORELEASER_CURRENT_TAG: ${{ github.ref_name }} - with: - distribution: goreleaser - version: ${{ env.GITHUB_REF_NAME }} - workdir: src/go/rpk/ - args: release --clean --release-notes /tmp/empty_notes - - - name: Archive quill output - if: failure() - uses: actions/upload-artifact@v3 - with: - name: quill-logs - path: src/go/rpk/dist/quill-*.log - - notify-release-failure: - name: Notify of release failures - runs-on: ubuntu-latest - if: failure() - needs: [release] - steps: - - name: Notify release failure - uses: slackapi/slack-github-action@v1.21.0 - with: - channel-id: ${{ secrets.INTERNAL_RELEASES_SLACK_CHANNEL }} - slack-message: "ERROR: release of `rpk` binaries for `${{ github.ref_name }}` failed in ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.VBOTBUILDOVICH_SLACK_BOT_TOKEN }} From 717e90a7feae254ae192a7a13351eda762f894aa Mon Sep 17 00:00:00 2001 From: Ivo Jimenez Date: Wed, 30 Aug 2023 03:16:44 -0400 Subject: [PATCH 4/4] gha: separate workflow for release of go binaries Now that there is a single goreleaser configuration, a separate workflow can be used to consolidate the creation of these golang-based binaries Signed-off-by: Ivo Jimenez (cherry picked from commit 744729030ddde503b25bfe41a0cadd276e16cfe9) --- .github/workflows/golang-binaries-release.yml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/golang-binaries-release.yml diff --git a/.github/workflows/golang-binaries-release.yml b/.github/workflows/golang-binaries-release.yml new file mode 100644 index 000000000000..5adfc5407b81 --- /dev/null +++ b/.github/workflows/golang-binaries-release.yml @@ -0,0 +1,77 @@ +# Copyright 2023 Redpanda Data, Inc. +# +# Use of this software is governed by the Business Source License +# included in the file licenses/BSL.md +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0 + +name: release-go-binaries +on: + push: + tags: + - 'v2**' + +jobs: + release: + name: Release using goreleaser + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install quill + run: | + mkdir -p "$HOME/.local/bin" + echo "$HOME/.local/bin" >> $GITHUB_PATH + curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b "$HOME/.local/bin" v0.4.1 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: stable + + - name: Create empty release notes + run: | + echo "" > /tmp/empty_notes + + - name: Invoke goreleaser + uses: goreleaser/goreleaser-action@v4 + env: + QUILL_SIGN_P12: ${{ secrets.QUILL_SIGN_P12_BASE64 }} + QUILL_SIGN_PASSWORD: ${{ secrets.QUILL_SIGN_PASSWORD }} + QUILL_NOTARY_KEY_ID: ${{ secrets.QUILL_NOTARY_KEY_ID }} + QUILL_NOTARY_KEY: ${{ secrets.QUILL_NOTARY_KEY_BASE64 }} + QUILL_NOTARY_ISSUER: ${{ secrets.QUILL_NOTARY_ISSUER }} + GITHUB_TOKEN: ${{ secrets.VBOT_GITHUB_API_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ github.ref_name }} + with: + distribution: goreleaser + version: ${{ env.GITHUB_REF_NAME }} + workdir: src/go/ + args: release --clean --release-notes /tmp/empty_notes + + - name: Archive quill output + if: failure() + uses: actions/upload-artifact@v3 + with: + name: quill-logs + path: src/go/dist/quill-*.log + + notify-release-failure: + name: Notify of release failures + runs-on: ubuntu-latest + if: failure() + needs: [release] + steps: + - name: Notify release failure + uses: slackapi/slack-github-action@v1.21.0 + with: + channel-id: ${{ secrets.INTERNAL_RELEASES_SLACK_CHANNEL }} + slack-message: "ERROR: release of `rpk` binaries for `${{ github.ref_name }}` failed in ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.VBOTBUILDOVICH_SLACK_BOT_TOKEN }}