-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
197 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,51 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: stable | ||
check-latest: true | ||
cache: true | ||
- | ||
name: Cache Go modules | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
if: success() && startsWith(github.ref, 'refs/tags/') | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ go.work | |
|
||
dump/ | ||
.cache/ | ||
bin/ |
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,24 @@ | ||
# Build | ||
FROM golang:1.20-alpine AS build | ||
|
||
# Install dependencies | ||
RUN apk update && apk upgrade && apk add --no-cache \ | ||
make git | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN make build-linux | ||
|
||
# Final container | ||
FROM alpine:3.18 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app/bin/linux/wp-go-static /app/ | ||
|
||
RUN chmod u+x /app/wp-go-static | ||
|
||
# Start | ||
ENTRYPOINT [ "/app/wp-go-static" ] |
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,12 @@ | ||
FROM alpine:3.18 | ||
|
||
RUN apk update && \ | ||
apk add --no-cache curl ca-certificates && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
WORKDIR /app | ||
|
||
ADD wp-go-static /app/wp-go-static | ||
RUN chmod u+x /app/wp-go-static | ||
|
||
ENTRYPOINT [ "/app/wp-go-static" ] |
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,49 @@ | ||
.PHONY: clean build build-mac build-linux | ||
|
||
PACKAGE_FOLDER = wp-go-static | ||
|
||
export GO111MODULE=on | ||
export CGO_ENABLED=0 | ||
|
||
# Strip debug info | ||
LDFLAGS += "-s -w" | ||
|
||
all: build | ||
|
||
build: | ||
go build -ldflags $(LDFLAGS) -o ./bin/$(PACKAGE_FOLDER) ./cmd/$(PACKAGE_FOLDER)/main.go | ||
|
||
dep-install: | ||
go mod download | ||
|
||
build-mac: | ||
mkdir -p bin/mac | ||
env GOOS=darwin GOARCH=amd64 go build -ldflags $(LDFLAGS) -o ./bin/mac/$(PACKAGE_FOLDER) ./cmd/$(PACKAGE_FOLDER)/main.go | ||
|
||
build-linux: | ||
mkdir -p bin/linux | ||
env GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o ./bin/linux/$(PACKAGE_FOLDER) ./cmd/$(PACKAGE_FOLDER)/main.go | ||
|
||
lint: check-lint | ||
golangci-lint run ./... | ||
|
||
start: | ||
go run cmd/gitlab-reporter/main.go transform | ||
|
||
test: | ||
go test -v ./... | ||
|
||
doc: | ||
go doc ./... | ||
|
||
check-lint: | ||
@if ! [ -x "$$(command -v golangci-lint)" ]; then \ | ||
echo "Downloading golangci-lint..."; \ | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \ | ||
fi; | ||
|
||
docker: | ||
docker build -f Dockerfile -t ${PACKAGE_FOLDER} . | ||
|
||
clean: | ||
rm -rf bin |
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,60 @@ | ||
project_name: wp-go-static | ||
builds: | ||
- | ||
main: ./cmd/wp-go-static | ||
id: "wp-go-static" | ||
binary: wp-go-static | ||
env: [CGO_ENABLED=0] | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
nfpms: | ||
- | ||
maintainer: Marco Santos <[email protected]> | ||
description: Wordpress static site generator | ||
homepage: https://github.com/LOQ9/wp-go-static | ||
license: MIT | ||
formats: | ||
- deb | ||
- rpm | ||
- apk | ||
|
||
archives: | ||
- | ||
format: binary | ||
|
||
# dockers: | ||
# - image_templates: | ||
# - 'ghcr.io/loq9/{{ .ProjectName }}:{{ .Tag }}-amd64' | ||
# use: buildx | ||
# build_flag_templates: | ||
# - "--pull" | ||
# - "--platform=linux/amd64" | ||
# - image_templates: | ||
# - 'ghcr.io/loq9/{{ .ProjectName }}:{{ .Tag }}-arm64' | ||
# use: buildx | ||
# build_flag_templates: | ||
# - "--pull" | ||
# - "--platform=linux/arm64" | ||
# goarch: arm64 | ||
|
||
dockers: | ||
- | ||
id: wp-go-static | ||
image_templates: | ||
- "ghcr.io/loq9/{{ .ProjectName }}:{{ .Tag }}" | ||
- "ghcr.io/loq9/{{ .ProjectName }}:latest" | ||
dockerfile: "Dockerfile.minimal" | ||
build_flag_templates: | ||
- --label=org.opencontainers.image.title={{ .ProjectName }} | ||
- --label=org.opencontainers.image.description={{ .ProjectName }} | ||
- --label=org.opencontainers.image.url=https://github.com/LOQ9/wp-go-static | ||
- --label=org.opencontainers.image.source=https://github.com/LOQ9/wp-go-static | ||
- --label=org.opencontainers.image.version={{ .Version }} | ||
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} | ||
- --label=org.opencontainers.image.revision={{ .FullCommit }} | ||
- --label=org.opencontainers.image.licenses=MIT |