Skip to content

Commit

Permalink
initial conversion to goreleaser based release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
attachmentgenie committed Feb 16, 2022
1 parent b47479b commit 61371e5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 24 deletions.
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:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
-
name: Run 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
Expand Up @@ -11,4 +11,4 @@ webhook-go*
webhook.yml

bin/
build/
dist/
39 changes: 39 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
before:
hooks:
- go mod download
archives:
- id: webhook-go
builds:
- id: webhook-go
env:
- CGO_ENABLED=0
goos:
- linux
- windows
goarch:
- amd64
- arm
- arm64
goarm:
- 6
- 7
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
release:
github:
owner: voxpupuli
name: webhook-go
prerelease: true
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
34 changes: 11 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
help: ## Print this message
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

GOARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
NAME := webhook-go
#VERSION := $(shell date +'v%y%m.%-d.%-H%M%S')
#DATE := $(shell date +'%y.%m.%d-%H:%M:%S')
Expand All @@ -10,7 +12,9 @@ test: ## Run go tests
@go test ./...

build: ## Build a local binary
@go build -o bin/${NAME} .
@goreleaser build --single-target --snapshot --rm-dist
@mkdir -p bin
@cp dist/$(NAME)_$(GOOS)_$(GOARCH)/$(NAME) bin/

run: ## Run webhook-go
@cp webhook.yml.example webhook.yml
Expand All @@ -20,29 +24,13 @@ clean: ## Clean up build
@echo "Cleaning Go environment..."
@go clean
@echo "Cleaning build directory..."
@rm -rf build/
@rm -rf dist/
@echo "Cleaning local bin directory..."
@rm -rf bin/

compile: clean windows linux rpi rpisf ## Build for all supported OSes

windows: ## Build a Windows 64-bit binary
@echo "Building Windows binary"
GOOS=windows GOARCH=amd64 go build -o build/windows/webhook-go-windows-x84_64.exe .
@zip build/webhook-go-windows-x84_64.zip build/windows/webhook-go-windows-x84_64.exe

linux: ## Build a Linux 64-bit binary
@echo "Building Linux AMD64 binary"
GOOS=linux GOARCH=amd64 go build -o build/linux/webhook-go-linux-x86_64 .
@tar czf build/webhook-go-linux-x86_64.tar.gz build/linux/webhook-go-linux-x86_64

rpi: ## Build a Raspberry Pi Linux binary
@echo "Building Linux ARM binary"
GOOS=linux GOARCH=arm go build -o build/rpi/webhook-go-rpi .
@tar cJf build/webhook-go-rpi.tar.xz build/rpi/webhook-go-rpi

rpisf: ## Build a Raspberry Pi 64-bit binary
@echo "Building Linux ARM64 binary"
GOOS=linux GOARCH=arm64 go build -o build/rpi/webhook-go-rpi64 .
@tar cJf build/webhook-go-rpi64.tar.xz build/rpi/webhook-go-rpi64
snapshot: ## Build artifacts without releasing
goreleaser release --snapshot --rm-dist

compile: release ## Alias for release
release: ## Build for all supported OSes
goreleaser release

0 comments on commit 61371e5

Please sign in to comment.