Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Introduce goreleaser (#65)
Browse files Browse the repository at this point in the history
* Introduce goreleaser (basic setup)

* Introduce Docker build and push

* Add Docker images building and publishing as part of the goreleaser configuration

* Remove docker-push-tagged GH action

* Fix LICENSE filename

* Fix path to the Dockerfile

* Change semver regex for tag names

* Remove license label from docker images

* Introduce Dockerfile.release

* Try to fix dockerfile

* Change tag name regex

* Try with adding binary tag

* Add go.mod and go.sum to the archive

* Eventually need to have minimal Dockerfile used by goreleaser

* Change copy destination

* Assign ids to artifacts built for linux because of Docker images building

* Remove symbols and debug info from the binary
  • Loading branch information
Stefan-Ethernal authored Feb 13, 2024
1 parent 5220742 commit f9d7d52
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/release.yaml
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 }}
113 changes: 113 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# .goreleaser.yaml
project_name: agglayer

release:
disable: false
draft: true
prerelease: auto

builds:
- id: linux-amd64
main: ./cmd/
binary: agglayer
goos:
- linux
goarch:
- amd64
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X github.com/0xPolygon/agglayer.Version={{ .Version }}
- -X github.com/0xPolygon/agglayer.GitRev={{ .Commit }}
- -X github.com/0xPolygon/agglayer.BuildDate={{ .Date }}
- -X github.com/0xPolygon/agglayer.GitBranch={{ .Branch }}

- id: linux-arm64
main: ./cmd/
binary: agglayer
goos:
- linux
goarch:
- arm64
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X github.com/0xPolygon/agglayer.Version={{ .Version }}
- -X github.com/0xPolygon/agglayer.GitRev={{ .Commit }}
- -X github.com/0xPolygon/agglayer.BuildDate={{ .Date }}
- -X github.com/0xPolygon/agglayer.GitBranch={{ .Branch }}

- main: ./cmd/
binary: agglayer
goos:
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- -s -w
- -X github.com/0xPolygon/agglayer.Version={{ .Version }}
- -X github.com/0xPolygon/agglayer.GitRev={{ .Commit }}
- -X github.com/0xPolygon/agglayer.BuildDate={{ .Date }}
- -X github.com/0xPolygon/agglayer.GitBranch={{ .Branch }}

archives:
- files:
- LICENSE.md
- README.md

dockers:
- image_templates:
- 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
use: buildx
goos: linux
goarch: amd64
ids:
- linux-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
ids:
- linux-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
7 changes: 7 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.16.0

EXPOSE 8444

COPY agglayer /usr/local/bin

ENTRYPOINT ["agglayer"]

0 comments on commit f9d7d52

Please sign in to comment.