1
0
mirror of https://github.com/maaslalani/gambit.git synced 2024-12-24 20:14:34 +02:00

ci: add build and release workflow

* use goreleaser for release
* add docker builds
* add docker-compose.yml example
This commit is contained in:
Ayman Bagabas 2022-02-23 13:35:52 -05:00 committed by Maas Lalani
parent 8a4db5729c
commit fe96530644
5 changed files with 171 additions and 0 deletions

26
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Checkout code
uses: actions/checkout@v2
- name: Download Go modules
run: go mod download
- name: Build
run: go build -v ./...
- name: Test
run: go test ./...

48
.github/workflows/goreleaser.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: goreleaser
on:
push:
tags:
- v*.*.*
concurrency:
group: goreleaser
cancel-in-progress: true
jobs:
goreleaser:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
env:
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
name: ghcr.io login
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@v2
with:
version: latest
distribution: goreleaser
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

71
.goreleaser.yaml Normal file
View File

@ -0,0 +1,71 @@
project_name: gambit
env:
- GO111MODULE=on
- CGO_ENABLED=0
before:
hooks:
- go mod download
- go mod tidy
builds:
- id: "gambit"
binary: "gambit"
ldflags: -s -w -X main.Version=v{{ .Version }} -X main.CommitSHA={{ .Commit }}
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
archives:
- format_overrides:
- goos: windows
format: zip
replacements:
windows: Windows
darwin: Darwin
386: i386
amd64: x86_64
changelog:
sort: asc
use: github
filters:
exclude:
- "^docs:"
- "^test:"
groups:
- title: 'New Features'
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Others
order: 999
dockers:
- image_templates:
- "ghcr.io/maaslalani/gambit:latest"
- "ghcr.io/maaslalani/gambit:v{{ .Version }}"
ids: [gambit]
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/maaslalani/gambit
- --label=org.opencontainers.image.source=https://github.com/maaslalani/gambit
- --label=org.opencontainers.image.version=v{{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
dockerfile: Dockerfile
use: buildx

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM scratch
COPY gambit /usr/local/bin/gambit
# Expose data volume
VOLUME /data
# Expose ports
EXPOSE 53531/tcp
# Set the default command
ENTRYPOINT [ "/usr/local/bin/gambit" ]

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
version: "3.1"
services:
soft-serve:
image: ghcr.io/maaslalani/gambit:latest
container_name: gambit
volumes:
- ./data:/data
ports:
- 53531:53531
environment:
- GAMBIT_SERVER_HOST=
- GAMBIT_SERVER_PORT=53531
- GAMBIT_SERVER_KEY_PATH="/data/gambit"
command: serve
restart: unless-stopped