From 2adcb3bcb517cefdef1835e75b35d10dbb66d0d3 Mon Sep 17 00:00:00 2001 From: Dylan Bourque Date: Tue, 19 Apr 2022 11:02:48 -0500 Subject: [PATCH] feat: integrate Goreleaser for building binaries (#19) 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 --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yaml | 46 +++++++++++++++++++++++++++++++++++ Makefile | 12 ++++++++- 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a2d2492 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 5e2c116..3ead75e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # build/test outputs bin/ +dist/ *.test *profile.out diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4f855b5 --- /dev/null +++ b/.goreleaser.yaml @@ -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 diff --git a/Makefile b/Makefile index 7610b4a..128e1a2 100644 --- a/Makefile +++ b/Makefile @@ -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