From 282ef8952d0196c6e4176db51e8be4e875e267e8 Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Mon, 24 Apr 2023 22:30:27 +0800 Subject: [PATCH] ci: fix release job (#1519) * ci: remove CGO_ENABLE=0 due to blst package * ci: fix arm binary build * ci: remove arm5-7 version * ci: fix arm64 build script * ci: fix generate_change_log.sh --- .github/generate_change_log.sh | 22 ++++------- .github/workflows/pre-release.yml | 62 +++++++++---------------------- .github/workflows/release.yml | 62 +++++++++---------------------- Dockerfile | 8 ++-- Dockerfile.alltools | 4 ++ Makefile | 18 --------- README.md | 10 +++++ build/ci.go | 37 ++++++++++-------- 8 files changed, 81 insertions(+), 142 deletions(-) diff --git a/.github/generate_change_log.sh b/.github/generate_change_log.sh index 9caf6f202..b50893ddf 100755 --- a/.github/generate_change_log.sh +++ b/.github/generate_change_log.sh @@ -24,26 +24,20 @@ TESTNET_ZIP_SUM="$(checksum ./testnet.zip)" LINUX_BIN_SUM="$(checksum ./linux/geth)" MAC_BIN_SUM="$(checksum ./macos/geth)" WINDOWS_BIN_SUM="$(checksum ./windows/geth.exe)" -ARM5_BIN_SUM="$(checksum ./arm5/geth-linux-arm-5)" -ARM6_BIN_SUM="$(checksum ./arm6/geth-linux-arm-6)" -ARM7_BIN_SUM="$(checksum ./arm7/geth-linux-arm-7)" ARM64_BIN_SUM="$(checksum ./arm64/geth-linux-arm64)" OUTPUT=$(cat <<-END ## Changelog\n ${CHANGE_LOG}\n ## Assets\n -| Assets | Sha256 Checksum |\n -| :-----------: |------------|\n -| mainnet.zip | ${MAINNET_ZIP_SUM} |\n -| testnet.zip | ${TESTNET_ZIP_SUM} |\n -| geth_linux | ${LINUX_BIN_SUM} |\n -| geth_mac | ${MAC_BIN_SUM} |\n -| geth_windows | ${WINDOWS_BIN_SUM} |\n -| geth_linux_arm-5 | ${ARM5_BIN_SUM} |\n -| geth_linux_arm-6 | ${ARM6_BIN_SUM} |\n -| geth_linux_arm-7 | ${ARM7_BIN_SUM} |\n +| Assets | Sha256 Checksum | +| :-----------: |------------| +| mainnet.zip | ${MAINNET_ZIP_SUM} | +| testnet.zip | ${TESTNET_ZIP_SUM} | +| geth_linux | ${LINUX_BIN_SUM} | +| geth_mac | ${MAC_BIN_SUM} | +| geth_windows | ${WINDOWS_BIN_SUM} | | geth_linux_arm64 | ${ARM64_BIN_SUM} |\n END ) -echo -e ${OUTPUT} \ No newline at end of file +echo -e "${OUTPUT}" \ No newline at end of file diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index df63b64ca..e9979b069 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -44,8 +44,17 @@ jobs: # ============================== - name: Build Binary for ${{matrix.os}} - env: - CGO_ENABLED: "0" + if: matrix.os == 'ubuntu-latest' + run: | + go mod download + wget https://musl.cc/x86_64-linux-musl-cross.tgz + tar -xvf ./x86_64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth + + - name: Build Binary for ${{matrix.os}} + if: matrix.os != 'ubuntu-latest' run: | go mod download make geth @@ -58,7 +67,12 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | go mod download - make geth-linux-arm + wget https://musl.cc/aarch64-linux-musl-cross.tgz + tar -xvf ./aarch64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth-linux-arm64 -a ./cmd/geth + # ============================== # Upload artifacts # ============================== @@ -84,27 +98,6 @@ jobs: name: windows path: ./build/bin/geth.exe - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm5 - path: ./build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm6 - path: ./build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm7 - path: ./build/bin/geth-linux-arm-7 - - name: Upload ARM-64 Build uses: actions/upload-artifact@v3 if: matrix.os == 'ubuntu-latest' @@ -145,24 +138,6 @@ jobs: name: windows path: ./windows - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm7 - path: ./arm7 - - name: Download Artifacts uses: actions/download-artifact@v3 with: @@ -204,7 +179,4 @@ jobs: ./linux/geth_linux ./macos/geth_macos ./windows/geth_windows.exe - ./arm5/geth-linux-arm-5 - ./arm6/geth-linux-arm-6 - ./arm7/geth-linux-arm-7 ./arm64/geth-linux-arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fd5ecf23..e771923e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,8 +44,17 @@ jobs: # ============================== - name: Build Binary for ${{matrix.os}} - env: - CGO_ENABLED: "0" + if: matrix.os == 'ubuntu-latest' + run: | + go mod download + wget https://musl.cc/x86_64-linux-musl-cross.tgz + tar -xvf ./x86_64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=$(pwd)/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth -a ./cmd/geth + + - name: Build Binary for ${{matrix.os}} + if: matrix.os != 'ubuntu-latest' run: | go mod download make geth @@ -58,7 +67,12 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | go mod download - make geth-linux-arm + wget https://musl.cc/aarch64-linux-musl-cross.tgz + tar -xvf ./aarch64-linux-musl-cross.tgz + GIT_COMMIT=$(git rev-parse HEAD) + GIT_COMMIT_DATE=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d') + GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.gitDate=$GIT_COMMIT_DATE -extldflags=-static" -o ./build/bin/geth-linux-arm64 -a ./cmd/geth + # ============================== # Upload artifacts # ============================== @@ -84,27 +98,6 @@ jobs: name: windows path: ./build/bin/geth.exe - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm5 - path: ./build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm6 - path: ./build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v3 - if: matrix.os == 'ubuntu-latest' - with: - name: arm7 - path: ./build/bin/geth-linux-arm-7 - - name: Upload ARM-64 Build uses: actions/upload-artifact@v3 if: matrix.os == 'ubuntu-latest' @@ -145,24 +138,6 @@ jobs: name: windows path: ./windows - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v3 - with: - name: arm7 - path: ./arm7 - - name: Download Artifacts uses: actions/download-artifact@v3 with: @@ -211,7 +186,4 @@ jobs: ./linux/geth_linux ./macos/geth_macos ./windows/geth_windows.exe - ./arm5/geth-linux-arm-5 - ./arm6/geth-linux-arm-6 - ./arm7/geth-linux-arm-7 ./arm64/geth-linux-arm64 diff --git a/Dockerfile b/Dockerfile index ecbc855cd..12815f435 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,6 @@ COPY go.sum /go-ethereum/ RUN cd /go-ethereum && go mod download ADD . /go-ethereum -ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" -ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth # Pull Geth into a second stage deploy alpine container @@ -28,10 +26,9 @@ ENV BSC_HOME=/bsc ENV HOME=${BSC_HOME} ENV DATA_DIR=/data -ARG VERSION_GCC=11.2.1_git20220219-r2 ENV PACKAGES ca-certificates jq \ bash bind-tools tini \ - grep curl sed gcc==${VERSION_GCC} + grep curl sed gcc RUN apk add --no-cache $PACKAGES \ && rm -rf /var/cache/apk/* \ @@ -59,4 +56,7 @@ USER ${BSC_USER_UID}:${BSC_USER_GID} # rpc ws graphql EXPOSE 8545 8546 8547 30303 30303/udp +# For blst runtime env +ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" +ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" ENTRYPOINT ["/sbin/tini", "--", "./docker-entrypoint.sh"] \ No newline at end of file diff --git a/Dockerfile.alltools b/Dockerfile.alltools index 3205b412e..c968551d1 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -29,3 +29,7 @@ ARG VERSION="" ARG BUILDNUM="" LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM" + +# For blst runtime env +ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" +ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" diff --git a/Makefile b/Makefile index c18cdddea..adda257e7 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ .PHONY: geth android ios evm all test truffle-test clean .PHONY: docker -.PHONY: geth-linux-arm geth-linux-arm64 geth-linux-arm5 geth-linux-arm6 geth-linux-arm7 GOBIN = ./build/bin GO ?= latest @@ -17,23 +16,6 @@ geth: @echo "Done building." @echo "Run \"$(GOBIN)/geth\" to launch geth." -ldflags = -X main.gitCommit=$(GIT_COMMIT) \ - -X main.gitDate=$(GIT_COMMIT_DATE) - -geth-linux-arm: geth-linux-arm5 geth-linux-arm6 geth-linux-arm7 geth-linux-arm64 - -geth-linux-arm5: - env GO111MODULE=on GOARCH=arm GOARM=5 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-5 ./cmd/geth - -geth-linux-arm6: - env GO111MODULE=on GOARCH=arm GOARM=6 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-6 ./cmd/geth - -geth-linux-arm7: - env GO111MODULE=on GOARCH=arm GOARM=7 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm-7 ./cmd/geth - -geth-linux-arm64: - env GO111MODULE=on GOARCH=arm64 GOOS=linux go build -ldflags="$(ldflags)" -o build/bin/geth-linux-arm64 ./cmd/geth - all: $(GORUN) build/ci.go install diff --git a/README.md b/README.md index 9b6c28f24..20d8ecbaf 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,16 @@ Download latest chaindata snapshot from [here](https://github.com/bnb-chain/bsc- ./geth --config ./config.toml --datadir ./node --cache 8000 --rpc.allow-unprotected-txs --txlookuplimit 0 --tries-verify-mode none ``` +if you get such error: +```shell +Caught SIGILL in blst_cgo_init, consult /bindinds/go/README.md. +``` +please try to add the following environment variables: +```shell +export CGO_CFLAGS="-O -D__BLST_PORTABLE__" +export CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" +``` + #### 5. Monitor node status Monitor the log from **./node/bsc.log** by default. When the node has started syncing, should be able to see the following output: diff --git a/build/ci.go b/build/ci.go index d036b7d6e..80599916c 100644 --- a/build/ci.go +++ b/build/ci.go @@ -24,19 +24,18 @@ Usage: go run build/ci.go Available commands are: - install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables - test [ -coverage ] [ packages... ] -- runs the tests - lint -- runs certain pre-selected linters - archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts - importkeys -- imports signing keys from env - debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package - nsis -- creates a Windows NSIS installer - aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive - xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework - purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore + install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables + test [ -coverage ] [ packages... ] -- runs the tests + lint -- runs certain pre-selected linters + archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts + importkeys -- imports signing keys from env + debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package + nsis -- creates a Windows NSIS installer + aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive + xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework + purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore For all commands, -n prevents execution of external programs (dry run mode). - */ package main @@ -198,9 +197,10 @@ func main() { func doInstall(cmdline []string) { var ( - dlgo = flag.Bool("dlgo", false, "Download Go and build with it") - arch = flag.String("arch", "", "Architecture to cross build for") - cc = flag.String("cc", "", "C compiler to cross build with") + dlgo = flag.Bool("dlgo", false, "Download Go and build with it") + arch = flag.String("arch", "", "Architecture to cross build for") + cc = flag.String("cc", "", "C compiler to cross build with") + output = flag.String("o", "", "Output directory for build artifacts") ) flag.CommandLine.Parse(cmdline) @@ -213,7 +213,8 @@ func doInstall(cmdline []string) { // Configure the build. env := build.Env() - gobuild := tc.Go("build", buildFlags(env)...) + buildArgs := buildFlags(env) + gobuild := tc.Go("build", buildArgs...) // arm64 CI builders are memory-constrained and can't handle concurrent builds, // better disable it. This check isn't the best, it should probably @@ -239,7 +240,11 @@ func doInstall(cmdline []string) { for _, pkg := range packages { args := make([]string, len(gobuild.Args)) copy(args, gobuild.Args) - args = append(args, "-o", executablePath(path.Base(pkg))) + outputPath := executablePath(path.Base(pkg)) + if output != nil && *output != "" { + outputPath = *output + } + args = append(args, "-o", outputPath) args = append(args, pkg) build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env}) }