Skip to content

Commit

Permalink
chore: add docker target to Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
  • Loading branch information
khos2ow committed Apr 1, 2021
1 parent f76afed commit 2ede517
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

env:
GO_VERSION: "1.16"
GOLANGCI_VERSION: "v1.38"

jobs:
tests:
Expand Down Expand Up @@ -54,4 +55,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.38
version: ${{ env.GOLANGCI_VERSION }}
16 changes: 8 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@ name: publish

on:
push:
branches:
branches:
- master

env:
GO_VERSION: "1.16"
DOCKER_REGISTRY: "quay.io"

jobs:
goreleaser:
docker:
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Build go binary
run: make build
- name: Login to GitHub Packages Docker Registry

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.QUAY_IO_USER }}
password: ${{ secrets.QUAY_IO_TOKEN }}

- name: Build and Push docker image
run: |
docker build --pull --tag ${{ env.DOCKER_REGISTRY }}/git-chglog/git-chglog:edge .
docker push ${{ env.DOCKER_REGISTRY }}/git-chglog/git-chglog:edge
run: DOCKER_TAG=edge make docker push
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Login to GitHub Packages Docker Registry

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.QUAY_IO_USER }}
password: ${{ secrets.QUAY_IO_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ GOHOST ?= GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)

LDFLAGS ?= "-X main.version=$(VERSION)"

# Docker variables
DEFAULT_TAG ?= $(shell echo "$(VERSION)" | tr -d 'v')
DOCKER_IMAGE := quay.io/git-chglog/git-chglog
DOCKER_TAG ?= $(DEFAULT_TAG)

.PHONY: all
all: help

Expand Down Expand Up @@ -46,6 +51,16 @@ install: ## Install git-chglog
@ $(MAKE) --no-print-directory log-$@
$(GOHOST) install ./cmd/git-chglog

.PHONY: docker
docker: build ## Build Docker image
@ $(MAKE) --no-print-directory log-$@
docker build --pull --tag $(DOCKER_IMAGE):$(DOCKER_TAG) .

.PHONY: push
push: ## Push Docker image
@ $(MAKE) --no-print-directory log-$@
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)

###########
##@ Release

Expand All @@ -55,7 +70,7 @@ changelog: build ## Generate changelog
./git-chglog --next-tag $(VERSION) -o CHANGELOG.md

.PHONY: release
release: changelog ## Release a new tag
release: changelog ## Release a new tag
@ $(MAKE) --no-print-directory log-$@
git add CHANGELOG.md
git commit -m "chore: update changelog for $(VERSION)"
Expand Down

0 comments on commit 2ede517

Please sign in to comment.