Skip to content

Commit

Permalink
feat: integrate Goreleaser for building binaries (#19)
Browse files Browse the repository at this point in the history
added Goreleaser config and GH action to build binaries for all supported platforms and architectures when a new release is published
added new `snapshot` and `check-goreleaser-install` Make targets
  • Loading branch information
dylan-bourque authored Apr 19, 2022
1 parent 197366e commit 2adcb3b
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: build-binary-artifacts

on:
# run when a release is published
release:
types: [published]

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build/test outputs
bin/
dist/
*.test
*profile.out

Expand Down
46 changes: 46 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project_name: csproto
before:
hooks:
- go mod tidy
builds:
- id: protoc-gen-fastmarshal
main: ./cmd/protoc-gen-fastmarshal
binary: protoc-gen-fastmarshal
flags:
- -trimpath
env:
- CGO_ENABLED=0
goarch:
- '386'
- amd64
- arm
- arm64
goarm:
- '6'
- '7'
goos:
- linux
- darwin
- windows
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incminor .Version }}-pre.{{.Timestamp}}.{{.ShortCommit}}"
changelog:
use: github-native
filters:
exclude:
- '^(docs|test)(\\(.+\\))?:'
release:
prerelease: auto
mode: append
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,15 @@ lint: check-golangci-lint-install
.PHONY: check-golangci-lint-install
check-golangci-lint-install:
ifeq ("$(shell command -v golangci-lint)", "")
$(error golangci-lint was not found. Please install it using the method of your choice\n https://golangci-lint.run/usage/install/#local-installation)
$(error golangci-lint was not found. Please install it using the method of your choice. (https://golangci-lint.run/usage/install/#local-installation))
endif

.PHONY: snapshot
snapshot: check-goreleaser-install
@goreleaser release --snapshot --rm-dist

.PHONY: check-goreleaser-install
check-goreleaser-install:
ifeq ("$(shell command -v goreleaser)", "")
$(error goreleaser was not found. Please install it using the method of your choice. (https://goreleaser.com/install))
endif

0 comments on commit 2adcb3b

Please sign in to comment.