-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,935 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: CI/CD with Tests, Semantic Release, GoReleaser and Docker Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.23" | ||
- name: install | ||
run: | | ||
go install -v golang.org/x/tools/cmd/goimports@latest | ||
go install -v honnef.co/go/tools/cmd/staticcheck@latest | ||
- name: Test | ||
run: | | ||
make fmt && git diff --exit-code | ||
make imports && git diff --exit-code | ||
make test | ||
semantic_release: | ||
name: Semantic Release | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
outputs: | ||
version: ${{ steps.get-version.outputs.version }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.23" | ||
- name: Install GoReleaser | ||
run: go install github.com/goreleaser/goreleaser/v2@latest | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v4 | ||
with: | ||
extra_plugins: | | ||
@semantic-release/exec | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
- id: get-version | ||
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT | ||
docker_build: | ||
name: Docker build | ||
runs-on: ubuntu-latest | ||
needs: semantic_release | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- 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.DOCKERIO_USERNAME }}" | ||
password: "${{ secrets.DOCKERIO_TOKEN }}" | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
lokxy/lokxy:${{ github.ref_name == 'main' && 'latest' || github.ref_name }},lokxy/lokxy:${{ needs.semantic_release.outputs.version }} | ||
cache-from: type=registry,ref=lokxy/lokxy:latest | ||
cache-to: type=registry,ref=lokxy/lokxy:latest,mode=max,image-manifest=true | ||
env: | ||
LOKXY_VERSION: ${{ needs.semantic_release.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.23" | ||
- name: install | ||
run: | | ||
go install -v golang.org/x/tools/cmd/goimports@latest | ||
go install -v honnef.co/go/tools/cmd/staticcheck@latest | ||
- name: Test | ||
run: | | ||
make fmt && git diff --exit-code | ||
make imports && git diff --exit-code | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: 2 | ||
project_name: lokxy | ||
|
||
env: | ||
- GO111MODULE=on | ||
- CGO_ENABLED=0 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
- go mod download | ||
|
||
metadata: | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
|
||
report_sizes: true | ||
|
||
archives: | ||
- format: tar.gz | ||
files: | ||
- LICENSE | ||
|
||
builds: | ||
- main: ./cmd/ | ||
binary: lokxy | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm | ||
- arm64 | ||
- ppc64 | ||
goarm: | ||
- "7" | ||
ignore: | ||
- goos: windows | ||
goarch: arm | ||
- goos: darwin | ||
goarch: "386" | ||
- goos: linux | ||
goarch: arm | ||
goarm: 7 | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w -X main.version={{ .Env.GORELEASER_CURRENT_TAG }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} -X main.builtBy=goreleaser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
branches: | ||
- main | ||
|
||
plugins: | ||
- "@semantic-release/commit-analyzer" | ||
- "@semantic-release/release-notes-generator" | ||
- - "@semantic-release/exec" | ||
- prepareCmd: 'echo "${nextRelease.version}" >> VERSION' | ||
publishCmd: | | ||
echo "${nextRelease.notes}" > /tmp/release-notes.md | ||
export GORELEASER_CURRENT_TAG=$(cat VERSION) | ||
goreleaser release --release-notes /tmp/release-notes.md --clean --skip=validate | ||
- "@semantic-release/changelog" | ||
- "@semantic-release/git" | ||
|
||
tagFormat: ${version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM debian:12-slim AS builder | ||
|
||
ARG BUILDPLATFORM | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG LOKXY_VERSION | ||
ENV GOARCH=${TARGETARCH} GOOS=${TARGETOS} | ||
|
||
RUN apt update &&\ | ||
apt install -y --no-install-recommends --no-install-suggests \ | ||
curl &&\ | ||
curl -sL -o /tmp/lokxy_${LOKXY_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz https://github.com/paulojmdias/lokxy/releases/download/${LOKXY_VERSION}/lokxy_${LOKXY_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz &&\ | ||
tar -xvf /tmp/lokxy_${LOKXY_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz -C /tmp | ||
|
||
FROM gcr.io/distroless/static-debian12 | ||
|
||
EXPOSE 3100 | ||
|
||
COPY --from=builder /tmp/lokxy /usr/local/bin/lokxy | ||
|
||
CMD ["/usr/local/bin/lokxy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.23 AS builder | ||
|
||
ARG BUILDPLATFORM | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ENV GOARCH=${TARGETARCH} GOOS=${TARGETOS} | ||
|
||
COPY . /go/src/github.com/paulojmdias/lokxy | ||
RUN cd /go/src/github.com/paulojmdias/lokxy &&\ | ||
make build | ||
|
||
FROM gcr.io/distroless/static-debian12 | ||
|
||
EXPOSE 3100 | ||
|
||
COPY --from=builder /go/src/github.com/paulojmdias/lokxy/lokxy /usr/local/bin/lokxy | ||
|
||
CMD ["/usr/local/bin/lokxy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
BUILD := build | ||
GO ?= go | ||
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*") | ||
GOFMT ?= gofmt | ||
GOIMPORTS ?= goimports -local=github.com/paulojmdias/lokxy | ||
STATICCHECK ?= staticcheck | ||
|
||
.PHONY: clean | ||
clean: | ||
$(GO) clean -i ./... | ||
rm -rf $(BUILD) | ||
|
||
.PHONY: static-check | ||
static-check: | ||
$(STATICCHECK) ./... | ||
|
||
.PHONY: fmt | ||
fmt: | ||
$(GOFMT) -w -s $(GOFILES) | ||
|
||
.PHONY: imports | ||
imports: | ||
$(GOIMPORTS) -w $(GOFILES) | ||
|
||
.PHONY: test | ||
test: | ||
GO111MODULE=on $(GO) test -race -mod=mod -tags netgo,builtinassets ./... | ||
|
||
.PHONY: build | ||
build: | ||
CGO_ENABLED=0 go build -mod=mod -tags netgo,builtinassets -x -o lokxy ./cmd/ | ||
|
||
testlocal-build: | ||
docker build -f Dockerfile.local --load -t lokxy:latest . |
Oops, something went wrong.