Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goreleaser for validium node #82

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 76 additions & 20 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,78 @@
# .goreleaser.yaml
builds:
- main: ./cmd/
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/0xPolygonHermez/zkevm-node.Version={{.Version}}
- -X github.com/0xPolygonHermez/zkevm-node.GitRev={{.Commit}}
- -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{.Date}}
- -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{.Branch}}
project_name: cdk-validium-node

release:
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: true
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/cdk-validium-node.Version={{ .Version }}
- -X github.com/0xPolygon/cdk-validium-node.GitRev={{ .Commit }}
- -X github.com/0xPolygon/cdk-validium-node.BuildDate={{ .Date }}
- -X github.com/0xPolygon/cdk-validium-node.GitBranch={{ .Branch }}
christophercampbell marked this conversation as resolved.
Show resolved Hide resolved

archives:
- files:
- LICENSE
- README.md

dockers:
- image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64

Choose a reason for hiding this comment

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

We should tweek the version here as it will try to push +cdk tags that are not compatible with docker

Choose a reason for hiding this comment

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

@vcastellm would changing the +cdk to -cdk work? As in

{{ replace .Version "+" "-" }}

Choose a reason for hiding this comment

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

And do all the uses of Version have to change? name_templates, image_templates, flag_templates?

Choose a reason for hiding this comment

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

hmm only the strings that correspond to docker tags

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 }}:{{ .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 }}:{{ .Version }}-amd64
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64
skip_push: false

- name_template: 0xpolygon/{{ .ProjectName }}:latest
image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64
- 0xpolygon/{{ .ProjectName }}:{{ .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 8444
christophercampbell marked this conversation as resolved.
Show resolved Hide resolved

COPY zkevm-node /usr/local/bin

RUN addgroup -S zkevm-group \
&& adduser -S zkevm-user -G zkevm-group

USER cdk-dac-user
christophercampbell marked this conversation as resolved.
Show resolved Hide resolved

ENTRYPOINT ["zkevm-node"]
Loading