Skip to content

Commit

Permalink
Set up goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
leocomelli committed Jul 27, 2022
1 parent c8024ed commit 59f2f7e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
25 changes: 3 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

17 changes: 1 addition & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/[email protected]
@go install github.com/golangci/golangci-lint/cmd/[email protected]

GOFILES=$(shell find . -type f -name '*.go' -not -path "./.git/*")

.PHONY: lint
lint:
golangci-lint run
Expand All @@ -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:
Expand Down
34 changes: 34 additions & 0 deletions goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 59f2f7e

Please sign in to comment.