Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzvonimir committed Mar 28, 2024
1 parent e85452f commit 4af19d4
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 18 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ on:
branches: [ "main" ]

jobs:
build-and-test:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: bufbuild/buf-setup-action@v1
with:
version: "1.30.0"

- uses: bufbuild/buf-lint-action@v1

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.4'

- name: Build
run: make build
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
with:
version: "1.30.0"
- uses: bufbuild/buf-lint-action@v1

- name: Test
run: make test
build-and-test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.4'
- name: Build
run: make build
- name: Test
run: make test
57 changes: 57 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create Release

on:
push:
tags:
- 'v*'

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: build-linux
suffix: linux-amd64
- target: build-mac
suffix: darwin-amd64
- target: build-mac-m1
suffix: darwin-arm64
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.4'

- name: Build Binary
run: |
make ${{ matrix.target }}
zip "${{ env.TARGET }}-${{ matrix.suffix }}.zip" "${{ env.TARGET }}"
- uses: actions/upload-artifact@v2
with:
name: ${{ env.TARGET }}-${{ matrix.suffix }}.zip
path: ${{ env.TARGET }}-${{ matrix.suffix }}.zip

create-release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ endif
.PHONY: \
all \
build \
build-mac \
build-mac-m1 \
build-linux \
deps \
doc \
buf \
Expand All @@ -65,6 +68,18 @@ all: build debug
build: proto
CGO_ENABLED=1 GOOS=$(UNAME) go build -a -tags netgo -ldflags="$(LDFLAGS)" -o "$(TARGET)" .

## Build binary for linux amd64
build-linux: proto
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags="$(LDFLAGS)" -o "$(TARGET)" .

## Build binary for darwin amd64
build-mac: proto
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -a -tags netgo -ldflags="$(LDFLAGS)" -o "$(TARGET)" .

## Build binary for darwin arm64
build-mac-m1: proto
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -a -tags netgo -ldflags="$(LDFLAGS)" -o "$(TARGET)" .

## Install binary to GOPATH
install: proto
CGO_ENABLED=1 GOOS=$(UNAME) go install -a -tags netgo -ldflags="$(LDFLAGS)"
Expand Down

0 comments on commit 4af19d4

Please sign in to comment.