Skip to content

Commit

Permalink
chore(release): move to goreleaser for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Wolfe committed Feb 16, 2021
1 parent b9557ae commit 5d83e08
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 67 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ jobs:

build:
name: Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:

- name: Set up Go 1.x
Expand All @@ -22,10 +25,10 @@ jobs:
uses: actions/checkout@v2

- name: Test
run: make ci
run: go test -v ./...

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.32
version: v1.32
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: release

on:
push:
tags:
- '*'

jobs:
release:
name: release
runs-on: macOS-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15.x

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
.credentials
/dist
/dist*
/build
/packages
/release
Expand Down
29 changes: 29 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
project_name: saml2aws

builds:
- main: ./cmd/saml2aws/main.go
binary: saml2aws
flags:
- -trimpath
- -v
ldflags:
- -s -w -X main.Version={{.Version}}
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm64
- arm
archives:
- format: tar.gz
wrap_in_directory: false
format_overrides:
- goos: windows
format: zip
# remove README and LICENSE
files:
- LICENSE.md
- README.md
44 changes: 5 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@ $(BIN_DIR)/golangci-lint-${GOLANGCI_VERSION}:
@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}
@mv $(BIN_DIR)/golangci-lint $@

prepare:
GOBIN=$(BIN_DIR) go install github.com/buildkite/github-release
GOBIN=$(BIN_DIR) go install github.com/mitchellh/gox
GOBIN=$(BIN_DIR) go install github.com/axw/gocov/gocov
GOBIN=$(BIN_DIR) go install golang.org/x/tools/cmd/cover
$(BIN_DIR)/goreleaser:
@go get -u github.com/goreleaser/goreleaser
@env GOBIN=$(BIN_DIR) GO111MODULE=on go install github.com/goreleaser/goreleaser

mod:
@go mod download
@go mod tidy

compile: mod
@rm -rf build/
@$(BIN_DIR)/gox -ldflags "-X main.Version=$(VERSION)" \
-osarch="darwin/amd64" \
-osarch="linux/i386" \
-osarch="linux/amd64" \
-osarch="windows/amd64" \
-osarch="windows/i386" \
-output "build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \
${SOURCE_FILES}

lint: $(BIN_DIR)/golangci-lint
@echo "--- lint all the things"
@$(BIN_DIR)/golangci-lint run ./...
Expand All @@ -55,33 +42,12 @@ fmt: lint-fix
install:
go install ./cmd/saml2aws

dist:
$(eval FILES := $(shell ls build))
@rm -rf dist && mkdir dist
@for f in $(FILES); do \
(cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \
(cd $(shell pwd)/dist && shasum -a 512 $$f.tar.gz > $$f.sha512); \
echo $$f; \
done

release:
@$(BIN_DIR)/github-release "v$(VERSION)" dist/* --commit "$(git rev-parse HEAD)" --github-repository versent/$(NAME)

test:
@$(BIN_DIR)/gocov test $(SOURCE_FILES) | $(BIN_DIR)/gocov report
release-snapshot: $(BIN_DIR)/goreleaser
$(BIN_DIR)/goreleaser --snapshot --rm-dist

clean:
@rm -fr ./build

packages:
rm -rf package && mkdir package
rm -rf stage && mkdir -p stage/usr/bin
cp build/saml2aws_*_linux_amd64/saml2aws stage/usr/bin
fpm --name $(NAME) -a x86_64 -t rpm -s dir --version $(VERSION) --iteration $(ITERATION) -C stage -p package/$(NAME)-$(VERSION)_$(ITERATION).rpm usr
fpm --name $(NAME) -a x86_64 -t deb -s dir --version $(VERSION) --iteration $(ITERATION) -C stage -p package/$(NAME)-$(VERSION)_$(ITERATION).deb usr
shasum -a 512 package/$(NAME)-$(VERSION)_$(ITERATION).rpm > package/$(NAME)-$(VERSION)_$(ITERATION).rpm.sha512
shasum -a 512 package/$(NAME)-$(VERSION)_$(ITERATION).deb > package/$(NAME)-$(VERSION)_$(ITERATION).deb.sha512

generate-mocks:
mockery -dir pkg/prompter --all
mockery -dir pkg/provider/okta -name U2FDevice
Expand Down
28 changes: 18 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,38 @@ require (
github.com/Azure/go-ntlmssp v0.0.0-20180416175057-4b934ac9dad3
github.com/PuerkitoBio/goquery v1.5.1
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/alecthomas/units v0.0.0-20190910110746-680d30ca3117 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/avast/retry-go v2.6.0+incompatible
github.com/aws/aws-sdk-go v1.35.24
github.com/aws/aws-sdk-go v1.37.11
github.com/beevik/etree v1.0.1
github.com/danieljoos/wincred v1.1.0
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/godbus/dbus v4.1.0+incompatible // indirect
github.com/google/uuid v1.1.1
github.com/google/uuid v1.2.0
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d
github.com/kr/text v0.2.0 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/marshallbrekka/go-u2fhost v0.0.0-20210111072507-3ccdec8c8105
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.7.1
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
github.com/stretchr/testify v1.5.1
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/tidwall/gjson v1.1.1
github.com/tidwall/match v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
golang.org/x/sys v0.0.0-20210216163648-f7da38b97c65 // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/ini.v1 v1.57.0
golang.org/x/text v0.3.5 // indirect
gopkg.in/ini.v1 v1.62.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

// replace github.com/keybase/go-keychain => github.com/wolfeidau/go-keychain v0.0.0-20210215232950-1e19148f864f
Loading

0 comments on commit 5d83e08

Please sign in to comment.