Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

[DVT-85] add goreleaser to erigon github actions #3

Merged
merged 16 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
# to be used by fork patch-releases ^^
- 'v*.*.*-*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.18.x

- name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Run GoReleaser
run: |
make release
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ go.work

/goerli

docker-compose.*.yml
docker-compose.*.yml

dist
132 changes: 132 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
project_name: erigon

release:
disable: false
draft: true
prerelease: auto

builds:
- id: darwin-amd64
main: ./cmd/erigon
binary: erigon
goos:
- darwin
goarch:
- amd64
env:
- CC=o64-clang
- CXX=o64-clang++
tags:
- netgo
ldflags:
-s -w

- id: darwin-arm64
main: ./cmd/erigon
binary: erigon
goos:
- darwin
goarch:
- arm64
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags:
- netgo
ldflags:
-s -w

- id: linux-amd64
main: ./cmd/erigon
binary: erigon
goos:
- linux
goarch:
- amd64
env:
- CC=gcc
- CXX=g++
tags:
- netgo
ldflags:
# We need to build a static binary because we are building in a glibc based system and running in a musl container
-s -w -extldflags "-static"

- id: linux-arm64
main: ./cmd/erigon
binary: erigon
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
tags:
- netgo
ldflags:
# We need to build a static binary because we are building in a glibc based system and running in a musl container
-s -w -extldflags "-static"

nfpms:
- vendor: 0xPolygon
homepage: https://polygon.technology
maintainer: Polygon Team <team@polygon.technology>
description: Polygon Blockchain
license: GPLv3 LGPLv3

formats:
- apk
- deb
- rpm

contents:
- src: builder/files/erigon.service
dst: /lib/systemd/system/erigon.service
type: config

overrides:
rpm:
replacements:
amd64: x86_64

snapshot:
name_template: "{{ .Tag }}.next"

dockers:
- image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
use: buildx
goarch: amd64
ids:
- linux-amd64
build_flag_templates:
- --platform=linux/amd64

- image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64
dockerfile: Dockerfile.release
use: buildx
goarch: arm64
ids:
- linux-arm64
build_flag_templates:
- --platform=linux/arm64/v8

docker_manifests:
- name_template: 0xpolygon/{{ .ProjectName }}:{{ .Version }}
image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64

- name_template: 0xpolygon/{{ .ProjectName }}:latest
image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64

announce:
slack:
enabled: false
# The name of the channel that the user selected as a destination for webhook messages.
channel: '#code-releases'
8 changes: 8 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:3.14

RUN apk add --no-cache ca-certificates && \
mkdir -p /etc/erigon
COPY erigon /usr/local/bin/

EXPOSE 8545 8551 8546 30303 30303/udp 42069 42069/udp 8080 9090 6060
ENTRYPOINT ["erigon"]
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,37 @@ git-submodules:
@# Dockerhub using ./hooks/post-checkout to set submodules, so this line will fail on Dockerhub
@git submodule sync --quiet --recursive
@git submodule update --quiet --init --recursive --force || true


PACKAGE_NAME := github.com/maticnetwork/erigon
GOLANG_CROSS_VERSION ?= v1.18.1

.PHONY: release-dry-run
release-dry-run: git-submodules
@docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN \
-e DOCKER_USERNAME \
-e DOCKER_PASSWORD \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish

.PHONY: release
release: git-submodules
@docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN \
-e DOCKER_USERNAME \
-e DOCKER_PASSWORD \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate
34 changes: 34 additions & 0 deletions builder/files/erigon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[Unit]
Description=erigon
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/erigon \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to specify the bindir for nfpm or does it default to this location

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--chain=mumbai \
# --chain=mainnet \
--datadir /var/lib/erigon/data \
--metrics \
--metrics.prometheus-addr="127.0.0.1:9090" \
--syncmode 'full' \
--miner.gasprice '30000000000' \
--miner.gaslimit '20000000' \
--miner.gastarget '20000000' \
--txpool.nolocals \
--txpool.accountslots 16 \
--txpool.globalslots 32768 \
--txpool.accountqueue 16 \
--txpool.globalqueue 32768 \
--txpool.pricelimit '30000000000' \
--txpool.lifetime '1h30m0s' \
--bootnodes "enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303,enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303"
WorkingDirectory=$NODE_DIR
Type=simple
User=$USER
KillSignal=SIGINT
TimeoutStopSec=120

[Install]
WantedBy=multi-user.target