diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml deleted file mode 100644 index 1e082f8b..00000000 --- a/.github/workflows/package.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Release -on: - push: - tags: - - "v*.*.*" - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Get release tag - id: get_version - uses: battila7/get-version-action@v2 - - name: Login to GitHub Packages Docker Registry - uses: docker/login-action@v1 - with: - registry: docker.pkg.github.com - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to DockerHub - uses: docker/login-action@v1 - 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 }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..512875f4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }} diff --git a/.github/workflows/build.yaml b/.github/workflows/test.yaml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/test.yaml diff --git a/.gitignore b/.gitignore index 5ce75cb3..d7ef8323 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ raccoon .temp node_modules __debug.* +dist \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..ddcdb251 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,45 @@ +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: ["arm"] + env: + - CGO_ENABLED=1 + +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" diff --git a/Makefile b/Makefile index ecf098d0..28028d1b 100644 --- a/Makefile +++ b/Makefile @@ -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..." @@ -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..." @@ -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 @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index f200e121..1b266519 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Raccoon -![build workflow](https://github.com/raystack/raccoon/actions/workflows/build.yaml/badge.svg) -![package workflow](https://github.com/raystack/raccoon/actions/workflows/package.yaml/badge.svg) + + +![release workflow](https://github.com/raystack/raccoon/actions/workflows/release.yaml/badge.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](LICENSE) [![Version](https://img.shields.io/github/v/release/raystack/raccoon?logo=semantic-release)](Version) diff --git a/buf.gen.yaml b/buf.gen.yaml index 48067c57..49537db0 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -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