From 59f2f7e38b26f36d5afc6b4323700cf0efee629d Mon Sep 17 00:00:00 2001 From: Leonardo Comelli Date: Wed, 27 Jul 2022 15:41:32 -0300 Subject: [PATCH] Set up goreleaser --- .github/workflows/release.yml | 25 +++---------------------- Makefile | 17 +---------------- goreleaser.yml | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8356020..8c39773 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,29 +24,10 @@ jobs: uses: actions/checkout@v2 - name: Generate releases - run: make releases - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false - - - name: GitHub Release - uses: softprops/action-gh-release@v1 - if: success() + uses: goreleaser/goreleaser-action@v2 with: - draft: true - files: | - dist/asl_darwin-amd64 - dist/asl_linux-amd64 - dist/asl_windows-amd64 - name: ${{ github.ref }} + version: latest + args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/Makefile b/Makefile index dd91e5e..f25811b 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,12 @@ #!/usr/bin/make .DEFAULT_GOAL := all -PLATFORMS := linux/amd64 darwin/amd64 windows/amd64 - -LD_FLAGS := -ldflags "-X main.Version=`git describe --tags` -X main.BuildDate=`date -u +%Y-%m-%d_%H:%M:%S` -X main.GitHash=`git rev-parse HEAD`" - -temp = $(subst /, ,$@) -os = $(word 1, $(temp)) -arch = $(word 2, $(temp)) .PHONY: setup setup: @go install github.com/securego/gosec/v2/cmd/gosec@v2.12.0 @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.2 -GOFILES=$(shell find . -type f -name '*.go' -not -path "./.git/*") - .PHONY: lint lint: golangci-lint run @@ -26,13 +17,7 @@ sec: .PHONY: bin bin: - go build -o ./dist/asl - -.PHONY: releases -releases: $(PLATFORMS) - -$(PLATFORMS): - GOOS=$(os) GOARCH=$(arch) go build $(LD_FLAGS) -o 'dist/asl_$(os)-$(arch)' + @go build -o ./dist/asl .PHONY: test test: diff --git a/goreleaser.yml b/goreleaser.yml new file mode 100644 index 0000000..1c15343 --- /dev/null +++ b/goreleaser.yml @@ -0,0 +1,34 @@ +project_name: asl +env: + - GO111MODULE=on + - GOPROXY=https://proxy.golang.org +before: + hooks: + - go mod download +builds: + - + binary: asl + id: asl + ldflags: "-X main.Version={{.Version}} -X main.BuildDate={{.Date}} -X main.GitHash={{.Commit}}" + env: + - CGO_ENABLED=0 + flags: + - -buildmode + - exe + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + goarm: + - 7 +archives: + - + id: asl + format: binary + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + replacements: + darwin: Darwin + linux: Linux + amd64: x86_64