diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release-legacy.yml similarity index 94% rename from .github/workflows/publish-release.yml rename to .github/workflows/publish-release-legacy.yml index 3dc3a27e36..1c05cd1920 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release-legacy.yml @@ -1,4 +1,4 @@ -name: Publish Release +name: Publish Release Legacy on: workflow_dispatch: @@ -19,7 +19,7 @@ on: description: 'Only run pre-release checks' concurrency: - group: publish-release + group: publish-release-legacy cancel-in-progress: false jobs: @@ -74,8 +74,10 @@ jobs: cat changelog-current.md - name: Set Version + env: + VERSION_INPUT: ${{ inputs.version }} run: | - echo "GITHUB_TAG_VERSION=${{ inputs.version }}" >> ${GITHUB_ENV} + echo "GITHUB_TAG_VERSION=${VERSION_INPUT}" >> ${GITHUB_ENV} - name: Create Release Tag shell: bash @@ -133,6 +135,6 @@ jobs: run: sudo rm -rf * || echo "failed to cleanup workspace please investigate" publish-typescript: - needs: publish-release + needs: publish-release-legacy uses: ./.github/workflows/publish-typescript.yml secrets: inherit diff --git a/.github/workflows/publish-release-zetaclient.yml b/.github/workflows/publish-release-zetaclient.yml new file mode 100644 index 0000000000..41ac8dca00 --- /dev/null +++ b/.github/workflows/publish-release-zetaclient.yml @@ -0,0 +1,40 @@ +name: Publish ZetaClient Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version for ZetaClient Release (e.g., v2.5.0)' + required: true + skip_checks: + type: boolean + required: false + default: false + description: 'Skip pre-release checks' + skip_release: + type: boolean + required: false + default: false + description: 'Only run pre-release checks' + +concurrency: + group: publish-release-zetaclient + cancel-in-progress: false + +jobs: + release: + uses: ./.github/workflows/release-template.yml + with: + version: ${{ inputs.version }} + skip_checks: ${{ inputs.skip_checks }} + skip_release: ${{ inputs.skip_release }} + component: 'zetaclient' + branch_prefix: 'release/zetaclient/' + make_snapshot_target: 'release-snapshot-zetaclient' + make_release_target: 'release-zetaclient' + attestation_paths: | + dist/zetaclientd_**/* + dist/zetae2e_**/* + dist/checksums.txt + include_typescript: false + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/publish-release-zetacore.yml b/.github/workflows/publish-release-zetacore.yml new file mode 100644 index 0000000000..ec2d5dc50b --- /dev/null +++ b/.github/workflows/publish-release-zetacore.yml @@ -0,0 +1,39 @@ +name: Publish ZetaCore Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version for ZetaCore Release (e.g., v36.0.0)' + required: true + skip_checks: + type: boolean + required: false + default: false + description: 'Skip pre-release checks' + skip_release: + type: boolean + required: false + default: false + description: 'Only run pre-release checks' + +concurrency: + group: publish-release-zetacore + cancel-in-progress: false + +jobs: + release: + uses: ./.github/workflows/release-template.yml + with: + version: ${{ inputs.version }} + skip_checks: ${{ inputs.skip_checks }} + skip_release: ${{ inputs.skip_release }} + component: 'zetacore' + branch_prefix: 'release/zetacore/' + make_snapshot_target: 'release-snapshot-zetacore' + make_release_target: 'release-zetacore' + attestation_paths: | + dist/zetacored_**/* + dist/checksums.txt + include_typescript: true + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release-template.yml b/.github/workflows/release-template.yml new file mode 100644 index 0000000000..b9515c9854 --- /dev/null +++ b/.github/workflows/release-template.yml @@ -0,0 +1,150 @@ +name: Release Template (Reusable) + +on: + workflow_call: + inputs: + version: + description: 'Version for Release' + required: true + type: string + skip_checks: + type: boolean + required: false + default: false + skip_release: + type: boolean + required: false + default: false + component: + description: 'Component to release (zetacore or zetaclient)' + required: true + type: string + branch_prefix: + description: 'Expected branch prefix (e.g., release/zetacore/)' + required: true + type: string + make_snapshot_target: + description: 'Make target for snapshot (e.g., release-snapshot-zetacore)' + required: true + type: string + make_release_target: + description: 'Make target for release (e.g., release-zetacore)' + required: true + type: string + attestation_paths: + description: 'Paths for attestation (multiline string)' + required: true + type: string + include_typescript: + description: 'Whether to publish TypeScript after release' + type: boolean + default: false + +jobs: + log: + runs-on: ubuntu-22.04 + steps: + - name: "Log inputs" + env: + INPUTS: ${{ toJson(inputs) }} + run: echo "${INPUTS}" | jq -r + + check-branch: + if: startsWith(github.ref, format('refs/heads/{0}', inputs.branch_prefix)) + runs-on: ubuntu-22.04 + steps: + - name: Branch + run: echo "${{ github.ref }}" + + check-goreleaser: + runs-on: ${{ vars.RELEASE_RUNNER }} + steps: + - uses: actions/checkout@v4 + - name: Build release snapshot + if: inputs.skip_checks != true + env: + MAKE_SNAPSHOT_TARGET: ${{ inputs.make_snapshot_target }} + run: make "$MAKE_SNAPSHOT_TARGET" + + publish-release: + permissions: + id-token: write + contents: write + attestations: write + if: inputs.skip_release != true + needs: + - check-branch + - check-goreleaser + runs-on: ${{ vars.RELEASE_RUNNER }} + timeout-minutes: 60 + environment: release + steps: + - uses: actions/checkout@v4 + + - name: Change Log Release Notes + id: release_notes + run: | + awk '/^## /{flag++} flag==1{print}' changelog.md > changelog-current.md + cat changelog-current.md + + - name: Set Version + env: + VERSION_INPUT: ${{ inputs.version }} + run: echo "GITHUB_TAG_VERSION=${VERSION_INPUT}" >> ${GITHUB_ENV} + + - name: Create Release Tag + env: + TAG_VERSION: ${{ inputs.version }} + shell: bash + run: | + if git rev-parse "${TAG_VERSION}" >/dev/null 2>&1; then + echo "Error: Tag ${TAG_VERSION} already exists!" + echo "If you need to re-release, either:" + echo " 1. Use a new version number (recommended)" + echo " 2. Manually delete the tag first with: git push --delete origin ${TAG_VERSION}" + exit 1 + fi + git tag "${TAG_VERSION}" + git push --tags + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2.2.0 + with: + prerelease: true + token: ${{ secrets.GITHUB_TOKEN }} + body_path: changelog-current.md + tag_name: ${{ env.GITHUB_TAG_VERSION }} + generate_release_notes: false + + - name: Publish Release Files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ env.GITHUB_TAG_VERSION }} + env: + MAKE_RELEASE_TARGET: ${{ inputs.make_release_target }} + run: | + touch .release-env + make "$MAKE_RELEASE_TARGET" + - name: Artifact Attestations + id: attestation + uses: actions/attest-build-provenance@v2 + with: + subject-path: ${{ inputs.attestation_paths }} + + - name: Upload Attestation Bundle + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_VERSION: ${{ env.GITHUB_TAG_VERSION }} + shell: bash + run: gh release upload "${TAG_VERSION}" "${{ steps.attestation.outputs.bundle-path }}" + + - name: Clean Up Workspace + if: always() + shell: bash + run: sudo rm -rf * || echo "failed to cleanup workspace please investigate" + + publish-typescript: + if: inputs.include_typescript + needs: publish-release + uses: ./.github/workflows/publish-typescript.yml + secrets: inherit \ No newline at end of file diff --git a/.goreleaser-zetaclient.yaml b/.goreleaser-zetaclient.yaml new file mode 100644 index 0000000000..a469d6a40b --- /dev/null +++ b/.goreleaser-zetaclient.yaml @@ -0,0 +1,81 @@ +env: + - CGO_ENABLED=1 + - 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++ + - VERSION={{ .Version }} + - BUILDTIME={{ .Date }} + +before: + hooks: + - go mod download + - go mod tidy + +builds: + - id: "zetaclientd" + main: ./cmd/zetaclientd + binary: "zetaclientd-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + goarch: + - arm64 + - amd64 + flags: &default_flags + - -tags=pebbledb,ledger + 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={{ .FullCommit }} + - -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb + - -X github.com/zeta-chain/node/pkg/constant.Name=zetacored + - -X github.com/zeta-chain/node/pkg/constant.Version={{ .Version }} + - -X github.com/zeta-chain/node/pkg/constant.CommitHash={{ .FullCommit }} + - -X github.com/zeta-chain/node/pkg/constant.BuildTime={{ .CommitDate }} + - -X main.version={{ .Version }} + - -X main.commit={{ .Commit }} + - -X main.date={{ .CommitDate }} + - -buildid= + - -s -w + + - id: "zetae2e" + main: ./cmd/zetae2e + binary: "zetae2e-{{ .Os }}-{{ .Arch }}" + env: + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + goos: + - linux + goarch: + - arm64 + - amd64 + flags: *default_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: + draft: false + target_commitish: "{{ .FullCommit }}" + prerelease: auto + mode: append \ No newline at end of file diff --git a/.goreleaser-zetacore.yaml b/.goreleaser-zetacore.yaml new file mode 100644 index 0000000000..3b06e3a538 --- /dev/null +++ b/.goreleaser-zetacore.yaml @@ -0,0 +1,78 @@ +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 }} + - BUILDTIME={{ .Date }} + +before: + hooks: + - go mod download + - go mod tidy + +builds: + - id: "zetacored" + main: ./cmd/zetacored + binary: "zetacored-{{ .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_flags + - -tags=pebbledb,ledger + 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={{ .FullCommit }} + - -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb + - -X github.com/zeta-chain/node/pkg/constant.Name=zetacored + - -X github.com/zeta-chain/node/pkg/constant.Version={{ .Version }} + - -X github.com/zeta-chain/node/pkg/constant.CommitHash={{ .FullCommit }} + - -X github.com/zeta-chain/node/pkg/constant.BuildTime={{ .CommitDate }} + - -X main.version={{ .Version }} + - -X main.commit={{ .Commit }} + - -X main.date={{ .CommitDate }} + - -buildid= + - -s -w + +archives: + - format: binary + name_template: "{{ .Binary }}" + +checksum: + name_template: "checksums.txt" + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +snapshot: + name_template: "{{ .Tag }}-next" + +release: + draft: false + target_commitish: "{{ .FullCommit }}" + prerelease: auto + mode: append \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9a20ff2968..c7fe6f778c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -12,7 +12,7 @@ env: - CC_darwin_arm64=oa64-clang - CXX_darwin_arm64=oa64-clang++ - CC_darwin_amd64=o64-clang - - CXX_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 diff --git a/Makefile b/Makefile index accb24e6a9..e29966f64b 100644 --- a/Makefile +++ b/Makefile @@ -488,6 +488,30 @@ test-sim-after-import-long ### GoReleaser ### ############################################################################### +release-snapshot-zetacore: + $(GORELEASER) --config .goreleaser-zetacore.yaml --clean --skip=validate --skip=publish --snapshot + +release-snapshot-zetaclient: + $(GORELEASER) --config .goreleaser-zetaclient.yaml --clean --skip=validate --skip=publish --snapshot + +release-zetacore: + @if [ ! -f ".release-env" ]; then \ + echo "\033[91m.release-env is required for release\033[0m";\ + exit 1;\ + fi + $(GORELEASER) --config .goreleaser-zetacore.yaml --clean --skip=validate + +release-zetaclient: + @if [ ! -f ".release-env" ]; then \ + echo "\033[91m.release-env is required for release\033[0m";\ + exit 1;\ + fi + $(GORELEASER) --config .goreleaser-zetaclient.yaml --clean --skip=validate + +### Legacy release commands +# TODO: Remove once new separated zetaclientd/zetacored is fully adopted +# https://github.com/zeta-chain/node/issues/4327 + release-snapshot: $(GORELEASER) --clean --skip=validate --skip=publish --snapshot