From ac478ac2113f6e590f5cb97617553caf94ebd0b7 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Tue, 4 Jun 2024 18:40:26 -0400 Subject: [PATCH] feat(ci): Update release.yml (#1318) * bet * bet * bet * bet * bet * bet * bet * bet * bet * bet * x * bet --- .github/workflows/release.yaml | 190 ++++++++++++++++++++++----------- build/scripts/release.mk | 16 +-- 2 files changed, 134 insertions(+), 72 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index defc9c655d..1e9710e2a3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,85 +32,145 @@ on: branches: - 'release/*' +env: + REPO_NAME: ${{ github.repository_owner }}/beacon-kit + IMAGE_NAME: ${{ github.repository_owner }}/beacon-kit + jobs: - build-linux: + extract-version: + name: extract version runs-on: ubuntu-latest + steps: + - name: Extract version + run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + id: extract_version + outputs: + VERSION: ${{ steps.extract_version.outputs.VERSION }} + + build: + name: build release + runs-on: ${{ matrix.configs.runs-on }} + needs: extract-version strategy: matrix: - arch: [amd64, arm64] - targetos: [linux] + configs: + - arch: arm64 + target-os: linux + runs-on: ubuntu-20.04 + - arch: amd64 + os: ubuntu-20.04 + - arch: arm64 + target-os: darwin + runs-on: macos-14 + build: + - binary: beacond + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "^1.22" + env: + GOOS: ${{ matrix.target-os }} + GOARCH: ${{ matrix.arch }} + + - name: Build ${{ matrix.build.binary }} + run: | + make build-${{ matrix.targetos }}-${{ matrix.arch }}-${{ needs.extract-version.outputs.VERSION }} + tar -czvf ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.targetos }}-${{ matrix.arch }}.tar.gz -C build/bin . + + # Uploads binaries + - uses: actions/upload-artifact@v3 + with: + name: beacond-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.targetos }}-${{ matrix.arch }}.tar.gz + path: build/bin - name: beacond-${{ matrix.targetos }}-${{ matrix.arch }} + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}.tar.gz + path: ${{ matrix.build.binary }}-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.configs.target }}.tar.gz + draft-release: + name: draft release + needs: [build, extract-version] + runs-on: ubuntu-latest + env: + VERSION: ${{ needs.extract-version.outputs.VERSION }} + permissions: + # Required to post the release + contents: write steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + # This is necessary for generating the changelog. + # It has to come before "Download Artifacts" or else it deletes the artifacts. + - uses: actions/checkout@v4 with: - go-version: "^1.22" + fetch-depth: 0 + - name: Download artifacts + uses: actions/download-artifact@v4 + - name: Generate full changelog + id: changelog + run: | + echo "CHANGELOG<> $GITHUB_OUTPUT + echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: Create release draft env: - GOOS: ${{ matrix.targetos }} - GOARCH: ${{ matrix.arch }} - - # Build and capture an artifact - - name: Build beacond + GITHUB_USER: ${{ github.repository_owner }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # The formatting here is borrowed from Lighthouse (which is borrowed from OpenEthereum): + # https://github.com/openethereum/openethereum/blob/6c2d392d867b058ff867c4373e40850ca3f96969/.github/workflows/build.yml run: | - make build-${{ matrix.targetos }}-${{ matrix.arch }} + body=$(cat <<- "ENDBODY" + ![image](https://github.com/berachain/beacon-kit/blob/main/.github/assets/banner.png?raw=true) + ## Testing Checklist (DELETE ME) - # Uploads binaries - - uses: actions/upload-artifact@v3 - with: - name: beacond-${{ matrix.targetos }}-${{ matrix.arch }} - path: build/bin + - [ ] Run on testnet for 1-3 days. + - [ ] Resync a mainnet node. + - [ ] Ensure all CI checks pass. - build-mac: - runs-on: macos-latest - strategy: - matrix: - arch: [arm64] - targetos: [darwin] + ## Release Checklist (DELETE ME) - name: beacond-${{ matrix.targetos }}-${{ matrix.arch }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "^1.22" - env: - GOOS: ${{ matrix.targetos }} - GOARCH: ${{ matrix.arch }} - CGO_CFLAGS: "-O -D__BLST_PORTABLE__" - CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__" + - [ ] Ensure all crates have had their versions bumped. + - [ ] Write the summary. + - [ ] Fill out the update priority. + - [ ] Ensure all binaries have been added. + - [ ] Prepare release posts (Twitter, ...). - # Build and capture an artifact - - name: Build beacond - run: | - make build-${{ matrix.targetos }}-${{ matrix.arch }} + ## Summary - # Uploads binaries - - uses: actions/upload-artifact@v3 - with: - name: beacond-${{ matrix.targetos }}-${{ matrix.arch }} - path: build/bin + Add a summary, including: - draft-release: - runs-on: ubuntu-latest - needs: [build-linux, build-mac] - permissions: write-all - steps: - - name: Checkout repository - uses: actions/checkout@v3 + - Critical bug fixes + - New features + - Any breaking changes (and what to expect) - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - path: . + ## Update Priority - - name: Draft Release - uses: softprops/action-gh-release@v2 - with: - draft: true - files: | - ./beacond-linux-arm64/beacond-linux-arm64 - ./beacond-linux-amd64/beacond-linux-amd64 - ./beacond-darwin-arm64/beacond-darwin-arm64 - env: - GIT_TOKEN: ${{ secrets.DEV_PAT }} + This table provides priorities for which classes of users should update particular components. + + | User Class | Priority | + |----------------------|-----------------| + | Payload Builders | | + | Non-Payload Builders | | + + ## All Changes + + ${{ steps.changelog.outputs.CHANGELOG }} + + ## Binaries + + | System | Architecture | Binary | PGP Signature | + |:---:|:---:|:---:|:---| + | | amd64 | [beacond-${{ env.VERSION }}-linux-amd64](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/beacond-${{ env.VERSION }}-amd64-linux.tar.gz) | + | | arm64 | [beacond-${{ env.VERSION }}-linux-arm64](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/beacond-${{ env.VERSION }}-arm64-linux.tar.gz) | + | | arm64 | [beacond-${{ env.VERSION }}-darwin-arm64](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/beacond-${{ env.VERSION }}-darwin-arm64.tar.gz) | + | | | | | + | **System** | **Option** | - | **Resource** | + | | Docker | | [${{ env.IMAGE_NAME }}](https://ghcr.io/berachain/beacon-kit) | + ENDBODY + ) + assets=() + for asset in ./*beacond-*.tar.gz*; do + assets+=("$asset/$asset") + done + tag_name="${{ env.VERSION }}" + echo "$body" | gh release create --draft -t "BeaconKit $tag_name" -F "-" "$tag_name" "${assets[@]}" diff --git a/build/scripts/release.mk b/build/scripts/release.mk index 5e0e4dc3d3..f5ec4cbd49 100644 --- a/build/scripts/release.mk +++ b/build/scripts/release.mk @@ -3,17 +3,19 @@ RELEASE_TARGETS := build-linux-amd64 build-linux-arm64 build-darwin-arm64 define build_release + echo "Building beacond for $(shell echo $(4) | tr '/' '-')-$(1)-$(2)-..." GOOS=$(1) GOARCH=$(2) CGO_ENABLED=$(3) \ cd ${CURRENT_DIR}/$(TESTAPP_CMD_DIR) && \ - go build -mod=readonly $(BUILD_FLAGS) -o $(OUT_DIR)/beacond-$(1)-$(2) ./. + go build -mod=readonly $(BUILD_FLAGS) -o $(OUT_DIR)/beacond-$(shell echo $(4) | tr '/' '-')-$(1)-$(2) ./. endef -build-linux-amd64: - $(call build_release,linux,amd64,0) +build-linux-amd64-%: + $(call build_release,linux,amd64,1,$*) -build-linux-arm64: - $(call build_release,linux,arm64,0) +build-linux-arm64-%: + $(call build_release,linux,arm64,1,$*) + +build-darwin-arm64-%: + $(call build_release,darwin,arm64,1,$*) -build-darwin-arm64: - $(call build_release,darwin,arm64,1)