Skip to content

Commit ba43ff4

Browse files
committed
Add release workflow
1 parent 437f882 commit ba43ff4

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: goreleaser
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
goreleaser:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Unshallow
16+
run: git fetch --prune --unshallow
17+
- name: Set up Go
18+
uses: actions/setup-go@v1
19+
with:
20+
go-version: 1.15.x
21+
- name: Run GoReleaser
22+
uses: goreleaser/goreleaser-action@v1
23+
with:
24+
version: latest
25+
args: release --rm-dist
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
before:
2+
hooks:
3+
- go mod vendor
4+
- scripts/prepare.sh
5+
builds:
6+
- goos:
7+
- darwin
8+
- freebsd
9+
- linux
10+
- windows
11+
archives:
12+
- replacements:
13+
darwin: Darwin
14+
linux: Linux
15+
windows: Windows
16+
386: i386
17+
amd64: x86_64
18+
files:
19+
- LICENSE
20+
- NOTICE
21+
- README.md
22+
checksum:
23+
name_template: 'checksums.txt'
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
changelog:
27+
sort: asc
28+
filters:
29+
exclude:
30+
- '^docs:'
31+
- '^test:'
32+
release:
33+
github:
34+
owner: netauth
35+
name: netkeys

scripts/prepare.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
./scripts/vendor-licenses > NOTICE

scripts/vendor-licenses

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
list_vendor_files() {
4+
find vendor -type f -a \( -iname 'COPYING*' -o -iname 'LICENSE*' \) | sort
5+
}
6+
7+
list_files() {
8+
goroot="$(go env GOROOT)"
9+
goid='Go programming language'
10+
if [ -r "$goroot/LICENSE" ]; then
11+
echo "${goid}::$goroot/LICENSE"
12+
elif [ -r /usr/share/licenses/go/LICENSE ]; then
13+
echo "${goid}::/usr/share/licenses/go/LICENSE"
14+
else # last restort: HTTP
15+
echo "${goid}::https://golang.org/LICENSE?m=text"
16+
fi
17+
list_vendor_files
18+
}
19+
20+
generate_notice() {
21+
last=
22+
$0 -all | while IFS=$'\n' read -r license; do
23+
pkg="${license%%::*}"
24+
if [ "$pkg" != "$license" ]; then
25+
license="${license#${pkg}::}"
26+
else
27+
pkg="${pkg#vendor/}"
28+
pkg="${pkg%/*}"
29+
fi
30+
31+
printf "%s" "${last:+'\n\n\n'}"
32+
last=x
33+
34+
echo "$pkg" | sed 'p;s/./-/g'
35+
fetch "${license}"
36+
done
37+
}
38+
39+
fetch() {
40+
case "$1" in
41+
*://*) wget -q -O- "${1#*::}";;
42+
*) cat "${1#*::}";;
43+
esac
44+
}
45+
46+
case "${1--gen}" in
47+
-gen)
48+
if [ -t 1 ]; then
49+
generate_notice | ${PAGER:-more}
50+
else
51+
generate_notice
52+
fi
53+
;;
54+
-src) list_vendor_files;;
55+
-all) list_files;;
56+
-h)
57+
echo 'Usage: vendor-licenses [-h|-gen|-src|-all]' >&2
58+
exit 2
59+
;;
60+
*)
61+
echo "Unrecognized argument: '$1'" >&2
62+
exit 1
63+
;;
64+
esac

0 commit comments

Comments
 (0)