Skip to content

Commit

Permalink
build: update build workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Jun 19, 2024
1 parent a9f57c7 commit b543a76
Show file tree
Hide file tree
Showing 13 changed files with 357 additions and 80 deletions.
45 changes: 20 additions & 25 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
name: Test
name: Build

on:
- push
- pull_request
push:
branches:
- main

jobs:
test:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Invoking go test
run: make test
- name: Invoking go bench test
run: make test-bench

build:
runs-on: ubuntu-latest
steps:
- name: Setup Go
- run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v2
- name: Build
run: make build
go-version: "stable"
cache: true
- name: Get release tag
id: get_version
uses: battila7/get-version-action@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: ~v2
args: --snapshot --clean
36 changes: 0 additions & 36 deletions .github/workflows/package.yaml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Invoking go test
run: make test
- name: Invoking go bench test
run: make test-bench

build:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22.4"
- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: actions/checkout@v2
- name: Build
run: make build
72 changes: 72 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: 2

project_name: raccoon

release:
prerelease: auto

before:
hooks:
- go mod tidy
- make clean

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^build:"

builds:
- id: darwin-amd64
main: ./main.go
binary: raccoon
goos:
- darwin
goarch:
- amd64
env:
- CGO_ENABLED=1
flags:
- -mod=readonly

archives:
- id: "archives"
format_overrides:
- goos: windows
format: zip

checksum:
name_template: "checksums.txt"

snapshot:
name_template: "{{ .Tag }}-next"

dockers:
- goos: linux
goarch: amd64
ids:
- linux
dockerfile: Dockerfile
image_templates:
- "docker.io/raystack/{{.ProjectName}}:latest"
- "docker.io/raystack/{{.ProjectName}}:{{ .Version }}"
- "docker.io/raystack/{{.ProjectName}}:{{ .Version }}-amd64"

brews:
- name: raccoon
homepage: "https://github.com/raystack/raccoon"
description: "Event sourcing tool."
repository:
owner: raystack
name: homebrew-tap
license: "Apache 2.0"
directory: Formula
dependencies:
- name: git
install: |-
bin.install "raccoon"
commit_author:
name: Ravi Suhag
email: [email protected]
23 changes: 7 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
NAME="github.com/raystack/raccoon"
COMMIT := $(shell git rev-parse --short HEAD)
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})-next"
BUILD_DIR=dist
PROTON_COMMIT := "ccbf219312db35a934361ebad895cb40145ca235"
PROTON_COMMIT := "a4240deecb8345e0e95261f22288f937422594b7"

.PHONY: all build clean test tidy vet proto setup format generate
.PHONY: all build clean test tidy vet proto setup format

all: clean test build format lint
all: clean test lint build

tidy:
@echo "Tidy up go.mod..."
Expand All @@ -19,19 +16,17 @@ lint: ## Lint checker

clean: tidy ## Clean the build artifacts
@echo "Cleaning up build directories..."
@rm -rf $coverage.out ${BUILD_DIR}
@rm -rf $coverage.out raccoon

proto: ## Generate the protobuf files
@echo "Generating protobuf from raystack/proton"
@echo " [info] make sure correct version of dependencies are installed using 'make install'"
@buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path raystack/raccoon -v
@cp -R proto/raystack/raccoon/v1beta1/* proto/ && rm -Rf proto/raystack
@buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --path raystack/raccoon -v
@echo "Protobuf compilation finished"

setup: ## Install required dependencies
@echo "> Installing dependencies..."
go mod tidy
go install github.com/bufbuild/buf/cmd/buf@v1.23.0
go install github.com/bufbuild/buf/cmd/buf@v1.33.0

config: ## Generate the sample config file
@echo "Initializing sample server config..."
Expand All @@ -43,7 +38,7 @@ build: ## Build the raccoon binary
@echo "Build complete"

install:
@echo "Installing Guardian to ${GOBIN}..."
@echo "Installing Raccoon to ${GOBIN}..."
@go install

test: ## Run the tests
Expand All @@ -52,10 +47,6 @@ test: ## Run the tests
test-bench: # run benchmark tests
@go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark ]

vendor: ## Update the vendor directory
@echo "Updating vendor directory..."
@go mod vendor

docker-run:
docker compose build
docker compose up -d
6 changes: 3 additions & 3 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: v1
version: v2
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
- remote: buf.build/protocolbuffers/go:v1.31.0
out: proto
opt: paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
- remote: buf.build/grpc/go:v1.3.0
out: proto
opt: paths=source_relative,require_unimplemented_servers=true
1 change: 1 addition & 0 deletions dist/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"metadata.json","path":"dist/metadata.json","internal_type":30,"type":"Metadata"},{"name":"raccoon","path":"dist/darwin-amd64_darwin_amd64_v1/raccoon","goos":"darwin","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"raccoon","Ext":"","ID":"darwin-amd64"}},{"name":"raccoon_v0.2.2-next_darwin_amd64.tar.gz","path":"dist/raccoon_v0.2.2-next_darwin_amd64.tar.gz","goos":"darwin","goarch":"amd64","goamd64":"v1","internal_type":1,"type":"Archive","extra":{"Binaries":["raccoon"],"Checksum":"sha256:8446b9f2283836952da7130f7cfaca13502ea3332f13c1d25eba17e34952dc53","Format":"tar.gz","ID":"archives","Replaces":null,"WrappedIn":""}},{"name":"checksums.txt","path":"dist/checksums.txt","internal_type":12,"type":"Checksum","extra":{}},{"name":"raccoon.rb","path":"dist/homebrew/Formula/raccoon.rb","internal_type":16,"type":"Brew Tap","extra":{"BrewConfig":{"name":"raccoon","repository":{"owner":"raystack","name":"homebrew-tap","git":{},"pull_request":{"base":{}}},"commit_author":{"name":"Ravi Suhag","email":"[email protected]"},"commit_msg_template":"Brew formula update for {{ .ProjectName }} version {{ .Tag }}","directory":"Formula","install":"bin.install \"raccoon\"","dependencies":[{"name":"git"}],"description":"Event sourcing tool.","homepage":"https://github.com/raystack/raccoon","license":"Apache 2.0","goarm":"6","goamd64":"v1"}}}]
1 change: 1 addition & 0 deletions dist/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8446b9f2283836952da7130f7cfaca13502ea3332f13c1d25eba17e34952dc53 raccoon_v0.2.2-next_darwin_amd64.tar.gz
Loading

0 comments on commit b543a76

Please sign in to comment.