Skip to content

Commit

Permalink
Merge pull request #69 from kayac/fix/workflows
Browse files Browse the repository at this point in the history
Fix/workflows
  • Loading branch information
fujiwara authored Oct 17, 2023
2 parents 1e46722 + ebc2b60 commit a378580
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 70 deletions.
55 changes: 0 additions & 55 deletions .circleci/config.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release
on:
push:
branches:
- "!**/*"
tags:
- "v*"

permissions:
contents: read
packages: write

jobs:
release:
name: Release
runs-on: ubuntu-22.04
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: setup QEMU
uses: docker/setup-qemu-action@v3

- name: setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Login
uses: docker/login-action@v3
with:
username: fujiwara
password: ${{ secrets.DOCKER_TOKEN }}

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker
run: |
PATH=~/bin:$PATH make docker-push
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test
on: [push]
jobs:
test:
strategy:
matrix:
go:
- "1.21"
- "1.20"
name: Build
runs-on: ubuntu-22.04
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Build & Test
run: |
make test
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/gunfish/
binary: gunfish
ldflags:
- -s -w
- -X main.version=v{{.Version}}
goos:
- darwin
- linux
goarch:
- amd64
- arm64
archives:
- name_template: "{{.ProjectName}}_v{{.Version}}_{{.Os}}_{{.Arch}}"

release:
prerelease: "true"
checksum:
name_template: "checksums.txt"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ export PROJECT_ROOT:=$(shell git rev-parse --show-toplevel)
all: test

install:
cd cmd/gunfish && go build -ldflags "-X main.version=${GIT_VER} -X main.buildDate=${DATE}"
cd cmd/gunfish && go build -ldflags "-X main.version=${GIT_VER} -X main.buildDate=${DATE}"
install cmd/gunfish/gunfish ${GOPATH}/bin

packages:
cd cmd/gunfish \
&& CGO_ENABLED=0 gox \
-os="linux darwin" \
-arch="amd64" \
-output "../../pkg/{{.Dir}}-${GIT_VER}-{{.OS}}-{{.Arch}}" \
-gcflags "-trimpath=${GOPATH}" \
-ldflags "-w -X main.version=${GIT_VER} -X main.buildDate=${DATE} -extldflags \"-static\"" \
-tags "netgo"
cd pkg && find . -name "*${GIT_VER}*" -type f -exec zip {}.zip {} \;

gen-cert:
test/scripts/gen_test_cert.sh

Expand All @@ -31,13 +20,34 @@ test: gen-cert
clean:
rm -f cmd/gunfish/gunfish
rm -f test/server.*
rm -f pkg/*
rm -f dist/*

packages:
goreleaser build --skip-validate --rm-dist

build:
go build -gcflags="-trimpath=${HOME}" -ldflags="-w" cmd/gunfish/gunfish.go

tools/%:
go build -gcflags="-trimpath=${HOME}" -ldflags="-w" test/tools/$*/$*.go

release:
ghr -u kayac -r Gunfish -n $(GIT_VER) $(GIT_VER) pkg/
docker: clean packages
mv dist/Gunfish_linux_amd64_v1 dist/Gunfish_linux_amd64
docker buildx build \
--build-arg VERSION=v${GIT_VER} \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t kayac/gunfish:v${GIT_VER} \
-t ghcr.io/kayac/gunfish:v${GIT_VER} \
.

docker-push:
mv dist/Gunfish_linux_amd64_v1 dist/Gunfish_linux_amd64
docker buildx build \
--build-arg VERSION=v${GIT_VER} \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t katsubushi/katsubushi:v${GIT_VER} \
-t ghcr.io/kayac/gunfish:v${GIT_VER} \
--push \
.

0 comments on commit a378580

Please sign in to comment.