Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bin/
Dockerfile
*.md
.travis.yml
.pgdata/
18 changes: 5 additions & 13 deletions .github/workflows/docker.yaml → .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
name: Docker Image CI
name: Docker

on:
push:
branches: '*'
tags: '*'
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Docker Build
run: make docker-build

- name: Login to Docker Hub
- name: Login to the Docker Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')

- name: Docker Push
run: |
make docker-deploy
if: startsWith(github.ref, 'refs/tags/')
run: make docker-push
10 changes: 4 additions & 6 deletions .github/workflows/go.yaml → .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Go

on:
push:
branches: '*'
tags: '*'
pull_request:
branches: [ master ]
branches: ['*']
tags: ['*']

jobs:

Expand All @@ -17,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: '1.23'

- name: Build
- name: Build & Test
run: make
2 changes: 1 addition & 1 deletion .protobuf
Submodule .protobuf updated 1 files
+72 −123 voting/v1/voting.proto
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17 as build
FROM golang:1.23 as build
WORKDIR /go/src/github.com/jukeizu/voting
COPY Makefile go.mod go.sum ./
RUN make deps
Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
TAG=$(shell git describe --tags --always)
VERSION=$(TAG:v%=%)
VERSION=1.0.0-alpha.1-$(TAG:v%=%)
REPO=jukeizu/voting
GO=go
BUILD=GOARCH=amd64 $(GO) build -ldflags="-s -w -X main.Version=$(VERSION)"
PROTOFILES=$(wildcard .protobuf/voting/v1/*.proto)
PROTOPBDEST="../../../api/protobuf-spec"
PROTOFILES=$(wildcard .protobuf/voting/*/*.proto)
PBFILES=$(patsubst %.proto,%.pb.go, $(PROTOFILES))
PROTOPBDEST="../../../api/protobuf-spec/$(patsubst %.proto,%pb, $(notdir $<))"

.PHONY: all deps test build build-linux docker-build docker-save docker-deploy proto clean $(PROTOFILES)
.PHONY: all deps test build build-linux run docker-build docker-save docker-deploy proto clean $(PROTOFILES)

all: deps test build
deps:
Expand All @@ -23,19 +23,22 @@ build:
build-linux:
CGO_ENABLED=0 GOOS=linux $(BUILD) -a -installsuffix cgo -o bin/voting ./cmd/...

run: build
./bin/voting-$(VERSION) -migrate

docker-build:
docker build -t $(REPO):$(VERSION) .

docker-save:
mkdir -p bin && docker save -o bin/image.tar $(REPO):$(VERSION)

docker-deploy:
docker-push:
docker push $(REPO):$(VERSION)

proto: $(PBFILES)

%.pb.go: %.proto
cd $(dir $<) && mkdir -p $(PROTOPBDEST)/$(patsubst %.proto,%pb, $(notdir $<)) && protoc $(notdir $<) --go_out=plugins=grpc:$(PROTOPBDEST)/$(patsubst %.proto,%pb, $(notdir $<))
cd $(dir $<) && mkdir -p $(PROTOPBDEST) && protoc $(notdir $<) --go_out=$(PROTOPBDEST) --go-grpc_out=$(PROTOPBDEST)

clean:
@find bin -type f ! -name '*.toml' -delete -print
@rm -f bin/*
Loading