Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maldridge committed Feb 24, 2022
1 parent 3a8185f commit 098a428
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
before:
hooks:
- go mod vendor
- scripts/prepare.sh
builds:
- goos:
- darwin
- freebsd
- linux
- windows
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- LICENSE
- NOTICE
- README.md
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
release:
github:
owner: netauth
name: sftpgo-hook
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/netauth/netauth v0.6.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.1
google.golang.org/grpc v1.43.0
)

require (
Expand All @@ -28,7 +29,6 @@ require (
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions scripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

./scripts/vendor-licenses > NOTICE
64 changes: 64 additions & 0 deletions scripts/vendor-licenses
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

list_vendor_files() {
find vendor -type f -a \( -iname 'COPYING*' -o -iname 'LICENSE*' \) | sort
}

list_files() {
goroot="$(go env GOROOT)"
goid='Go programming language'
if [ -r "$goroot/LICENSE" ]; then
echo "${goid}::$goroot/LICENSE"
elif [ -r /usr/share/licenses/go/LICENSE ]; then
echo "${goid}::/usr/share/licenses/go/LICENSE"
else # last restort: HTTP
echo "${goid}::https://golang.org/LICENSE?m=text"
fi
list_vendor_files
}

generate_notice() {
last=
$0 -all | while IFS=$'\n' read -r license; do
pkg="${license%%::*}"
if [ "$pkg" != "$license" ]; then
license="${license#${pkg}::}"
else
pkg="${pkg#vendor/}"
pkg="${pkg%/*}"
fi

printf "%s" "${last:+'\n\n\n'}"
last=x

echo "$pkg" | sed 'p;s/./-/g'
fetch "${license}"
done
}

fetch() {
case "$1" in
*://*) wget -q -O- "${1#*::}";;
*) cat "${1#*::}";;
esac
}

case "${1--gen}" in
-gen)
if [ -t 1 ]; then
generate_notice | ${PAGER:-more}
else
generate_notice
fi
;;
-src) list_vendor_files;;
-all) list_files;;
-h)
echo 'Usage: vendor-licenses [-h|-gen|-src|-all]' >&2
exit 2
;;
*)
echo "Unrecognized argument: '$1'" >&2
exit 1
;;
esac

0 comments on commit 098a428

Please sign in to comment.