diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 2f57f5da8..31734c028 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -5,17 +5,9 @@ on: types: [published] jobs: - releases-matrix: + release: name: Release Go Binary runs-on: ubuntu-latest - strategy: - matrix: - # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 - goos: [ linux, windows, darwin ] - goarch: [ amd64, arm64 ] - exclude: - - goarch: arm64 - goos: windows steps: - uses: actions/checkout@v3 - name: Codebase security check @@ -25,19 +17,17 @@ jobs: go-version: '1.20' env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - - uses: wangyoucao577/go-release-action@v1.40 - env: - MIXPANEL_PROJECT_TOKEN: ${{ secrets.MIXPANEL_PROJECT_TOKEN }} - LILICO_TOKEN: ${{ secrets.LILICO_TOKEN }} - APP_VERSION: $(basename ${GITHUB_REF}) - BUILD_TIME: $(date --iso-8601=seconds) - VERSION: ${{github.ref_name}} - COMMIT: ${{ github.sha }} + - uses: actions/setup-go@v4 with: - pre_command: make generate - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - goversion: "1.20" - project_path: "./cmd/flow" - ldflags: -X "github.com/onflow/flow-cli/build.commit=${{ env.COMMIT }}" -X "github.com/onflow/flow-cli/build.semver=${{ env.VERSION }}" -X "github.com/onflow/flow-cli/internal/command.mixpanelToken=${{ env.MIXPANEL_PROJECT_TOKEN }}" -X "github.com/onflow/flow-cli/internal/accounts.accountToken=${{ env.LILICO_TOKEN }}" + go-version: "1.20" + - name: Setup Release Environment + run: |- + echo 'MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN }}' > .release-env + echo 'LILICO_TOKEN=${{ secrets.LILICO_TOKEN }}' >> .release-env + echo 'APP_VERSION=$(basename ${GITHUB_REF})' >> .release-env + echo 'BUILD_TIME=$(date --iso-8601=seconds)' >> .release-env + echo 'VERSION=${{ github.ref_name }}' >> .release-env + echo 'COMMIT=${{ github.sha }}' >> .release-env + echo 'GITHUB_TOKEN=${{ secrets.FLOW_CLI_RELEASE }}' >> .release-env + - name: Build and Release + run: make release \ No newline at end of file diff --git a/.gitignore b/.gitignore index b8403f505..db38bb5af 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,7 @@ main *.pkey # Local development file generation folder -imports \ No newline at end of file +imports + +# Goreleaser .env +.release-env \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..071526d4e --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,54 @@ +before: + hooks: + - make generate + +builds: + - id: flow-cli + main: ./cmd/flow + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + env: + - CGO_FLAGS="-O2 -D__BLST_PORTABLE__" + - CGO_ENABLED=1 + - CC_darwin_amd64=o64-clang + - CXX_darwin_amd64=o64-clang+ + - CC_darwin_arm64=oa64-clang + - CXX_darwin_arm64=oa64-clang++ + - CC_linux_amd64=x86_64-linux-gnu-gcc + - CXX_linux_amd64=x86_64-linux-gnu-g++ + - CC_linux_arm64=aarch64-linux-gnu-gcc + - CXX_linux_arm64=aarch64-linux-gnu-g++ + - CC_windows_amd64=x86_64-w64-mingw32-gcc + - CXX_windows_amd64=x86_64-w64-mingw32-g++ + - CC_windows_arm64=aarch64-w64-mingw32-gcc + - CXX_windows_arm64=aarch64-w64-mingw32-g++ + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + flags: + - -mod=readonly + ldflags: + - -X github.com/onflow/flow-cli/build.commit={{ .Env.COMMIT }} -X github.com/onflow/flow-cli/build.semver={{ .Env.VERSION }} -X github.com/onflow/flow-cli/internal/command.mixpanelToken={{ .Env.MIXPANEL_PROJECT_TOKEN }} -X github.com/onflow/flow-cli/internal/accounts.accountToken={{ .Env.LILICO_TOKEN }} + +archives: + - id: golang-cross + builds: + - flow-cli + name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + wrap_in_directory: false +snapshot: + name_template: "{{ .Tag }}" +changelog: + skip: true +checksum: + name_template: "checksums.txt" +release: + github: + owner: onflow + name: flow-cli + prerelease: auto + draft: false \ No newline at end of file diff --git a/Makefile b/Makefile index 16692d4bc..a5ac84408 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +# Configuration for goreleaser +PACKAGE_NAME := github.com/onflow/flow-cli +GOLANG_CROSS_VERSION ?= v1.20.0 + # The short Git commit hash SHORT_COMMIT := $(shell git rev-parse --short HEAD) # The Git commit hash @@ -103,3 +107,15 @@ check-tidy: .PHONY: generate generate: install-tools go generate ./... + +.PHONY: release +release: + docker run \ + --rm \ + --env-file .release-env \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v `pwd`/sysroot:/sysroot \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + release --clean \ No newline at end of file diff --git a/go.mod b/go.mod index 892c1aa08..e271dc0ed 100644 --- a/go.mod +++ b/go.mod @@ -272,6 +272,3 @@ require ( nhooyr.io/websocket v1.8.7 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) - -// this is a woraround for the flow-go/crypto cross compliation issue -replace github.com/onflow/crypto => github.com/onflow/crypto v0.24.9 diff --git a/go.sum b/go.sum index c03168fd9..cf04a239e 100644 --- a/go.sum +++ b/go.sum @@ -2068,8 +2068,8 @@ github.com/onflow/cadence-tools/test v1.0.0-M3 h1:ZbKoMhXsvafJIOO/MVE7lV5INXfq2I github.com/onflow/cadence-tools/test v1.0.0-M3/go.mod h1:Yk6OyiRMNseM6C13FpNUxTJ7GekYZMzdX5D2B10y4N8= github.com/onflow/contract-updater/lib/go/templates v1.0.1 h1:xPj898Y8OgLLbXH8+JeKVBV6J+nqPZjiLgGM3Abucto= github.com/onflow/contract-updater/lib/go/templates v1.0.1/go.mod h1:OXO6s0X7OW4Q6QTfAfnjoOmibEPgs0psOfMi+tPyzQE= -github.com/onflow/crypto v0.24.9 h1:jYP1qdwid0qCineFzBFlxBchg710A7RuSWpTqxaOdog= -github.com/onflow/crypto v0.24.9/go.mod h1:J/V7IEVaqjDajvF8K0B/SJPJDgAOP2G+LVLeb0hgmbg= +github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= +github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 h1:IqdUzdqFCSW0klWmA3J9c17ZyQTab9SWcWSLouX6o0Q= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= github.com/onflow/flixkit-go v1.1.1-0.20240214222351-03b90f7d32ef h1:nPtuUuIMBcsl9T15qWzat8hYo6lU6ip2WKoYT2p9H4w= @@ -2359,7 +2359,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/supranational/blst v0.3.10/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=