Skip to content

Commit

Permalink
Merge pull request #2 from ueckoken/auto-build
Browse files Browse the repository at this point in the history
  • Loading branch information
Azuki-bar authored Dec 27, 2022
2 parents 4985de6 + e25bbb0 commit 3efe6e0
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: goreleaser

on:
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
packages: write
issues: 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: ">=1.19.4"
cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/#-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: test
on: push
jobs:
discotp:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: ./go.mod
cache: true
cache-dependency-path: ./go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50
working-directory: ./
skip-pkg-cache: true
- name: Build Go binary
run: |-
make build
- name: Run Go Test
run: |-
make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
compose.debug.yaml

dist/
75 changes: 75 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
dockers:
- image_templates:
- "ghcr.io/ueckoken/discotp:latest-amd64"
- "ghcr.io/ueckoken/discotp:{{ .Tag }}-amd64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}-amd64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}.{{ .Minor }}-amd64"
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
dockerfile: 'dockerfiles/release/Dockerfile'
- image_templates:
- "ghcr.io/ueckoken/discotp:latest-arm64"
- "ghcr.io/ueckoken/discotp:{{ .Tag }}-arm64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}-arm64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}.{{ .Minor }}-arm64"
use: buildx
goos: linux
goarch: arm64
build_flag_templates:
- --platform=linux/arm64
dockerfile: 'dockerfiles/release/Dockerfile'
docker_manifests:
- name_template: "ghcr.io/ueckoken/discotp:latest"
image_templates:
- "ghcr.io/ueckoken/discotp:latest-amd64"
- "ghcr.io/ueckoken/discotp:latest-arm64"
- name_template: "ghcr.io/ueckoken/discotp:{{ .Tag }}"
image_templates:
- "ghcr.io/ueckoken/discotp:{{ .Tag }}-amd64"
- "ghcr.io/ueckoken/discotp:{{ .Tag }}-arm64"
- name_template: "ghcr.io/ueckoken/discotp:v{{ .Major }}"
image_templates:
- "ghcr.io/ueckoken/discotp:v{{ .Major }}-amd64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}-arm64"
- name_template: "ghcr.io/ueckoken/discotp:v{{ .Major }}.{{ .Minor }}"
image_templates:
- "ghcr.io/ueckoken/discotp:v{{ .Major }}.{{ .Minor }}-amd64"
- "ghcr.io/ueckoken/discotp:v{{ .Major }}.{{ .Minor }}-arm64"
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
# modelines, feel free to remove those if you don't want/use them:
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build:
CGO_ENABLED=0 go build -o discotp ./
test:
go test -v ./...
3 changes: 3 additions & 0 deletions dockerfiles/release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM gcr.io/distroless/static-debian11:nonroot
COPY discotp /
ENTRYPOINT [ "/discotp" ]

0 comments on commit 3efe6e0

Please # to comment.