From b2d84935f4a11026e8522deb4cb30a055bbc36ff Mon Sep 17 00:00:00 2001 From: Carl Tashian Date: Tue, 9 Jul 2024 16:16:16 -0700 Subject: [PATCH] Move S3 binary build-deploy to GoReleaser --- .github/workflows/release.yml | 39 ------------------------ .goreleaser.yml | 56 +++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a8cf28f6..15b85e476 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,45 +100,6 @@ jobs: # All jobs below this are for full releases (non release candidates e.g. *-rc.*) - build_upload_aws_s3_binaries: - name: Build & Upload AWS S3 Binaries - runs-on: ubuntu-latest - needs: create_release - if: needs.create_release.outputs.is_prerelease == 'false' - steps: - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Setup Go - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 - with: - go-version: 'stable' - check-latest: true - - name: Build - id: build - run: | - PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin - make -j1 binary-linux-amd64 binary-linux-arm64 binary-darwin-amd64 binary-windows-amd64 - mkdir -p ./.releases - cp ./output/binary/linux-amd64/bin/step ./.releases/step_${{ needs.create_release.outputs.version }}_linux_amd64 - cp ./output/binary/linux-amd64/bin/step ./.releases/step_latest_linux_amd64 - cp ./output/binary/linux-arm64/bin/step ./.releases/step_${{ needs.create_release.outputs.version }}_linux_arm64 - cp ./output/binary/linux-arm64/bin/step ./.releases/step_latest_linux_arm64 - cp ./output/binary/darwin-amd64/bin/step ./.releases/step_${{ needs.create_release.outputs.version }}_darwin_amd64 - cp ./output/binary/darwin-amd64/bin/step ./.releases/step_latest_darwin_amd64 - cp ./output/binary/windows-amd64/bin/step ./.releases/step_${{ needs.create_release.outputs.version }}_windows.exe - cp ./output/binary/windows-amd64/bin/step ./.releases/step_latest_windows.exe - - name: Upload s3 - id: upload-s3 - uses: jakejarvis/s3-sync-action@be0c4ab89158cac4278689ebedd8407dd5f35a83 # v0.5.1 - with: - args: --acl public-read --follow-symlinks - env: - AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: us-east-1 - SOURCE_DIR: ./.releases - update_reference_docs: name: Update Reference Docs runs-on: ubuntu-latest diff --git a/.goreleaser.yml b/.goreleaser.yml index f04c5bbc0..d3b8377d7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -9,10 +9,17 @@ before: # - go generate ./... builds: - - - id: default + - &COMMON env: - CGO_ENABLED=0 + main: ./cmd/step/main.go + flags: + - -trimpath + ldflags: + - -w -X main.Version={{.Version}} -X main.BuildTime={{.Date}} + - + << : *COMMON + id: default targets: - darwin_amd64 - darwin_arm64 @@ -28,31 +35,44 @@ builds: - linux_ppc64le - windows_amd64 - windows_arm64 - flags: - - -trimpath - main: ./cmd/step/main.go binary: bin/step ldflags: - -w -X main.Version={{.Version}} -X main.BuildTime={{.Date}} + - + # This build is for S3 binaries that follow our naming convention there. + << : *COMMON + id: s3-versioned + targets: + - darwin_amd64 + - darwin_arm64 + - linux_amd64 + - linux_arm64 + - windows_amd64 + binary: 'step_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + - + # This build is for S3 unversioned binaries that follow our naming convention there. + << : *COMMON + id: s3-unversioned + targets: + - darwin_amd64 + - darwin_arm64 + - linux_amd64 + - linux_arm64 + - windows_amd64 + binary: 'step_latest_{{ .Os }}_{{ .Arch }}' - # This build is specifically for nFPM targets (.deb and .rpm files). # It's exactly the same as the default build above, except: # - it only builds the archs we want to produce .deb and .rpm files for # - the name of the output binary is step-cli + << : *COMMON id: nfpm - env: - - CGO_ENABLED=0 goos: - linux goarch: - amd64 - arm64 - flags: - - -trimpath - main: ./cmd/step/main.go binary: step-cli - ldflags: - - -w -X main.Version={{.Version}} -X main.BuildTime={{.Date}} archives: - &ARCHIVE @@ -239,6 +259,18 @@ release: # - glob: ./glob/**/to/**/file/**/* # - glob: ./glob/foo/to/bar/file/foobar/override_from_previous +blobs: + - + provider: s3 + region: us-east-1 + bucket: '{{ .Env.AWS_S3_BUCKET }}' + ids: + - s3-versioned + - s3-unversioned + acl: public-read + disable: '{{ neq .Prerelease "" }}' + + winget: - # IDs of the archives to use.