Skip to content

Commit

Permalink
chore: add github action to release binaries on tags
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen Yadav <pyadav9678@gmail.com>
  • Loading branch information
pyadav committed Mar 17, 2024
1 parent a03bfc7 commit da97585
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21.6"
go-version: "1.22.0"
- name: Login to DockerHub
uses: docker/login-action@v3
with:
Expand All @@ -28,4 +28,4 @@ jobs:
with:
push: true
file: "./docker/Dockerfile.gateway.dev"
tags: missingstudio/ai:dev
tags: missingstudio/gateway:dev
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: release

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:

jobs:
dev:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.0"
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish dev image
id: docker_dev_build
uses: docker/build-push-action@v2
with:
push: true
file: "./docker/Dockerfile.gateway.dev"
tags: missingstudio/gateway:dev
releaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.0"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Chart.lock
**/*.tgz

go.work.sum

dist/
104 changes: 104 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
project_name: gateway

before:
hooks:
- make test

release:
prerelease: auto

builds:
- id: gateway
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
binary: gateway
dir: ./gateway
main: ./
ldflags:
- -s -w -X github.com/missinstudio/ai/gateway/config.Version={{.Tag}}
- -X github.com/missinstudio/ai/gateway/config.BuildCommit={{.FullCommit}}
- -X github.com/missinstudio/ai/gateway/config.BuildDate={{.Date}}
env:
- CGO_ENABLED=0

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

checksum:
name_template: "{{ .ProjectName }}_v{{ .Version }}_checksums.txt"

snapshot:
name_template: "{{ .Tag }}-next"


dockers:
- goos: linux
goarch: amd64
ids:
- gateway
dockerfile: Dockerfile
image_templates:
- "docker.io/missingstudio/{{.ProjectName}}:latest"
- "docker.io/missingstudio/{{.ProjectName}}:{{ .Tag }}"
- "docker.io/missingstudio/{{.ProjectName}}:{{ .Tag }}-amd64"
- goos: linux
goarch: arm64
ids:
- gateway
dockerfile: Dockerfile
image_templates:
- "docker.io/missingstudio/{{.ProjectName}}:{{ .Tag }}-arm64"


nfpms:
- maintainer: Missing studio
description: A robust cloud-native AI Gateway
homepage: https://github.com/missingstudio/gateway
license: Apache 2.0
formats:
- deb
- rpm

scoops:
- homepage: https://github.com/missingstudio/gateway
description: A robust cloud-native AI Gateway
license: Apache 2.0
repository:
owner: raystack
name: scoop-bucket

brews:
- name: gateway
homepage: https://github.com/missingstudio/gateway
description: A robust cloud-native AI Gateway
repository:
owner: missingstudio
name: homebrew-tap
license: Apache 2.0
folder: Formula
dependencies:
- name: git
install: |-
bin.install "gateway"
commit_author:
name: Missing studio
email: support@missing.studio
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ help: ## Show this help
build: build-gateway ## Build missing studio project
.PHONY: build

test:
sh -c "cd ./gateway && make test"
.PHONY: test

build-gateway:
sh -c "cd ./gateway && make all"
.PHONY: build-gateway
Expand Down
23 changes: 23 additions & 0 deletions gateway/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22-alpine3.18 as builder

RUN apk add make

WORKDIR /go/src/app

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN make build

FROM alpine:3.18
COPY --from=builder /go/src/app/frontier /usr/bin/
RUN apk update
RUN apk add ca-certificates

# glibc compatibility library, since go binaries
# don't work well with musl libc that alpine uses
RUN apk add libc6-compat

ENTRYPOINT ["frontier", "server"]
2 changes: 1 addition & 1 deletion gateway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clean: ## Clean AI Gateway server
.PHONY: clean

test: ## Run tests
@go test -race $(shell go list ./... | grep -v /ui | grep -v /vendor/ | grep -v /test/) -coverprofile=coverage.out -count 2 -timeout 150s
@go test -race $(shell go list ./... | grep -v /vendor/ | grep -v /test/) -coverprofile=coverage.out -count 2 -timeout 150s

install-tools: install-go-tools
.PHONY: install-tools
Expand Down

0 comments on commit da97585

Please sign in to comment.