Skip to content

Commit

Permalink
Merge branch 'main' into drop-fcm-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Apr 5, 2024
2 parents 421dc28 + 8742f00 commit c1f4195
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 104 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: write
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ _testmain.go
/apnsmock
/test/server*
/pkg
/dist

*~
*~
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-build: # clean packages
mv dist/Gunfish_linux_amd64_v1 dist/Gunfish_linux_amd64
docker buildx build \
--build-arg VERSION=${GIT_VER} \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t kayac/gunfish:${GIT_VER} \
-t ghcr.io/kayac/gunfish:${GIT_VER} \
.

docker-push:
mv dist/Gunfish_linux_amd64_v1 dist/Gunfish_linux_amd64
docker buildx build \
--build-arg VERSION=${GIT_VER} \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t kayac/gunfish:${GIT_VER} \
-t ghcr.io/kayac/gunfish:${GIT_VER} \
--push \
.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

APNs and FCM provider server on HTTP/2.

* Gunfish provides the nterface as the APNs / FCM provider server.
* Gunfish provides the interface as the APNs / FCM provider server.

## Overview

Expand All @@ -14,10 +14,28 @@ APNs and FCM provider server on HTTP/2.

[Gunfish slides (jp)](http://slides.com/takuyayoshimura-tkyshm/deck/fullscreen)

## Install

### Binary

Download the latest binary from [releases](https://github.com/kayac/Gunfish/releases)

### Docker images

[DockerHub](https://hub.docker.com/r/kayac/gunfish/)

[GitHub Packages](https://github.com/kayac/Gunfish/pkgs/container/gunfish)

### Homebrew

```console
$ brew tap kayac/tap
$ brew install gunfish
```

## Quick Started

```bash
$ go get github.com/kayac/Gunfish/cmd/gunfish
$ gunfish -c ./config/gunfish.toml -E production
```

Expand Down Expand Up @@ -189,12 +207,12 @@ See detail properties that url: (https://github.com/fukata/golang-stats-api-hand

## Configuration
The Gunfish configuration file is a TOML file that Gunfish server uses to configure itself.
That configuration file should be located `/etc/gunfish.toml`, and is required to start.
That configuration file should be located at `/etc/gunfish.toml`, and is required to start.
Here is an example configuration:

```toml
[provider]
port = 8203
port = 8003
worker_num = 8
queue_size = 2000
max_request_size = 1000
Expand Down
18 changes: 6 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
FROM alpine:3.9
FROM alpine:3.18
LABEL maintainer "FUJIWARA Shunichiro <[email protected]>"

ARG version

RUN apk --no-cache add unzip curl && \
mkdir -p /etc/gunfish /opt/gunfish && \
curl -sL https://github.com/kayac/Gunfish/releases/download/${version}/gunfish-${version}-linux-amd64.zip > /tmp/gunfish-${version}-linux-amd64.zip && \
cd /tmp && \
unzip gunfish-${version}-linux-amd64.zip && \
install gunfish-${version}-linux-amd64 /usr/bin/gunfish && \
rm -f /tmp/gunfish*

ARG VERSION
ARG TARGETARCH
ADD dist/Gunfish_linux_${TARGETARCH}/gunfish /usr/local/bin/gunfish
EXPOSE 8003
WORKDIR /opt/gunfish

ENTRYPOINT ["/usr/bin/gunfish"]
ENTRYPOINT ["/usr/local/bin/gunfish"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/satori/go.uuid v1.1.0
github.com/sirupsen/logrus v1.0.3
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
golang.org/x/net v0.17.0
golang.org/x/oauth2 v0.0.0-20191122200657-5d9234df094c
google.golang.org/api v0.14.0 // indirect
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
Expand Down
Loading

0 comments on commit c1f4195

Please sign in to comment.