-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
8ab738a
commit b4e50d9
Showing
30 changed files
with
4,425 additions
and
2 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,2 @@ | ||
github: igolaizola | ||
custom: ["https://ko-fi.com/igolaizola", "https://buymeacoffee.com/igolaizola", "https://paypal.me/igolaizola"] |
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,29 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- run: git fetch --force --tags | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
- uses: goreleaser/goreleaser-action@v4 | ||
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
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,13 @@ | ||
builds: | ||
- binary: igogpt | ||
main: ./cmd/igogpt | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm64 | ||
- arm | ||
goarm: | ||
- "6" | ||
- "7" | ||
archives: | ||
- format: zip |
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,15 @@ | ||
# builder image | ||
FROM golang:alpine as builder | ||
ARG TARGETPLATFORM | ||
COPY . /src | ||
WORKDIR /src | ||
RUN apk add --no-cache make bash git | ||
RUN make app-build PLATFORMS=$TARGETPLATFORM | ||
|
||
# running image | ||
FROM alpine | ||
WORKDIR /home | ||
COPY --from=builder /src/bin/igogpt-* /bin/igogpt | ||
|
||
# executable | ||
ENTRYPOINT [ "/bin/igogpt" ] |
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,73 @@ | ||
#!/bin/bash | ||
|
||
SHELL = /bin/bash | ||
PLATFORMS ?= linux/amd64 darwin/amd64 windows/amd64 | ||
IMAGE_PREFIX ?= igolaizola | ||
REPO_NAME ?= igogpt | ||
COMMIT_SHORT ?= $(shell git rev-parse --verify --short HEAD) | ||
VERSION ?= $(COMMIT_SHORT) | ||
VERSION_NOPREFIX ?= $(shell echo $(VERSION) | sed -e 's/^[[v]]*//') | ||
|
||
# Build the binaries for the current platform | ||
.PHONY: build | ||
build: | ||
os=$$(go env GOOS); \ | ||
arch=$$(go env GOARCH); \ | ||
PLATFORMS="$$os/$$arch" make app-build | ||
|
||
# Build the binaries | ||
# Example: PLATFORMS=linux/amd64 make app-build | ||
.PHONY: app-build | ||
app-build: | ||
@for platform in $(PLATFORMS) ; do \ | ||
os=$$(echo $$platform | cut -f1 -d/); \ | ||
arch=$$(echo $$platform | cut -f2 -d/); \ | ||
arm=$$(echo $$platform | cut -f3 -d/); \ | ||
arm=$${arm#v}; \ | ||
ext=""; \ | ||
if [ "$$os" == "windows" ]; then \ | ||
ext=".exe"; \ | ||
fi; \ | ||
file=./bin/$(REPO_NAME)-$(VERSION_NOPREFIX)-$$(echo $$platform | tr / -)$$ext; \ | ||
GOOS=$$os GOARCH=$$arch GOARM=$$arm CGO_ENABLED=0 \ | ||
go build \ | ||
-a -x -tags netgo,timetzdata -installsuffix cgo -installsuffix netgo \ | ||
-ldflags " \ | ||
-X main.Version=$(VERSION_NOPREFIX) \ | ||
-X main.GitRev=$(COMMIT_SHORT) \ | ||
" \ | ||
-o $$file \ | ||
./cmd/$(REPO_NAME); \ | ||
if [ $$? -ne 0 ]; then \ | ||
exit 1; \ | ||
fi; \ | ||
chmod +x $$file; \ | ||
done | ||
|
||
# Build the docker image | ||
# Example: PLATFORMS=linux/amd64 make docker-build | ||
.PHONY: docker-build | ||
docker-build: | ||
@platforms=($(PLATFORMS)); \ | ||
platform=$${platforms[0]}; \ | ||
if [[ $${#platforms[@]} -ne 1 ]]; then \ | ||
echo "Multi-arch build not supported"; \ | ||
exit 1; \ | ||
fi; \ | ||
docker build --platform $$platform -t $(IMAGE_PREFIX)/$(REPO_NAME):$(VERSION) .; \ | ||
if [ $$? -ne 0 ]; then \ | ||
exit 1; \ | ||
fi | ||
|
||
# Build the docker images using buildx | ||
# Example: PLATFORMS="linux/amd64 darwin/amd64 windows/amd64" make docker-buildx | ||
.PHONY: docker-buildx | ||
docker-buildx: | ||
@platforms=($(PLATFORMS)); \ | ||
platform=$$(IFS=, ; echo "$${platforms[*]}"); \ | ||
docker buildx build --platform $$platform -t $(IMAGE_PREFIX)/$(REPO_NAME):$(VERSION) . | ||
|
||
# Clean binaries | ||
.PHONY: clean | ||
clean: | ||
rm -rf bin |
Oops, something went wrong.