diff --git a/.github/workflows/package.yaml b/.github/workflows/release.yaml similarity index 58% rename from .github/workflows/package.yaml rename to .github/workflows/release.yaml index 1e082f8b..a92ba8ec 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/release.yaml @@ -5,7 +5,7 @@ on: - "v*.*.*" jobs: - docker: + release: runs-on: ubuntu-latest steps: - name: Checkout code @@ -24,13 +24,11 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and Push - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: | - docker.pkg.github.com/${{ github.repository }}/raccoon:latest - docker.pkg.github.com/${{ github.repository }}/raccoon:${{ steps.get_version.outputs.version-without-v }} - raystack/raccoon:latest - raystack/raccoon:${{ steps.get_version.outputs.version-without-v }} + - name: setup docker + uses: docker-practice/actions-setup-docker@master + - name: release the project + env: + GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }} + run: | + BUILD_CMD='git config --global --add safe.directory /build/src && cd /build/src && goreleaser release --clean' + echo $BUILD_CMD | docker run -e GITHUB_TOKEN="${GITHUB_TOKEN}" -i --entrypoint /bin/bash -v "$PWD/:/build/src" goreleaser/goreleaser-cross:v1.22.4 diff --git a/.gitignore b/.gitignore index 5ce75cb3..16b5769b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ raccoon .temp node_modules __debug.* + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..8fc9cf1c --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,107 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +project_name: raccoon + +release: + prerelease: auto + +before: + hooks: + - go mod tidy + +changelog: + use: github + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^build:" + + +builds: + - id: "raccoon" + main: ./ + flags: [-trimpath] + ldflags: + - -s -w + - -X github.com/raystack/raccoon/config.Version={{.Tag}} + - -X github.com/raystack/raccoon/config.BuildCommit={{.FullCommit}} + - -X github.com/raystack/raccoon/config.BuildDate={{.Date}} + goos: + - darwin + - linux + - windows + goarch: + - amd64 + - arm64 + ignore: + # confluent-kafka-go doesn't support arm64 on windows + # https://github.com/confluentinc/confluent-kafka-go/blob/master/kafka/librdkafka_vendor/README.md + - goos: windows + goarch: arm64 + env: + - CGO_ENABLED=1 + - >- + {{- if eq .Os "darwin" }} + {{- if eq .Arch "amd64" }}CC=x86_64-apple-darwin21.1-clang{{- end }} + {{- if eq .Arch "arm64" }}CC=aarch64-apple-darwin21.1-clang{{- end }} + {{- end }} + {{- if eq .Os "linux" }} + {{- if eq .Arch "amd64" }}CC=x86_64-linux-gnu-gcc{{- end}} + {{- if eq .Arch "arm64" }}CC=aarch64-linux-gnu-gcc{{- end }} + {{- end}} + {{- if eq .Os "windows" }} + {{- if eq .Arch "amd64" }}CC=x86_64-w64-mingw32-gcc{{- end }} + {{- end}} + +archives: + - id: "archives" + format_overrides: + - goos: windows + format: zip + +dockers: + - id: dockerhub + image_templates: + - "docker.io/raystack/{{.ProjectName}}:latest" + - "docker.io/raystack/{{.ProjectName}}:{{ .Version }}" + - "docker.io/raystack/{{.ProjectName}}:{{ .Tag }}-amd64" + +nfpms: + - maintainer: Raystack + description: Scalable event ingestion tool. + homepage: https://github.com/raystack/raccoon + license: Apache 2.0 + formats: + - deb + - rpm + - apk + +scoops: + - homepage: "https://github.com/raystack/raccoon" + description: "Scalable event ingestion tool" + license: Apache 2.0 + repository: + owner: raystack + name: scoop-bucket + +brews: + - name: raccoon + homepage: "https://github.com/raystack/raccoon" + description: "Scalable event ingestion 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: suhag.ravi@gmail.com \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 124361e3..ea619654 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN PROTOC_ZIP=protoc-3.17.3-linux-x86_64.zip && \ unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \ rm -f $PROTOC_ZIP COPY . . -RUN make build +RUN make build FROM debian:bookworm-slim diff --git a/Makefile b/Makefile index ecf098d0..edf40320 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ 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" +VERSION := "$(shell git describe --tags ${TAG})" BUILD_DIR=dist PROTON_COMMIT := "ccbf219312db35a934361ebad895cb40145ca235" +BUILD_FLAGS=-trimpath +LD_FLAGS=-ldflags "-s -w -X ${NAME}/config.Version=${VERSION}" .PHONY: all build clean test tidy vet proto setup format generate @@ -32,18 +34,21 @@ 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/goreleaser/goreleaser/v2@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 config: ## Generate the sample config file @echo "Initializing sample server config..." @cp .env.sample .env build: ## Build the raccoon binary - @echo "Building racccoon version ${VERSION}..." - go build + @echo "Building raccoon version ${VERSION}..." + go build ${BUILD_FLAGS} ${LD_FLAGS} ${NAME} @echo "Build complete" install: - @echo "Installing Guardian to ${GOBIN}..." + @echo "Installing Raccoon to ${GOBIN}..." + go install ${BUILD_FLAGS} ${LD_FLAGS} ${NAME} @go install test: ## Run the tests diff --git a/app/proc.go b/app/proc.go index 9f340218..9427df1d 100644 --- a/app/proc.go +++ b/app/proc.go @@ -3,6 +3,7 @@ package app import ( "context" + "github.com/raystack/raccoon/config" "github.com/raystack/raccoon/logger" ) @@ -14,6 +15,7 @@ func Run() error { //@TODO - init config //start server + logger.Infof("Raccoon %s", config.Version) StartServer(ctx, cancel) logger.Info("App.Run --> Complete") <-ctx.Done() diff --git a/config/version.go b/config/version.go new file mode 100644 index 00000000..b4a27a79 --- /dev/null +++ b/config/version.go @@ -0,0 +1,3 @@ +package config + +var Version, BuildCommit, BuildDate string diff --git a/version.txt b/version.txt deleted file mode 100644 index eb9e63b2..00000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -v0.2.2 \ No newline at end of file