From 80c59c133d2fd2ff478b72956880ab3995433721 Mon Sep 17 00:00:00 2001 From: Karan Sharma Date: Thu, 14 Sep 2023 11:42:24 +0530 Subject: [PATCH] feat: add goreleaser for build and release steps (#20) fixes #8 --- .github/workflows/release.yaml | 34 +++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yml | 50 ++++++++++++++++++++++++++++++++++ Dockerfile | 5 ++++ 4 files changed, 90 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..a7f502f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - "v*" + +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@v4 + with: + go-version: 1.21 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --parallelism 1 --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 2ee011a..5332c44 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ config.toml # build pb bin/ +dist/ # OS Files .DS_Store diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..8a7f0aa --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,50 @@ +env: + - GO111MODULE=on + - CGO_ENABLED=0 + +builds: + - binary: pb + id: pb + main: ./main.go + goos: + - windows + - darwin + - linux + goarch: + - amd64 + - arm64 + flags: + - -trimpath + - -tags=kqueue + ldflags: + - -s -w -X main.Version={{ .Version }} -X main.Commit={{ .ShortCommit }} + +archives: + - format: tar.gz + rlcp: true + files: + - README.md + - LICENSE + +dockers: + - id: pb + goos: linux + goarch: amd64 + ids: + - pb + image_templates: + - "parseablehq/pb:{{ .Tag }}" + - "parseablehq/pb:latest" + skip_push: false + dockerfile: Dockerfile + use: docker + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title=Parseable" + - "--label=maintainer=Parseable Team " + - "--label=org.opencontainers.image.vendor=Cloudnatively Pvt Ltd" + - "--label=org.opencontainers.image.licenses=AGPL-3.0" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--platform=linux/amd64" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..65e07a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:22.04 +RUN apt-get -y update && apt install -y ca-certificates +WORKDIR /app +COPY pb . +ENTRYPOINT [ "./pb" ]