Skip to content

Commit 63e767d

Browse files
authored
Merge pull request #14 from ryodocx/goreleaser
2 parents a0e67e0 + 3517b14 commit 63e767d

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed

.github/workflows/goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
# run only against tags
6+
tags:
7+
- "v*"
8+
9+
permissions:
10+
contents: write
11+
# packages: write
12+
# issues: write
13+
14+
jobs:
15+
goreleaser:
16+
runs-on: ubuntu-latest
17+
steps:
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
-
24+
name: Fetch all tags
25+
run: git fetch --force --tags
26+
-
27+
name: Set up Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.19
31+
-
32+
name: Run GoReleaser
33+
uses: goreleaser/goreleaser-action@v2
34+
with:
35+
# either 'goreleaser' (default) or 'goreleaser-pro'
36+
distribution: goreleaser
37+
version: latest
38+
args: release --rm-dist
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
42+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.goreleaser.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
- windows
12+
- darwin
13+
archives:
14+
- replacements:
15+
darwin: Darwin
16+
linux: Linux
17+
windows: Windows
18+
386: i386
19+
amd64: x86_64
20+
checksum:
21+
name_template: 'checksums.txt'
22+
snapshot:
23+
name_template: "{{ incpatch .Version }}-next"
24+
changelog:
25+
sort: asc
26+
filters:
27+
exclude:
28+
- '^docs:'
29+
- '^test:'
30+
release:
31+
draft: false
32+
prerelease: auto

linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build linux
2+
3+
package main
4+
5+
import (
6+
"os"
7+
"syscall"
8+
)
9+
10+
func init() {
11+
ignoreSignals = []os.Signal{syscall.SIGURG} // https://golang.hateblo.jp/entry/golang-signal-urgent-io-condition
12+
}

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var gracePeriodBeforeShutdown time.Duration = 1 * time.Second
2929
var gracePeriodDuringShutdown time.Duration = 0
3030
var accessLog bool = false
3131

32+
var ignoreSignals []os.Signal
33+
3234
func init() {
3335
// override default config
3436

@@ -132,7 +134,7 @@ func main() {
132134
for {
133135
sigChan := make(chan os.Signal, 1)
134136
signal.Notify(sigChan)
135-
signal.Ignore(syscall.SIGURG) // https://golang.hateblo.jp/entry/golang-signal-urgent-io-condition
137+
signal.Ignore(ignoreSignals...)
136138
receivedSignal := <-sigChan
137139
log.Println("signal received:", fmt.Sprintf("%d(%s)", receivedSignal, receivedSignal.String()))
138140

0 commit comments

Comments
 (0)