diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 0000000000..2ccc284a94 --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,35 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: echo "flags=--snapshot" >> $GITHUB_ENV + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + cache: true + - name: GHCR Docker Login + run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean ${{ env.flags }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000000..67ca320417 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,45 @@ +version: 1 + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + goarm: + - 7 + ignore: + - goos: windows + goarch: arm64 + main: ./cmd/geth + binary: geth + +archives: + - format: tar.gz + # This name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # Use zip for windows archives. + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/geth-poa/docker-compose.yml b/geth-poa/docker-compose.yml index 78b13c160b..20a169ce18 100644 --- a/geth-poa/docker-compose.yml +++ b/geth-poa/docker-compose.yml @@ -177,6 +177,8 @@ services: networks: l1_net: ipv4_address: '172.14.0.2' + ports: + - 9545:8545 # Expose RPC port to host as 9545 volumes: - geth-data-l1-bootnode:/data profiles: diff --git a/geth-poa/entrypoint.sh b/geth-poa/entrypoint.sh index b13f134ca7..f0543ef1cf 100644 --- a/geth-poa/entrypoint.sh +++ b/geth-poa/entrypoint.sh @@ -1,8 +1,9 @@ #!/bin/sh set -exu +GETH_BIN_PATH=${GETH_BIN_PATH:-geth} GENESIS_L1_PATH=${GENESIS_L1_PATH:-/genesis.json} -VERBOSITY=3 +VERBOSITY=${VERBOSITY:-3} GETH_DATA_DIR=${GETH_DATA_DIR:-/data} GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata" GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore" @@ -16,7 +17,7 @@ if [ ! -d "$GETH_KEYSTORE_DIR" ] && [ "$GETH_NODE_TYPE" = "signer" ]; then echo "$GETH_KEYSTORE_DIR missing, running account import" echo -n "pwd" > "$GETH_DATA_DIR"/password echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key - geth --verbosity="$VERBOSITY" \ + "$GETH_BIN_PATH" --verbosity="$VERBOSITY" \ --nousb \ account import \ --datadir="$GETH_DATA_DIR" \ @@ -30,7 +31,7 @@ fi if [ ! -d "$GETH_CHAINDATA_DIR" ]; then echo "$GETH_CHAINDATA_DIR missing, running init" echo "Initializing genesis." - geth --verbosity="$VERBOSITY" \ + "$GETH_BIN_PATH" --verbosity="$VERBOSITY" \ --nousb \ --state.scheme=path \ --db.engine=pebble \ @@ -42,6 +43,19 @@ fi # Obtain assigned container IP for p2p NODE_IP=${NODE_IP:-$(hostname -i)} +echo "NODE_IP is set to: $NODE_IP" + +PUBLIC_NODE_IP=${PUBLIC_NODE_IP:-""} +echo "EXTERNAL_NODE_IP is set to: $PUBLIC_NODE_IP" + +# Set NAT_FLAG based on whether PUBLIC_NODE_IP is empty or not +if [ -n "$PUBLIC_NODE_IP" ]; then + NAT_FLAG="--nat=extip:$PUBLIC_NODE_IP" +else + NAT_FLAG="--nat=none" +fi + +# (Optional) Echo the values for verification if [ "$GETH_NODE_TYPE" = "bootnode" ]; then echo "Starting bootnode" @@ -49,7 +63,7 @@ if [ "$GETH_NODE_TYPE" = "bootnode" ]; then # Generate boot.key echo "$BOOT_KEY" > $GETH_DATA_DIR/boot.key - exec geth \ + exec "$GETH_BIN_PATH" \ --verbosity="$VERBOSITY" \ --datadir="$GETH_DATA_DIR" \ --port 30301 \ @@ -78,17 +92,19 @@ if [ "$GETH_NODE_TYPE" = "bootnode" ]; then --pprof.port=60601 \ --nodekey $GETH_DATA_DIR/boot.key \ --netrestrict $NET_RESTRICT \ - --nat extip:$NODE_IP \ + "$NAT_FLAG" \ --txpool.accountqueue=512 \ --rpc.allow-unprotected-txs elif [ "$GETH_NODE_TYPE" = "signer" ]; then echo "Starting signer node" + echo "BOOTNODE_ENDPOINT is set to: $BOOTNODE_ENDPOINT" + GETH_PORT="${GETH_PORT:-30311}" - exec geth \ + exec "$GETH_BIN_PATH" \ --verbosity="$VERBOSITY" \ --datadir="$GETH_DATA_DIR" \ - --port 30311 \ + --port="$GETH_PORT" \ --syncmode=full \ --gcmode=full \ --state.scheme=path \ @@ -124,15 +140,17 @@ elif [ "$GETH_NODE_TYPE" = "signer" ]; then --authrpc.port="8551" \ --authrpc.vhosts="*" \ --txpool.accountqueue=512 \ - --nat extip:$NODE_IP + "$NAT_FLAG" elif [ "$GETH_NODE_TYPE" = "member" ]; then echo "Starting member node" + echo "BOOTNODE_ENDPOINT is set to: $BOOTNODE_ENDPOINT" + GETH_PORT="${GETH_PORT:-30311}" - exec geth \ + exec "$GETH_BIN_PATH" \ --verbosity="$VERBOSITY" \ --datadir="$GETH_DATA_DIR" \ - --port 30311 \ + --port="$GETH_PORT" \ --syncmode=full \ --gcmode=full \ --state.scheme=path \ @@ -162,7 +180,7 @@ elif [ "$GETH_NODE_TYPE" = "member" ]; then --authrpc.port="8551" \ --authrpc.vhosts="*" \ --txpool.accountqueue=512 \ - --nat extip:$NODE_IP + "$NAT_FLAG" else echo "Invalid GETH_NODE_TYPE specified" fi diff --git a/geth-poa/util/deploy_create2.sh b/geth-poa/util/deploy_create2.sh index eda40615ee..197ff8b5f2 100755 --- a/geth-poa/util/deploy_create2.sh +++ b/geth-poa/util/deploy_create2.sh @@ -4,11 +4,13 @@ set -e -if [ -z "$1" ]; then - echo "Usage: $0 " +# Use the first command line argument, if provided. Otherwise, use the environment variable. +JSON_RPC="${1:-$JSON_RPC_URL}" + +if [ -z "$JSON_RPC" ]; then + echo "Usage: $0 or set the JSON_RPC_URL environment variable." exit 1 fi -JSON_RPC="$1" if ! [ -x "$(command -v curl)" ]; then echo "Curl must be installed to deploy the create2 proxy" >&2