diff --git a/.env b/.env index c6a3b527ff..8235e23c8e 100644 --- a/.env +++ b/.env @@ -1,7 +1,8 @@ -GOLANG_VERSION=1.20.2 -KIND_VERSION=0.11.1 GO111MODULE=on + +KIND_VERSION=0.11.1 ROOT_DIR=${AKASH_ROOT} + AKASH_DEVCACHE_BASE=${AKASH_ROOT}/.cache AKASH_DEVCACHE=${AKASH_DEVCACHE_BASE} AKASH_DEVCACHE_BIN=${AKASH_DEVCACHE}/bin diff --git a/.envrc b/.envrc index 6daf7ad289..595a89f9b2 100644 --- a/.envrc +++ b/.envrc @@ -26,6 +26,7 @@ if ! has readlink ; then echo "readlink is not installed"; exit 1 fi + AKASH_ROOT=$(pwd) export AKASH_ROOT @@ -33,9 +34,16 @@ export AKASH_ROOT dotenv dotenv_if_exists dev.env +GOROOT=$HOME/sdk/go1.21.0 + +PATH_add "$GOROOT/bin" + PATH_add "$AKASH_DEVCACHE_NODE_BIN" PATH_add "$AKASH_DEVCACHE_BIN" -export AKASH=$AKASH_DEVCACHE_BIN/akash +AKASH=$AKASH_DEVCACHE_BIN/akash + +export GOROOT +export AKASH make cache diff --git a/.github/workflows/dispatch.yaml b/.github/workflows/dispatch.yaml new file mode 100644 index 0000000000..b093e152d5 --- /dev/null +++ b/.github/workflows/dispatch.yaml @@ -0,0 +1,32 @@ +name: dispatch + +defaults: + run: + shell: bash + +on: + push: + +jobs: + dispatch-akash: + runs-on: ubuntu-latest + steps: + - name: notify goreleaser-cross with new release + uses: benc-uk/workflow-dispatch@v1 + with: + token: ${{ secrets.GORELEASER_ACCESS_TOKEN }} + repo: akash-network/homebrew-tap + workflow: akash + ref: refs/heads/main + inputs: '{ "tag" : "${{ env.RELEASE_TAG }}" }' + dispatch-provider: + runs-on: ubuntu-latest + steps: + - name: notify homebrew with new release + uses: benc-uk/workflow-dispatch@v1 + with: + token: ${{ secrets.GORELEASER_ACCESS_TOKEN }} + repo: akash-network/homebrew-tap + workflow: provider-services + ref: refs/heads/main + inputs: '{"tag": "${{ env.RELEASE_TAG }}"}' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f28cf15977..f5dc36b04d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,12 +13,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -49,9 +53,14 @@ jobs: - run: git fetch --prune --unshallow - name: set environment uses: HatsuneMiku3939/direnv-action@v1 - - uses: actions/setup-go@v3 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - name: detect release tag run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - name: configure variables diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index df12e5988c..aac558158c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,30 +17,38 @@ jobs: build-macos: runs-on: macos-latest steps: + - run: | + brew install bash direnv + sudo chsh -s /usr/local/bin/bash - uses: actions/checkout@v3 - run: git fetch --prune --unshallow + - name: set environment + run: direnv allow - run: | - while IFS='' read -r LINE || [ -n "${LINE}" ]; do - echo "$LINE" >> $GITHUB_ENV; - done < .env - - run: | - brew install bash - sudo chsh -s /usr/local/bin/bash - - uses: actions/setup-go@v3 + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT= /Users/runner/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - run: make bins build-bins: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" + check-latest: true - run: make bins - run: make docker-image @@ -49,12 +57,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - run: make test-full coverage: @@ -62,12 +74,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - run: make test-coverage - uses: codecov/codecov-action@v3 @@ -76,12 +92,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - run: make deps-tidy - run: make build - run: make test-vet @@ -95,12 +115,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - run: make shellcheck sims: @@ -110,12 +134,16 @@ jobs: env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - uses: actions/checkout@v3 - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - name: test-sim-nondeterminism run: make test-sim-nondeterminism - name: test-sim-import-export @@ -130,12 +158,16 @@ jobs: steps: - uses: actions/checkout@v3 - run: git fetch --prune --unshallow - - uses: c-py/action-dotenv-to-setenv@v3 - with: - env-file: .env - - uses: actions/setup-go@v3 + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -175,9 +207,14 @@ jobs: - run: git fetch --prune --unshallow - name: set environment uses: HatsuneMiku3939/direnv-action@v1 - - uses: actions/setup-go@v3 + - run: | + toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//') + echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV + - uses: actions/setup-go@v4 with: - go-version: "${{ env.GOLANG_VERSION }}" + go-version: "${{ env.GOVERSION }}" - name: configure variables run: | test_required=$(./script/upgrades.sh test-required ${{ github.ref }}) diff --git a/.goreleaser-docker.yaml b/.goreleaser-docker.yaml index 06e7c1cf00..ec0f5068c3 100644 --- a/.goreleaser-docker.yaml +++ b/.goreleaser-docker.yaml @@ -75,3 +75,4 @@ dockers: archives: - format: binary + rlcp: true diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 36b2690ecb..10a8d781eb 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -113,7 +113,6 @@ archives: name_template: "akash_{{ .Version }}_{{ .Os }}_{{ .Arch }}" wrap_in_directory: false format: zip - rlcp: true files: - none* - id: wo/version @@ -125,7 +124,6 @@ archives: name_template: "akash_{{ .Os }}_{{ .Arch }}" wrap_in_directory: false format: zip - rlcp: true files: - none* diff --git a/go.mod b/go.mod index ed4a9d883e..cd739a62a0 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/akash-network/node go 1.20 +toolchain go1.21.0 + require ( github.com/akash-network/akash-api v0.0.26 github.com/blang/semver/v4 v4.0.0 diff --git a/make/init.mk b/make/init.mk index 5847e81042..d347724645 100644 --- a/make/init.mk +++ b/make/init.mk @@ -21,40 +21,30 @@ ifndef AKASH_ROOT PATH := $(AKASH_DEVCACHE_BIN):$(AKASH_DEVCACHE_NODE_BIN):$(PATH) endif -SEMVER := $(ROOT_DIR)/script/semver.sh - -# require go. to be equal -GO_MIN_REQUIRED := $(shell echo $(GOLANG_VERSION) | cut -f1-2 -d ".") -DETECTED_GO_VERSION := $(shell go version | cut -d ' ' -f 3 | sed 's/go*//') -STRIPPED_GO_VERSION := $(shell echo $(DETECTED_GO_VERSION) | cut -f1-2 -d ".") -__IS_GO_UPTODATE := $(shell $(ROOT_DIR)/script/semver.sh compare $(STRIPPED_GO_VERSION) $(GO_MIN_REQUIRED); echo $?) -GO_MOD_VERSION := $(shell go mod edit -json | jq -r .Go | cut -f1-2 -d ".") -__IS_GO_MOD_MATCHING := $(shell $(SEMVER) compare $(GO_MOD_VERSION) $(GO_MIN_REQUIRED) && echo $?) - -ifneq (0, $(__IS_GO_MOD_MATCHING)) -$(error go version $(GO_MOD_VERSION) from go.mod does not match GO_MIN_REQUIRED=$(GO_MIN_REQUIRED)) -endif +BINS := $(AKASH) +SEMVER := $(AKASH_ROOT)/script/semver.sh -ifneq (0, $(__IS_GO_UPTODATE)) -$(error invalid go$(DETECTED_GO_VERSION) version. installed must be == $(GO_MIN_REQUIRED)) -else -$(info using go$(DETECTED_GO_VERSION)) +__local_go := $(shell GOTOOLCHAIN=local go version | cut -d ' ' -f 3 | sed 's/go*//' | tr -d '\n') +__is_local_go_satisfies := $(shell $(SEMVER) compare "v$(__local_go)" "v1.20.7"; echo $?) + +ifeq (-1, $(__is_local_go_satisfies)) +$(error "unsupported local go$(__local_go) version . min required go1.21.0") endif -BINS := $(AKASH) +GO_VERSION := $(shell go mod edit -json | jq -r .Go | tr -d '\n') +GOTOOLCHAIN := $(shell go mod edit -json | jq -r .Toolchain | tr -d '\n') +GOTOOLCHAIN_SEMVER := v$(shell echo "$(GOTOOLCHAIN)" | sed 's/go*//' | tr -d '\n') +GO := GO111MODULE=$(GO111MODULE) go GOWORK ?= on - GO_MOD ?= vendor ifeq ($(GOWORK), on) GO_MOD := readonly endif -GO := GO111MODULE=$(GO111MODULE) go GO_BUILD := $(GO) build -mod=$(GO_MOD) GO_TEST := $(GO) test -mod=$(GO_MOD) GO_VET := $(GO) vet -mod=$(GO_MOD) - GO_MOD_NAME := $(shell go list -m 2>/dev/null) ifeq ($(OS),Windows_NT) @@ -63,13 +53,13 @@ else DETECTED_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown') endif -# on MacOS disable deprecation warnings security framework ifeq ($(DETECTED_OS), Darwin) + # on MacOS disable deprecation warnings security framework export CGO_CFLAGS=-Wno-deprecated-declarations # on MacOS Sonoma Beta there is a bit of discrepancy between Go and new prime linker clang_version := $(shell echo | clang -dM -E - | grep __clang_major__ | cut -d ' ' -f 3 | tr -d '\n') - go_has_ld_fix := $(shell $(SEMVER) compare "v$(DETECTED_GO_VERSION)" "v1.21.0" | tr -d '\n') + go_has_ld_fix := $(shell $(SEMVER) compare "v$(GOTOOLCHAIN_SEMVER)" "v1.22.0" | tr -d '\n') ifeq (15,$(clang_version)) ifeq (-1,$(go_has_ld_fix)) @@ -81,11 +71,10 @@ endif # ==== Build tools versions ==== # Format _VERSION GOLANGCI_LINT_VERSION ?= v1.51.2 -GOLANG_VERSION ?= 1.16.1 STATIK_VERSION ?= v0.1.7 GIT_CHGLOG_VERSION ?= v0.15.1 MOCKERY_VERSION ?= 2.24.0 -COSMOVISOR_VERSION ?= v1.4.0 +COSMOVISOR_VERSION ?= v1.5.0 # ==== Build tools version tracking ==== # _VERSION_FILE points to the marker file for the installed version. diff --git a/make/releasing.mk b/make/releasing.mk index 1967f5d876..1c83ea4804 100644 --- a/make/releasing.mk +++ b/make/releasing.mk @@ -2,7 +2,7 @@ GON_CONFIGFILE ?= gon.json GORELEASER_SKIP_VALIDATE ?= false GORELEASER_DEBUG ?= false -GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GOLANG_VERSION) +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GOTOOLCHAIN_SEMVER) GORELEASER_RELEASE ?= false GORELEASER_MOUNT_CONFIG ?= false @@ -67,6 +67,7 @@ docker-image: -e LINKMODE="$(GO_LINKMODE)" \ -e DOCKER_IMAGE=$(RELEASE_DOCKER_IMAGE) \ -e GOPATH=/go \ + -e GOTOOLCHAIN="$(GOTOOLCHAIN)" \ -v $(GOPATH):/go:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -v `pwd`:/go/src/$(GO_MOD_NAME) \ @@ -96,6 +97,7 @@ release: gen-changelog -e GITHUB_TOKEN="$(GITHUB_TOKEN)" \ -e GORELEASER_CURRENT_TAG="$(RELEASE_TAG)" \ -e DOCKER_IMAGE=$(RELEASE_DOCKER_IMAGE) \ + -e GOTOOLCHAIN="$(GOTOOLCHAIN)" \ -e GOPATH=/go \ -v $(GOPATH):/go:ro \ -v /var/run/docker.sock:/var/run/docker.sock \