Skip to content

Commit

Permalink
Feat add release CI (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bullet-tooth authored Mar 28, 2024
1 parent efe445d commit 78851c9
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
build
.golangci.yml
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: CI

on:
push:
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -16,8 +19,6 @@ jobs:
cache: true
- name: Run build
run: make build
- name: Run tests
run: make test

lint:
name: Lint
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release

on:
release:
types: [created]

permissions:
contents: write
packages: write

jobs:
binaries:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "1.21.5"
project_path: "./cmd/keygen"
binary_name: "keygen"

docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: stroomnetwork/keygen:${{ github.ref_name }},stroomnetwork/keygen:latest
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.21.5 as builder

WORKDIR "/go/src/keygen"

COPY . ./

RUN make build

FROM alpine:3.19

COPY --from=builder /go/src/keygen/build/keygen /usr/local/bin/

WORKDIR "/keygen"

CMD ["help"]
ENTRYPOINT ["keygen"]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ all: help

## Build:

.PHONY: build
build: ## Build the project
go build -v -o ./build/keygen -installsuffix cgo -ldflags "$(LDFLAGS)" ./cmd/keygen

.PHONY: test
test: ## Run unit tests
go test -v ./...


.PHONY: build
build: test ## Build the project
go build -v -o ./build/keygen -installsuffix cgo -ldflags "$(LDFLAGS)" ./cmd/keygen

.PHONY: clean
clean: ## Remove build files and caches.
rm -rf build
Expand Down

0 comments on commit 78851c9

Please sign in to comment.