Skip to content

Commit

Permalink
Merge pull request #82 from 0xPolygon/CDK-71-introduce-goreleaser-on-…
Browse files Browse the repository at this point in the history
…cdk-validum-node

goreleaser for validium node
  • Loading branch information
christophercampbell authored Feb 26, 2024
2 parents 3953b4e + c56be7d commit f5d2c80
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
78 changes: 78 additions & 0 deletions .goreleaser-cdk.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit f5d2c80

Please sign in to comment.