Skip to content

Commit

Permalink
Added goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
hamstah committed Apr 9, 2019
1 parent 7457d1e commit 15b46c8
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 48 deletions.
224 changes: 224 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
before:
hooks:
- go mod download
archive:
format: binary
checksum:
name_template: 'SHA256SUMS'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
sign:
signature: "${artifact}.asc"
artifacts: all
nfpm:
vendor: hamstah
homepage: https://github.com/hamstah/awstools
maintainer: Nico Esteves <contact@hamstah.com>
license: MIT
formats:
- deb
- rpm
builds:

- env:
- CGO_ENABLED=0
main: ./aws/dump/
binary: aws-dump
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./elb/resolve-alb-external-url/
binary: elb-resolve-alb-external-url
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./elb/resolve-elb-external-url/
binary: elb-resolve-elb-external-url
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ec2/ip-from-name/
binary: ec2-ip-from-name
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ec2/describe-instances/
binary: ec2-describe-instances
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./kms/env/
binary: kms-env
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./cloudwatch/put-metric-data/
binary: cloudwatch-put-metric-data
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./iam/sync-users/
binary: iam-sync-users
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./iam/auth-proxy/
binary: iam-auth-proxy
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./iam/session/
binary: iam-session
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./iam/public-ssh-keys/
binary: iam-public-ssh-keys
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ecs/dashboard/
binary: ecs-dashboard
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ecs/deploy/
binary: ecs-deploy
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ecs/locate/
binary: ecs-locate
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ecs/run-task/
binary: ecs-run-task
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./lambda/ping/
binary: lambda-ping
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./ecr/get-login/
binary: ecr-get-login
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
- env:
- CGO_ENABLED=0
main: ./s3/download/
binary: s3-download
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{.Version}} -X github.com/hamstah/awstools/common.CommitHash={{.ShortCommit}}"
38 changes: 38 additions & 0 deletions scripts/.goreleaser.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
before:
hooks:
- go mod download
archive:
format: binary
checksum:
name_template: 'SHA256SUMS'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
sign:
signature: "${artifact}.asc"
artifacts: all
nfpm:
vendor: hamstah
homepage: https://github.com/hamstah/awstools
maintainer: Nico Esteves <contact@hamstah.com>
license: MIT
formats:
- deb
- rpm
builds:
{% for build in builds %}
- env:
- CGO_ENABLED=0
main: {{build.src}}
binary: {{build.name}}
goos:
- linux
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/hamstah/awstools/common.Version={{ '{{' }}.Version{{ '}}' }} -X github.com/hamstah/awstools/common.CommitHash={{ '{{' }}.ShortCommit{{ '}}' }}"
{%- endfor %}
48 changes: 0 additions & 48 deletions scripts/build.sh

This file was deleted.

14 changes: 14 additions & 0 deletions scripts/generate-goreleaser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -u

base=$(dirname $0)

j2=$(which j2)
if [ $? -ne 0 ]; then
echo "j2 not found, install with pip"
exit 1
fi

set -e
./${base}/generate-list.sh | j2 --format=json ${base}/.goreleaser.yml.j2 > .goreleaser.yml

22 changes: 22 additions & 0 deletions scripts/generate-list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -eu

base=$(dirname $0)/..


echo -n '{"builds": ['
c=0
find ${base} -name "main.go" | while read src; do
src=$(realpath --relative-to=${base} ${src})
fname=$(echo ${src} | awk -F/ '{print $1"-"$2}')
dir=$(echo ${src} | awk -F/ '{print $1"/"$2}')
if [ $c -ne 0 ]; then
echo ","
else
echo ""
fi
echo -n '{"src": "./'${dir}/'", "name":"'${fname}'"}'
c=$((c + 1))
done
echo ""
echo "]}"

0 comments on commit 15b46c8

Please sign in to comment.