Skip to content

Commit

Permalink
feat: prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-karan committed Feb 18, 2022
1 parent dd6067d commit 76356ca
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 185 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: goreleaser

on:
push:
tags:
- "v*" # Will trigger only if tag is pushed matching pattern `v*` (Eg: `v0.1.0`)

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: --parallelism 1 --rm-dist --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 48 additions & 23 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,83 @@
env:
- GO111MODULE=on
- CGO_ENABLED=0
- RELEASE_BUILDS=dist/calert_darwin_amd64/calert dist/calert_linux_amd64/calert dist/calert_windows_amd64//calert.exe

builds:
- binary: calert
- binary: calert.bin
id: calert
goos:
- windows
- darwin
- linux
goarch:
- amd64
ldflags:
- -s -w -X "main.buildVersion={{ .Tag }} ({{ .ShortCommit }} {{ .Date }})"
- -s -w -X "main.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }})"
dir: ./cmd/

archives:
- format: tar.gz
files:
- config.sample.toml
- README.md
- LICENSE
- message.tmpl
- config.sample.toml
- static/

dockers:
# You can have multiple Docker images.
-
# GOOS of the built binary that should be used.
- # ID of the image, needed if you want to filter by it later on (e.g. on custom publishers).
id: calert

# GOOS of the built binaries/packages that should be used.
goos: linux
# GOARCH of the built binary that should be used.

# GOARCH of the built binaries/packages that should be used.
goarch: amd64
# GOARM of the built binary that should be used.
goarm: ''
# Name templates of the built binaries that should be used.
id: calert

# IDs to filter the binaries/packages.
ids:
- calert

# Templates of the Docker image names.
image_templates:
- "mrkaran/calert:latest"
- "mrkaran/calert:{{ .Tag }}"
# Skips the docker push. Could be useful if you also do draft releases.
# If set to auto, the release will not be pushed to the docker repository
# in case there is an indicator for prerelease in the tag e.g. v1.0.0-rc1
- "ghcr.io/mr-karan/calert:{{ .Tag }}"
- "ghcr.io/mr-karan/calert:latest"

# Skips the docker push.
# Could be useful if you also do draft releases.
#
# If set to auto, the release will not be pushed to the Docker repository
# in case there is an indicator of a prerelease in the tag, e.g. v1.0.0-rc1.
#
# Defaults to false.
skip_push: false

# Path to the Dockerfile (from the project root).
dockerfile: Dockerfile
# If your Dockerfile copies files other than the binary itself,

# Set the "backend" for the Docker pipe.
# Valid options are: docker, buildx, podman, buildpacks
# podman is a GoReleaser Pro feature and is only available on Linux.
# Defaults to docker.
use: docker

# Template of the docker build flags.
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/amd64"

# If your Dockerfile copies files other than binaries and packages,
# you should list them here as well.
# Note that goreleaser will create the same structure inside the temporary
# Note that GoReleaser will create the same structure inside a temporary
# folder, so if you add `foo/bar.json` here, on your Dockerfile you can
# `COPY foo/bar.json /whatever.json`.
# Also note that the paths here are relative to the folder in which
# goreleaser is being run.
# GoReleaser is being run (usually the repository root folder).
# This field does not support wildcards, you can add an entire folder here
# and use wildcards when you `COPY`/`ADD` in your Dockerfile.
extra_files:
- config.sample.toml
- message.tmpl
- config.sample.toml
- static/
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:20.04
WORKDIR /app
COPY calert.bin .
COPY static/ /app/static/
COPY config.sample.toml .
CMD ["./calert.bin"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP-BIN := ./bin/calerts.bin
APP-BIN := ./bin/calert.bin

LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT})
Expand All @@ -25,7 +25,7 @@ lint:
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.43.0 golangci-lint run -v

.PHONY: dev-docker
dev-docker: clean build ## Build and spawns docker containers for the entire suite (Alertmanager/Prometheus/cAlert).
dev-docker: clean build ## Build and spawns docker containers for the entire suite (Alertmanager/Prometheus/calert).
cd dev; \
docker-compose build ; \
CURRENT_UID=$(id -u):$(id -g) docker-compose up
Expand Down
Loading

0 comments on commit 76356ca

Please sign in to comment.