diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..1bdccb1fba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + push: + tags: + # run only against tags that follow semver (https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string) + - 'v[0-9]+.[0-9]+.[0-9]+*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.x + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean --config=.goreleaser-cdk.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser-cdk.yaml b/.goreleaser-cdk.yaml new file mode 100644 index 0000000000..9ed20cddb2 --- /dev/null +++ b/.goreleaser-cdk.yaml @@ -0,0 +1,78 @@ +# .goreleaser-cdk.yaml +project_name: cdk-validium-node + +release: + disable: false + draft: true + prerelease: auto + +builds: + - main: ./cmd/ + binary: zkevm-node + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + env: + - CGO_ENABLED=0 + ldflags: + - -s -w + - -X github.com/0xPolygon/{{ .ProjectName }}.Version={{ .Version }} + - -X github.com/0xPolygon/{{ .ProjectName }}.GitRev={{ .Commit }} + - -X github.com/0xPolygon/{{ .ProjectName }}.BuildDate={{ .Date }} + - -X github.com/0xPolygon/{{ .ProjectName }}.GitBranch={{ .Branch }} + +archives: + - files: + - LICENSE + - README.md + +dockers: + - image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + dockerfile: Dockerfile.release + use: buildx + goos: linux + goarch: amd64 + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + skip_push: false + + - image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 + dockerfile: Dockerfile.release + use: buildx + goos: linux + goarch: arm64 + build_flag_templates: + - --platform=linux/arm64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + skip_push: false + +docker_manifests: + - name_template: 0xpolygon/{{ .ProjectName }}:{{ .Version }} + image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 + skip_push: false + + - name_template: 0xpolygon/{{ .ProjectName }}:latest + image_templates: + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 + skip_push: false diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 0000000000..58f865eaa3 --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,12 @@ +FROM alpine:3.16.0 + +EXPOSE 8123 + +COPY zkevm-node /usr/local/bin + +RUN addgroup -S zkevm-group \ + && adduser -S zkevm-user -G zkevm-group + +USER zkevm-user + +ENTRYPOINT ["zkevm-node"]