From 70ed79bf9f3db845bf0c9d67b65e25ccadf16fa2 Mon Sep 17 00:00:00 2001 From: Charlie <31941002+CharlieMc0@users.noreply.github.com> Date: Mon, 2 Oct 2023 14:31:05 -0700 Subject: [PATCH] ci: cross-compile release binaries and simplify PR testings (#1218) * setup goreleaser * test pr workflow * testing runner types * fixed download paths * Updated CodeOwners --- .github/CODEOWNERS | 2 + .github/actions/upgrade-testing/action.yml | 4 +- .github/workflows/build.yml | 468 +------------------- .github/workflows/publish-release.yml | 233 ++++++++++ .github/workflows/upgrade_path_testing.yaml | 8 +- .goreleaser.yaml | 169 +++++++ Makefile | 39 +- 7 files changed, 454 insertions(+), 469 deletions(-) create mode 100644 .github/workflows/publish-release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ec904b1899..7c2bcf799b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,3 @@ * @brewmaster012 @kingpinXD @kevinssgh @fadeev @lumtis @ws4charlie + +.github/** @zeta-chain/devops diff --git a/.github/actions/upgrade-testing/action.yml b/.github/actions/upgrade-testing/action.yml index b01862ea1a..da9019e8df 100644 --- a/.github/actions/upgrade-testing/action.yml +++ b/.github/actions/upgrade-testing/action.yml @@ -48,7 +48,7 @@ runs: BINARY_NAME_SUFFIX: "ubuntu-22-amd64" UPGRADES_SLEEP_TIME: 300 DEBUG_UPGRADES: "false" - #BINARY_DOWNLOAD_LIST: '{"binary_download_list":[["v8.3.3", "zetacored-ubuntu-22-amd64"],["v9.0.0", "zetacored-ubuntu-22-amd64"]]}' + #BINARY_DOWNLOAD_LIST: '{"binary_download_list":[["v8.3.3", "zetacored-testnet-linux-amd64"],["v9.0.0", "zetacored-ubuntu-22-amd64"]]}' #TAG_LIST: '{"tag_list":["v8.3.3","v9.0.0"]}' STARTING_VERSION: "v8.3.3" #END_VERSION: "v9.0.0" @@ -60,7 +60,7 @@ runs: echo "***********Change Permission of Zetacored*********************" chmod a+x zetacored* chmod -R 777 zetacored* - mv zetacored-ubuntu-22-amd64 zetacored + mv zetacored-testnet-linux-amd64 zetacored export PATH=$(pwd):$PATH echo "***********Change Directories into the Upgrade Testing Directory.*********************" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6012ce610..fd459bafef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,16 +1,9 @@ -name: Build +name: PR Testing on: - push: - branches: - - develop - - athens2-develop - tags: - - "*" pull_request: branches: - develop - - athens2-develop types: - synchronize - opened @@ -18,7 +11,7 @@ on: - ready_for_review concurrency: - group: build-${{ github.head_ref || github.run_id }} + group: pr-testing-${{ github.head_ref || github.run_id }} cancel-in-progress: true env: @@ -28,13 +21,11 @@ env: GITHUB_REF_NAME: "$(echo ${{ github.ref_name }} | tr '//' '-')" jobs: - build-and-test-single-arch: - runs-on: ubuntu-latest - # runs-on: ["zeta-runners"] - timeout-minutes: 20 - if: (! startsWith(github.ref, 'refs/tags/')) || (! startsWith(github.ref, 'refs/heads/develop') ) + build-and-test: + runs-on: buildjet-4vcpu-ubuntu-2004 + timeout-minutes: 15 concurrency: - group: "build-and-test-single-arch" + group: "build-and-test" steps: - uses: actions/checkout@v3 @@ -86,204 +77,9 @@ jobs: shell: bash run: rm -rf * - build-and-test-multi-arch: - strategy: - matrix: - runs-on: - [ - buildjet-4vcpu-ubuntu-2204-arm, - buildjet-4vcpu-ubuntu-2204, - buildjet-4vcpu-ubuntu-2004 - ] - - runs-on: ${{matrix.runs-on}} - timeout-minutes: 30 - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - steps: - - uses: actions/checkout@v3 - - - name: Set CPU Architecture - shell: bash - run: | - if [ "$(uname -m)" == "aarch64" ]; then - echo "CPU_ARCH=arm64" >> $GITHUB_ENV - elif [ "$(uname -m)" == "x86_64" ]; then - echo "CPU_ARCH=amd64" >> $GITHUB_ENV - else - echo "Unsupported architecture" >&2 - exit 1 - fi - - - name: Install Pipeline Dependencies - uses: ./.github/actions/install-dependencies - timeout-minutes: 8 - with: - cpu_architecture: ${{ env.CPU_ARCH }} - skip_python: "true" - skip_aws_cli: "true" - skip_docker_compose: "true" - - # - uses: buildjet/cache - # timeout-minutes: 5 - # with: - # path: | - # ~/.cache/go-build - # ~/go/pkg/mod - # key: ${{ matrix.runs-on }}-go-${{ hashFiles('**/go.sum') }} - # restore-keys: | - # ${{ matrix.runs-on }}-go- - - - name: Test - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - retry_on: error - command: | - echo "Running Build Tests" - make clean - make test - - - name: Build zetacored and zetaclientd - env: - CGO_ENABLED: 1 - GOOS: linux - GOARCH: ${{ env.CPU_ARCH }} - run: | - make install-testnet - cp "$HOME"/go/bin/* ./ - chmod a+x ./zetacored - ./zetacored version - - - - name: Name Binaries - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - env: - CPU_ARCH: ${{ env.CPU_ARCH }} - run: | - OS_VERSION=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d '=' -f 2 | cut -d '.' -f 1) - cp zetacored zetacored-ubuntu-$OS_VERSION-$CPU_ARCH - cp zetaclientd zetaclientd-ubuntu-$OS_VERSION-$CPU_ARCH - - - name: Save Binaries as Artifacts - uses: actions/upload-artifact@v3 - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - with: - name: binaries-${{ github.sha }} - path: | - zetacored-ubuntu-* - zetaclientd-ubuntu-* - - - name: Clean Up Workspace - if: always() - shell: bash - run: rm -rf * - - build-alpine-and-test: - runs-on: ["ubuntu-latest"] - timeout-minutes: 30 - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - concurrency: - group: "alpine-build-test" - steps: - - uses: actions/checkout@v3 - - - name: Set CPU Architecture - shell: bash - run: | - if [ "$(uname -m)" == "aarch64" ]; then - echo "CPU_ARCH=arm64" >> $GITHUB_ENV - elif [ "$(uname -m)" == "x86_64" ]; then - echo "CPU_ARCH=amd64" >> $GITHUB_ENV - else - echo "Unsupported architecture" >&2 - exit 1 - fi - - - name: Install Pipeline Dependencies - uses: ./.github/actions/install-dependencies - timeout-minutes: 8 - with: - cpu_architecture: ${{ env.CPU_ARCH }} - skip_python: "true" - skip_aws_cli: "true" - skip_docker_compose: "false" - - - uses: jirutka/setup-alpine@v1 - with: - branch: v3.17 - arch: x86_64 - packages: > - build-base - pkgconf - lld - go - gcc - g++ - libusb-dev - linux-headers - git - shell-name: alpine.sh - - - name: Test - env: - CGO_ENABLED: 1 - GOOS: linux - GOARCH: ${{ env.CPU_ARCH }} - shell: alpine.sh --root {0} - run: | - echo "Running Build Tests" - apk add --no-cache --update - make clean - make test - - - name: Build zetacored and zetaclientd - env: - CGO_ENABLED: 1 - GOOS: linux - GOARCH: ${{ env.CPU_ARCH }} - shell: alpine.sh --root {0} - run: | - git config --global --add safe.directory '*' - make install-testnet - cp "$HOME"/go/bin/* ./ - - - name: Binary Docker Test - env: - CPU_ARCH: ${{ env.CPU_ARCH }} - shell: alpine.sh --root {0} - run: | - chmod a+x ./zetacored - ./zetacored version - mv zetacored zetacored-alpine-$CPU_ARCH - mv zetaclientd zetaclientd-alpine-$CPU_ARCH - - - name: Save Binaries as Artifacts - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - uses: actions/upload-artifact@v3 - with: - name: binaries-${{ github.sha }} - path: | - zetacored-alpine-* - zetaclientd-alpine-* - - - name: Clean Up Alpine Workspace - if: always() - shell: alpine.sh --root {0} - run: | - set -e # fail on error - rm -rf * - - - name: Clean Up Workspace - if: always() - shell: bash - run: rm -rf * - - smoke-test: - runs-on: ["zeta-runners"] - #runs-on: ubuntu-latest - timeout-minutes: 20 + runs-on: ["zeta-runners"] # 20 minutes + timeout-minutes: 25 steps: - uses: actions/checkout@v3 @@ -341,252 +137,4 @@ jobs: shell: bash run: rm -rf * - upload: - runs-on: ["zeta-runners"] - #runs-on: ubuntu-latest - timeout-minutes: 15 - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/develop') - needs: - - build-and-test-multi-arch - - smoke-test - - build-alpine-and-test - steps: - - uses: actions/checkout@v3 - - - name: Install Pipeline Dependencies - uses: ./.github/actions/install-dependencies - timeout-minutes: 8 - with: - cpu_architecture: ${{ env.CPU_ARCH }} - skip_python: "true" - skip_aws_cli: "false" - skip_docker_compose: "true" - - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v6 - - - name: Git Hash - run: | - echo "GIT_HASH=$(git rev-parse --short HEAD)" >> ${GITHUB_ENV} - echo "WORKSPACE_DIR=$(pwd)" >> ${GITHUB_ENV} - - - name: set-branch-name - uses: ./.github/actions/set-branch-name - with: - github_ref: "${{github.ref}}" - github_event: "${{ github.event_name }}" - github_head_ref: "${{ github.event.pull_request.head.ref }}" - github_commit_sha: "${{ env.GIT_HASH }}" - current_branch_name: "${{ steps.branch-name.outputs.current_branch }}" - - - uses: actions/download-artifact@v3 - with: - name: binaries-${{ github.sha }} - path: ./ - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: upload-files-to-s3 - uses: ./.github/actions/upload-to-s3 - with: - bucket-name: ${{ env.S3_BUCKET_PATH }} - release-name: ${{ env.RELEASE_NAME }} - git-sha: ${{ github.sha }} - files: | - zetacored-alpine-amd64 - zetaclientd-alpine-amd64 - zetacored-ubuntu-22-arm64 - zetaclientd-ubuntu-22-arm64 - zetacored-ubuntu-22-amd64 - zetaclientd-ubuntu-22-amd64 - zetacored-ubuntu-20-amd64 - zetaclientd-ubuntu-20-amd64 - - # # Approval will be required closer to mainnet - # - name: Require Approval To Create a Release - # uses: softprops/action-gh-release@v1 - # if: startsWith(github.ref, 'refs/tags/v') - # with: - # token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - # files: | - # zetacored-alpine-amd64 - # zetaclientd-alpine-amd64 - # zetacored-ubuntu-22-arm64 - # zetaclientd-ubuntu-22-arm64 - # zetacored-ubuntu-22-amd64 - # zetaclientd-ubuntu-22-amd64 - # zetacored-ubuntu-20-amd64 - # zetaclientd-ubuntu-20-amd64 - - - name: Build, tag, and push docker images - uses: ./.github/actions/build-docker-images - with: - DOCKER_FILENAME: Dockerfile - REPOSITORY_NAME: zeta-node - IMAGE_TAG: ${{ env.TAG_NAME }} - GHCR_USERNAME: ${{ secrets.PAT_GITHUB_SERVICE_ACCT_USERNAME }} - GHCR_TOKEN: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - - name: Create GitHub Release for ZetaCore/ZetaClient - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/v') - with: - token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - generate_release_notes: true - files: | - zetacored-alpine-amd64 - zetaclientd-alpine-amd64 - zetacored-ubuntu-22-arm64 - zetaclientd-ubuntu-22-arm64 - zetacored-ubuntu-22-amd64 - zetaclientd-ubuntu-22-amd64 - zetacored-ubuntu-20-amd64 - zetaclientd-ubuntu-20-amd64 - - - name: Clean Up Workspace - if: always() - shell: bash - run: rm -rf * - - upgrade_path_testing: - runs-on: ["buildjet-4vcpu-ubuntu-2204"] - timeout-minutes: 60 - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release') - needs: - - build-and-test-multi-arch - - build-alpine-and-test - - upload - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Major Version in Upgrade Handler Must Match Tag - if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/release') - run: | - UPGRADE_HANDLER_MAJOR_VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"' | cut -d '.' -f1) - echo $UPGRADE_HANDLER_MAJOR_VERSION - GITHUB_TAG_MAJOR_VERSION=$(echo ${{ github.ref_name }} | cut -d '.' -f1) - if [ $GITHUB_TAG_MAJOR_VERSION != $UPGRADE_HANDLER_MAJOR_VERSION ]; then - echo "ERROR: The major version of this release (${{ github.ref_name }}) does not match the major version in the releaseVersion constant ($UPGRADE_HANDLER_MAJOR_VERSION) found in app/setup_handlers.go" - echo "Did you forget to update the 'releaseVersion' in app/setup_handlers.go?" - exit 1 - fi - echo "The major version found in 'releaseVersion' in app/setup_handlers.go matches this tagged release - Moving Forward!" - - - name: upgrade-path-testing - uses: ./.github/actions/upgrade-testing - with: - github_token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - - name: Clean Up Workspace - if: always() - shell: bash - run: rm -rf * - - upload_s3_public: - #runs-on: ubuntu-latest - runs-on: ["zeta-runners"] - timeout-minutes: 15 - if: startsWith(github.ref, 'refs/tags/') - needs: - - build-and-test-multi-arch - - build-alpine-and-test - - upload - - steps: - - uses: actions/checkout@v3 - - - name: Install Pipeline Dependencies - uses: ./.github/actions/install-dependencies - timeout-minutes: 8 - with: - cpu_architecture: ${{ env.CPU_ARCH }} - skip_python: "true" - skip_aws_cli: "false" - skip_docker_compose: "true" - - - uses: actions/download-artifact@v3 - with: - name: binaries-${{ github.sha }} - path: ./ - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: Get Version - run: | - VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"') - echo "BINARY_VERSION=${VERSION}" >> ${GITHUB_ENV} - - - name: upload-files-to-s3 - uses: ./.github/actions/upload-to-s3 - with: - bucket-name: ${{ env.S3_PUBLIC_BUCKET_PATH }} - release-name: "binaries/athens3/${{ env.BINARY_VERSION }}" - git-sha: ${{ github.sha }} - files: | - zetacored-alpine-amd64 - zetaclientd-alpine-amd64 - zetacored-ubuntu-22-arm64 - zetaclientd-ubuntu-22-arm64 - zetacored-ubuntu-22-amd64 - zetaclientd-ubuntu-22-amd64 - zetacored-ubuntu-20-amd64 - zetaclientd-ubuntu-20-amd64 - - - name: Determine Release Type - run: | - if [[ "${{ env.BINARY_VERSION }}" =~ ^v[0-9]+\.0\.0+$ ]]; then - echo "RELEASE_TYPE=major" >> ${GITHUB_ENV} - elif [[ "${{ env.BINARY_VERSION }}" =~ ^v[0-9]+\.[0-9]+\.[1-9]+$ ]]; then - echo "RELEASE_TYPE=minor" >> ${GITHUB_ENV} - else - echo "RELEASE_TYPE=unknown" >> ${GITHUB_ENV} - fi - id: determine_release_type - - - name: "SEND:DISCORD:MESSAGE" - if: steps.determine_release_type.outputs.RELEASE_TYPE == 'major' - uses: gzukel/CosmosComposites/send_discord_message@main - with: - discord_token: "${{ secrets.DISCORD_TOKEN }}" - discord_channel_id: "${{ secrets.DISCORD_CHANNEL_ID }}" - discord_message: | - Hey <@&1122981184255840306>! A new version of the ZetaChain software has been released. - - Major Version Upgrade (e.g. v5.x.x to V6.x.x) must be completed through a governance proposal. - We will submit a governance proposal in the next few days. - More specific information including block height will be shared as part of the governance proposal. - - See the release notes for more details. https://github.com/zeta-chain/node/releases/tag/${{ env.BINARY_VERSION }} - - # - name: "SEND:DISCORD:MESSAGE" - # if: steps.determine_release_type.outputs.RELEASE_TYPE == 'minor' - # uses: gzukel/CosmosComposites/send_discord_message@main - # with: - # discord_token: "${{ secrets.DISCORD_TOKEN }}" - # discord_channel_id: "${{ secrets.DISCORD_CHANNEL_ID }}" - # discord_message: | - # Hey <@&1122981184255840306>! A new version of the zetachain node has been released. - - # Minor Version Upgrade (e.g. v5.0.x to v5.1.x) can be applied without a governance proposal. - # Please review the release notes for any specific upgrade instructions or considerations. - - # See the release notes for more details. https://github.com/zeta-chain/node/releases/tag/${{ env.BINARY_VERSION }} - - - name: Clean Up Workspace - if: always() - shell: bash - run: rm -rf * \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000000..7f88220c26 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,233 @@ +name: Publish Release + +on: + push: + tags: + - "v*.*.*" + +concurrency: + group: publish-release + cancel-in-progress: false + +env: + GITHUB_REF_NAME: "$(echo ${{ github.ref_name }} | tr '//' '-')" + +jobs: + pre-release-checks: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Major Version in Upgrade Handler Must Match Tag + run: | + UPGRADE_HANDLER_MAJOR_VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"' | cut -d '.' -f1) + echo $UPGRADE_HANDLER_MAJOR_VERSION + GITHUB_TAG_MAJOR_VERSION=$(echo ${{ github.ref_name }} | cut -d '.' -f1) + if [ $GITHUB_TAG_MAJOR_VERSION != $UPGRADE_HANDLER_MAJOR_VERSION ]; then + echo "ERROR: The major version of this release (${{ github.ref_name }}) does not match the major version in the releaseVersion constant ($UPGRADE_HANDLER_MAJOR_VERSION) found in app/setup_handlers.go" + echo "Did you forget to update the 'releaseVersion' in app/setup_handlers.go?" + exit 1 + fi + echo "The major version found in 'releaseVersion' in app/setup_handlers.go matches this tagged release - Moving Forward!" + + publish-release: + runs-on: buildjet-4vcpu-ubuntu-2004 + timeout-minutes: 60 + needs: + - pre-release-checks + steps: + - uses: actions/checkout@v3 + + - name: Set CPU Architecture + shell: bash + run: | + if [ "$(uname -m)" == "aarch64" ]; then + echo "CPU_ARCH=arm64" >> $GITHUB_ENV + elif [ "$(uname -m)" == "x86_64" ]; then + echo "CPU_ARCH=amd64" >> $GITHUB_ENV + else + echo "Unsupported architecture" >&2 + exit 1 + fi + + - name: Install Pipeline Dependencies + uses: ./.github/actions/install-dependencies + timeout-minutes: 8 + with: + cpu_architecture: ${{ env.CPU_ARCH }} + skip_python: "true" + skip_aws_cli: "true" + skip_docker_compose: "true" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + generate_release_notes: true + + - name: Publish Release Files + env: + GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + run: | + touch .release-env + make release + + ## TODO - Will add in later after optimizing docker images + # - name: Build, tag, and push docker images + # uses: ./.github/actions/build-docker-images + # with: + # DOCKER_FILENAME: Dockerfile + # REPOSITORY_NAME: zeta-node + # IMAGE_TAG: ${{ env.TAG_NAME }} + # GHCR_USERNAME: ${{ secrets.PAT_GITHUB_SERVICE_ACCT_USERNAME }} + # GHCR_TOKEN: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + + build-alpine: + runs-on: ["ubuntu-latest"] + timeout-minutes: 30 + concurrency: + group: "alpine-build-test" + needs: + - pre-release-checks + steps: + - uses: actions/checkout@v3 + + - name: Set CPU Architecture + shell: bash + run: | + if [ "$(uname -m)" == "aarch64" ]; then + echo "CPU_ARCH=arm64" >> $GITHUB_ENV + elif [ "$(uname -m)" == "x86_64" ]; then + echo "CPU_ARCH=amd64" >> $GITHUB_ENV + else + echo "Unsupported architecture" >&2 + exit 1 + fi + + - name: Install Pipeline Dependencies + uses: ./.github/actions/install-dependencies + timeout-minutes: 8 + with: + cpu_architecture: ${{ env.CPU_ARCH }} + skip_python: "true" + skip_aws_cli: "true" + skip_docker_compose: "false" + + - uses: jirutka/setup-alpine@v1 + with: + branch: v3.17 + arch: x86_64 + packages: > + build-base + pkgconf + lld + go + gcc + g++ + libusb-dev + linux-headers + git + shell-name: alpine.sh + + - name: Build zetacored and zetaclientd + env: + CGO_ENABLED: 1 + GOOS: linux + GOARCH: ${{ env.CPU_ARCH }} + shell: alpine.sh --root {0} + run: | + git config --global --add safe.directory '*' + make install-testnet + cp "$HOME"/go/bin/* ./ + + - name: Binary Docker Test + env: + CPU_ARCH: ${{ env.CPU_ARCH }} + shell: alpine.sh --root {0} + run: | + chmod a+x ./zetacored + ./zetacored version + mv zetacored zetacored-testnet-alpine-$CPU_ARCH + mv zetaclientd zetaclientd-testnet-alpine-$CPU_ARCH + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + generate_release_notes: true + files: | + zetacored-* + zetaclientd-* + + - name: Clean Up Alpine Workspace + if: always() + shell: alpine.sh --root {0} + run: | + set -e # fail on error + rm -rf * + + - name: Clean Up Workspace + if: always() + shell: bash + run: rm -rf * + + announce-release: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: + - publish-release + - build-alpine + steps: + - uses: actions/checkout@v3 + - name: Get Version + run: | + VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"') + echo "BINARY_VERSION=${VERSION}" >> ${GITHUB_ENV} + + - name: Determine Release Type + id: determine_release_type + run: | + if [[ "${{ env.BINARY_VERSION }}" =~ ^v[0-9]+\.0\.0+$ ]]; then + echo "RELEASE_TYPE=major" >> ${GITHUB_ENV} + elif [[ "${{ env.BINARY_VERSION }}" =~ ^v[0-9]+\.[0-9]+\.[1-9]+$ ]]; then + echo "RELEASE_TYPE=minor" >> ${GITHUB_ENV} + else + echo "RELEASE_TYPE=unknown" >> ${GITHUB_ENV} + fi + + - name: "SEND:DISCORD:MESSAGE" + if: steps.determine_release_type.outputs.RELEASE_TYPE == 'major' + uses: gzukel/CosmosComposites/send_discord_message@main + with: + discord_token: "${{ secrets.DISCORD_TOKEN }}" + discord_channel_id: "${{ secrets.DISCORD_CHANNEL_ID }}" + discord_message: | + Hey <@&1122981184255840306>! A new version of the ZetaChain software has been released. + + Major Version Upgrade (e.g. v5.x.x to V6.x.x) must be completed through a governance proposal. + We will submit a governance proposal in the next few days. + More specific information including block height will be shared as part of the governance proposal. + + See the release notes for more details. https://github.com/zeta-chain/node/releases/tag/${{ env.BINARY_VERSION }} + + # - name: "SEND:DISCORD:MESSAGE" + # if: steps.determine_release_type.outputs.RELEASE_TYPE == 'minor' + # uses: gzukel/CosmosComposites/send_discord_message@main + # with: + # discord_token: "${{ secrets.DISCORD_TOKEN }}" + # discord_channel_id: "${{ secrets.DISCORD_CHANNEL_ID }}" + # discord_message: | + # Hey <@&1122981184255840306>! A new version of the zetachain node has been released. + + # Minor Version Upgrade (e.g. v5.0.x to v5.1.x) can be applied without a governance proposal. + # Please review the release notes for any specific upgrade instructions or considerations. + + # See the release notes for more details. https://github.com/zeta-chain/node/releases/tag/${{ env.BINARY_VERSION }} + + - name: Clean Up Workspace + if: always() + shell: bash + run: rm -rf * diff --git a/.github/workflows/upgrade_path_testing.yaml b/.github/workflows/upgrade_path_testing.yaml index fffc7fcbda..002c1df6d6 100644 --- a/.github/workflows/upgrade_path_testing.yaml +++ b/.github/workflows/upgrade_path_testing.yaml @@ -18,8 +18,8 @@ jobs: runs-on: ["buildjet-8vcpu-ubuntu-2204"] env: latest_state_export: "https://zetachain-external-files.s3.amazonaws.com/state-export/athens3/latest.json" - github_binary_version_link: "https://github.com/zeta-chain/node/releases/download/${{ github.event.inputs.version }}/zetacored-ubuntu-22-amd64" - downloaded_binary_name: "zetacored-ubuntu-22-amd64" + github_binary_version_link: "https://github.com/zeta-chain/node/releases/download/${{ github.event.inputs.version }}/zetacored-testnet-linux-amd64" + downloaded_binary_name: "zetacored-testnet-linux-amd64" VERSION: "${{ github.event.inputs.version }}" aws_region: "us-east-1" GAS_PRICES: "1.0azeta" @@ -119,7 +119,7 @@ jobs: ls -lah /home/runner/.zetacored/zetavisor/upgrades/${{ github.event.inputs.upgrade_name }}/bin/zetacored echo "ZETACORED_CHECKSUM=${ZETACORED_CHECKSUM}" >> ${GITHUB_ENV} - UPGRADE_INFO='{"binaries": {"zetacored-linux/amd64": "https://github.com/zeta-chain/node/releases/download/${{ github.event.inputs.version }}/zetacored-ubuntu-22-amd64?checksum=sha256:'${ZETACORED_CHECKSUM}'"}}' + UPGRADE_INFO='{"binaries": {"zetacored-linux/amd64": "https://github.com/zeta-chain/node/releases/download/${{ github.event.inputs.version }}/zetacored-testnet-linux-amd64?checksum=sha256:'${ZETACORED_CHECKSUM}'"}}' echo ${UPGRADE_INFO} @@ -128,7 +128,7 @@ jobs: current_version=$(curl https://rpc-archive.athens.zetachain.com:26657/abci_info -s | jq .result.response.version -r | tr -d '\n') echo "STARTING_VERSION=${current_version}" >> ${GITHUB_ENV} echo "STARTING_VERSION=${current_version}" - wget -q https://github.com/zeta-chain/node/releases/download/${current_version}/zetacored-ubuntu-22-amd64 -O /home/runner/.zetacored/zetavisor/genesis/bin/zetacored + wget -q https://github.com/zeta-chain/node/releases/download/${current_version}/zetacored-testnet-linux-amd64 -O /home/runner/.zetacored/zetavisor/genesis/bin/zetacored sudo chmod a+x /home/runner/.zetacored/zetavisor/genesis/bin/zetacored echo "PATH=/home/runner/.zetacored/zetavisor/genesis/bin:$PATH" >> ${GITHUB_ENV} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000000..1995d6b43d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,169 @@ +# Make sure to check the documentation at https://goreleaser.com + +## Test locally with `make release-dry-run` + +## TODO +# - Add SBOMs +# - Add Docker Builds +# - SLSA - https://github.com/goreleaser/goreleaser-example-slsa-provenance +# - Add Code Signing + +env: + - CGO_ENABLED=1 + - CC_darwin_arm64=oa64-clang + - CXX_darwin_arm64=oa64-clang++ + - CC_darwin_amd64=o64-clang + - CXX_darwin_amd64=o64-clang+ + - CC_linux_arm64=aarch64-linux-gnu-gcc + - CXX_linux_arm64=aarch64-linux-gnu-g++ + - CC_linux_amd64=x86_64-linux-gnu-gcc + - CXX_linux_amd64=x86_64-linux-gnu-g++ + - CC_windows_amd64=x86_64-w64-mingw32-gcc + - CXX_windows_amd64=x86_64-w64-mingw32-g++ + - VERSION={{ .Version }} + - COMMIT={{ .Commit }} + - BUILDTIME={{ .Date }} + # - CC_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES + # - CXX_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES + +before: + hooks: + - go mod download + - go mod tidy + +builds: + - id: "zetacored_testnet" + main: ./cmd/zetacored + binary: "zetacored_testnet-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + - darwin + - windows + goarch: + - arm64 + - amd64 + ignore: + - goos: windows + goarch: arm64 + flags: &default_testnet_flags + - -tags=TESTNET,pebbledb,ledger,cgo,netgo + - -installsuffix=static + ldflags: &default_ldflags + - -X github.com/cosmos/cosmos-sdk/version.Name=zetacore + - -X github.com/cosmos/cosmos-sdk/version.ServerName=zetacored + - -X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd + - -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Env.COMMIT }} + - -X github.com/zeta-chain/zetacore/common.Name=zetacored + - -X github.com/zeta-chain/zetacore/common.Version={{ .Version }} + - -X github.com/zeta-chain/zetacore/common.CommitHash={{ .Env.COMMIT }} + - -X github.com/zeta-chain/zetacore/common.BuildTime=={{ .Env.BUILDTIME }} + - -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb +W + - id: "zetaclientd_testnet" + main: ./cmd/zetaclientd + binary: "zetaclientd_testnet-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + # - darwin + # - windows + goarch: + - arm64 + - amd64 + ignore: + - goos: windows + goarch: arm64 + flags: *default_testnet_flags + ldflags: *default_ldflags + + - id: "zetacored_mock_mainnet" + main: ./cmd/zetacored + binary: "zetacored_mock_mainnet-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + - darwin + - windows + goarch: + - arm64 + - amd64 + ignore: + - goos: windows + goarch: arm64 + flags: &default_mock_mainnet_flags + - -tags=MOCK_MAINNET,pebbledb,ledger,cgo + ldflags: *default_ldflags + + - id: "zetaclientd_mock_mainnet" + main: ./cmd/zetaclientd + binary: "zetaclientd_mock_mainnet-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + # - darwin + # - windows + goarch: + - arm64 + - amd64 + ignore: + - goos: windows + goarch: arm64 + flags: *default_mock_mainnet_flags + ldflags: *default_ldflags + +archives: + - format: binary + name_template: "{{ .Binary }}" + +checksum: + name_template: "checksums.txt" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +snapshot: + name_template: "{{ .Tag }}-next" + +release: + # If set to true, will not auto-publish the release. + # Available only for GitHub and Gitea. + draft: false + + target_commitish: "{{ .Commit }}" + + # If set, will create a release discussion in the category specified. + # + # Warning: do not use categories in the 'Announcement' format. + # Check https://github.com/goreleaser/goreleaser/issues/2304 for more info. + # + # Default is empty. + # discussion_category_name: General + + # If set to auto, will mark the release as not ready for production + # in case there is an indicator for this in the tag e.g. v1.0.0-rc1 + # If set to true, will mark the release as not ready for production. + # Default is false. + prerelease: auto + + # What to do with the release notes in case there the release already exists. + # + # Valid options are: + # - `keep-existing`: keep the existing notes + # - `append`: append the current release notes to the existing notes + # - `prepend`: prepend the current release notes to the existing notes + # - `replace`: replace existing notes + # + # Default is `keep-existing`. + mode: append \ No newline at end of file diff --git a/Makefile b/Makefile index 5fb9f29843..575057ef70 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ .PHONY: build - -PACKAGES=$(shell go list ./... | grep -v '/simulation') VERSION := $(shell git describe --tags) COMMIT := $(shell [ -z "${COMMIT_ID}" ] && git log -1 --format='%H' || echo ${COMMIT_ID} ) BUILDTIME := $(shell date -u +"%Y%m%d.%H%M%S" ) @@ -229,4 +227,39 @@ stateful-upgrade: cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d stop-stateful-upgrade: - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans \ No newline at end of file + cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans + + +############################################################################### +### GoReleaser ### +############################################################################### +PACKAGE_NAME := github.com/zeta-chain/node +GOLANG_CROSS_VERSION ?= v1.20 +GOPATH ?= '$(HOME)/go' +release-dry-run: + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v ${GOPATH}/pkg:/go/pkg \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + --clean --skip-validate --skip-publish --snapshot + +release: + @if [ ! -f ".release-env" ]; then \ + echo "\033[91m.release-env is required for release\033[0m";\ + exit 1;\ + fi + docker run \ + --rm \ + --privileged \ + -e CGO_ENABLED=1 \ + -e "GITHUB_TOKEN=${GITHUB_TOKEN}" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + release --clean --skip-validate \ No newline at end of file