From 4331d457ec48283e5f8d15a0781d51b961b29f92 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:40:59 +0100 Subject: [PATCH 1/3] chore: remove traces of template --- .releaserc.yml | 18 ++++++++--------- Dockerfile | 4 ++-- Makefile | 8 ++++---- README.md | 34 +++++++------------------------- cmd/root.go | 6 +++--- cmd/version.go | 2 +- go.mod | 2 +- internal/version/version_test.go | 4 ++-- main.go | 2 +- 9 files changed, 30 insertions(+), 50 deletions(-) diff --git a/.releaserc.yml b/.releaserc.yml index 594dfc5..87c2bfb 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -8,7 +8,7 @@ plugins: - preset: conventionalcommits - - "@semantic-release/changelog" - changelogFile: CHANGELOG.md - changelogTitle: "# ØKP4 template-go" + changelogTitle: "# ØKP4 minio auth plugin" - - "@google/semantic-release-replace-plugin" - replacements: - files: [version] @@ -25,18 +25,18 @@ plugins: make build-go-all - - "@semantic-release/github" - assets: - - name: template-go_darwin_amd64 + - name: minio-auth-plugin_darwin_amd64 label: Binary - Darwin amd64 - path: "./target/dist/darwin/amd64/template-go" - - name: template-go_darwin_arm64 + path: "./target/dist/darwin/amd64/minio-auth-plugin" + - name: minio-auth-plugin_darwin_arm64 label: Binary - Darwin arm64 - path: "./target/dist/darwin/arm64/template-go" - - name: template-go_linux_amd64 + path: "./target/dist/darwin/arm64/minio-auth-plugin" + - name: minio-auth-plugin_linux_amd64 label: Binary - Linux amd64 - path: "./target/dist/linux/amd64/template-go" - - name: template-go_windows_amd64.exe + path: "./target/dist/linux/amd64/minio-auth-plugin" + - name: minio-auth-plugin_windows_amd64.exe label: Binary - Windows amd64 - path: "./target/dist/windows/amd64/template-go.exe" + path: "./target/dist/windows/amd64/minio-auth-plugin.exe" - - "@semantic-release/git" - assets: - CHANGELOG.md diff --git a/Dockerfile b/Dockerfile index 3c7e5b3..ea4b31a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ RUN make build CGO_ENABLED=0 #--- Image stage FROM alpine:3.19.1 -COPY --from=go-builder /src/target/dist/template-go /usr/bin/template-go +COPY --from=go-builder /src/target/dist/minio-auth-plugin /usr/bin/minio-auth-plugin WORKDIR /opt -ENTRYPOINT ["/usr/bin/template-go"] +ENTRYPOINT ["/usr/bin/minio-auth-plugin"] diff --git a/Makefile b/Makefile index e7529bc..bb22d5f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # ℹ Freely based on: https://gist.github.com/thomaspoignant/5b72d579bd5f311904d973652180c705 # Constants -BINARY_NAME = template-go +BINARY_NAME = minio-auth-plugin TARGET_FOLDER = target DIST_FOLDER = $(TARGET_FOLDER)/dist DOCKER_IMAGE_GOLANG_CI = golangci/golangci-lint:v1.55 @@ -17,9 +17,9 @@ COLOR_RESET = $(shell tput -Txterm sgr0) VERSION := $(shell cat version) COMMIT := $(shell git log -1 --format='%H') LD_FLAGS = \ - -X okp4/template-go/internal/version.Name=$(BINARY_NAME) \ - -X okp4/template-go/internal/version.Version=$(VERSION) \ - -X okp4/template-go/internal/version.Commit=$(COMMIT) + -X okp4/minio-auth-plugin/internal/version.Name=$(BINARY_NAME) \ + -X okp4/minio-auth-plugin/internal/version.Version=$(VERSION) \ + -X okp4/minio-auth-plugin/internal/version.Commit=$(COMMIT) BUILD_FLAGS := -ldflags '$(LD_FLAGS)' # Commands diff --git a/README.md b/README.md index 1920248..73ae645 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,17 @@ -# Golang Template +# Minio auth plugin -> Template for golang projects @okp4. +> Minio authentication connector to the OKP4 chain. -[![version](https://img.shields.io/github/v/release/okp4/template-go?style=for-the-badge&logo=github)](https://github.com/okp4/template-go/releases) -[![lint](https://img.shields.io/github/actions/workflow/status/okp4/template-go/lint.yml?branch=main&label=lint&style=for-the-badge&logo=github)](https://github.com/okp4/template-go/actions/workflows/lint.yml) -[![build](https://img.shields.io/github/actions/workflow/status/okp4/template-go/build.yml?branch=main&label=build&style=for-the-badge&logo=github)](https://github.com/okp4/template-go/actions/workflows/build.yml) -[![test](https://img.shields.io/github/actions/workflow/status/okp4/template-go/test.yml?branch=main&label=test&style=for-the-badge&logo=github)](https://github.com/okp4/template-go/actions/workflows/test.yml) -[![codecov](https://img.shields.io/codecov/c/github/okp4/template-go?style=for-the-badge&token=6NL9ICGZQS&logo=codecov)](https://codecov.io/gh/okp4/template-go) +[![version](https://img.shields.io/github/v/release/okp4/minio-auth-plugin?style=for-the-badge&logo=github)](https://github.com/okp4/minio-auth-plugin/releases) +[![lint](https://img.shields.io/github/actions/workflow/status/okp4/minio-auth-plugin/lint.yml?branch=main&label=lint&style=for-the-badge&logo=github)](https://github.com/okp4/minio-auth-plugin/actions/workflows/lint.yml) +[![build](https://img.shields.io/github/actions/workflow/status/okp4/minio-auth-plugin/build.yml?branch=main&label=build&style=for-the-badge&logo=github)](https://github.com/okp4/minio-auth-plugin/actions/workflows/build.yml) +[![test](https://img.shields.io/github/actions/workflow/status/okp4/minio-auth-plugin/test.yml?branch=main&label=test&style=for-the-badge&logo=github)](https://github.com/okp4/minio-auth-plugin/actions/workflows/test.yml) +[![codecov](https://img.shields.io/codecov/c/github/okp4/minio-auth-plugin?style=for-the-badge&token=6NL9ICGZQS&logo=codecov)](https://codecov.io/gh/okp4/minio-auth-plugin) [![conventional commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge&logo=conventionalcommits)](https://conventionalcommits.org) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=for-the-badge)](https://github.com/okp4/.github/blob/main/CODE_OF_CONDUCT.md) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=for-the-badge)](https://opensource.org/licenses/BSD-3-Clause) -## Purpose & Philosophy - -This repository holds the template for building Golang projects with a consistent set of standards accros all [OKP4](https://github.com/okp4) projects. We are convinced that the quality of the code depends on clear and consistent coding conventions, with an automated enforcement (CI). - -This way, the template promotes: - -- the use of [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), [semantic versioning](https://semver.org/) and [semantic releasing](https://github.com/cycjimmy/semantic-release-action) which automates the whole package release workflow including: determining the next version number, generating the release notes, and publishing the artifacts (project tarball, docker images, etc.) -- unit testing -- linting via [golangci-lint](https://github.com/golangci/golangci-lint) -- a uniformed way of building the project for several platforms via a Makefile using a docker image - -## How to use - -> 🚨 do not fork this repository as it is a [template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) - -1. Click on [Use this template](https://github.com/okp4/template-go/generate) -2. Give a name to your project -3. Wait until the first run of CI finishes -4. Clone your new project and happy coding! - ## Prerequisites - Be sure you have [Golang](https://go.dev/doc/install) installed. diff --git a/cmd/root.go b/cmd/root.go index d622d89..d7a07f1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,9 +8,9 @@ import ( // rootCmd represents the base command when called without any subcommands. var rootCmd = &cobra.Command{ - Use: "template-go", - Short: "A template fo Golang projects", - Long: "A template fo Golang projects", + Use: "minio-auth-plugin", + Short: "Minio authentication connector to the OKP4 chain.", + Long: "Minio authentication connector to the OKP4 chain.", } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/cmd/version.go b/cmd/version.go index 721180d..aec62f0 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -2,7 +2,7 @@ package cmd import ( "encoding/json" - "okp4/template-go/internal/version" + "okp4/minio-auth-plugin/internal/version" "strings" "github.com/spf13/cobra" diff --git a/go.mod b/go.mod index 82157d9..1f69ee9 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module okp4/template-go +module okp4/minio-auth-plugin go 1.21 diff --git a/internal/version/version_test.go b/internal/version/version_test.go index bbabfec..cb0bf20 100644 --- a/internal/version/version_test.go +++ b/internal/version/version_test.go @@ -18,7 +18,7 @@ func TestNewInfo(t *testing.T) { func TestInfoString(t *testing.T) { Convey("Given an info object", t, func() { info := new(Info) - info.Name = "go-template" + info.Name = "minio-auth-plugin" info.Version = "0.0" info.GitCommit = "13245" info.GoVersion = "go fake version 42" @@ -26,7 +26,7 @@ func TestInfoString(t *testing.T) { Convey("When the object string function is called", func() { result := info.String() Convey("Then the result should be an info string", func() { - expected := `go-template: 0.0 + expected := `minio-auth-plugin: 0.0 git commit: 13245 go fake version 42` diff --git a/main.go b/main.go index 6dbdbd5..bdb8dfb 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -import "okp4/template-go/cmd" +import "okp4/minio-auth-plugin/cmd" func main() { cmd.Execute() From 05b24e6095ba474b444164e54e5bd8319b56cd3d Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:41:09 +0100 Subject: [PATCH 2/3] ci: remove publish PR workflow --- .github/workflows/publish-pr.yml | 49 -------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/publish-pr.yml diff --git a/.github/workflows/publish-pr.yml b/.github/workflows/publish-pr.yml deleted file mode 100644 index 584bf7f..0000000 --- a/.github/workflows/publish-pr.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: PR Publish - -on: - issue_comment: - types: [created, edited] - -jobs: - publish-docker-images: - if: ${{ github.event.issue.pull_request && github.event.comment.body == '/publish' }} - runs-on: ubuntu-22.04 - steps: - - uses: xt0rted/pull-request-comment-branch@v2 - id: comment-branch - - - name: Check out repository - uses: actions/checkout@v3 - with: - ref: ${{ steps.comment-branch.outputs.head_ref }} - - - uses: gacts/github-slug@v1 - id: slug - with: - to-slug: ${{ steps.comment-branch.outputs.head_ref }} - - - name: Extract metadata (tags, labels) for Docker - id: docker_metadata - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ steps.slug.outputs.slug }} - labels: | - org.opencontainers.image.vendor=OKP4 - - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ secrets.DOCKER_REGISTRY_ID }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - - - name: Build and publish image(s) - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64 - push: true - tags: ${{ steps.docker_metadata.outputs.tags }} - labels: ${{ steps.docker_metadata.outputs.labels }} From 937659f090d0478f4b1ea281dce1e7de458eb253 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:41:17 +0100 Subject: [PATCH 3/3] ci(release): rework release workflow --- .github/workflows/release.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1cd518..9006da9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,27 +25,39 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.OKP4_TOKEN }} - - name: Setup Go environment - uses: actions/setup-go@v4.0.1 + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 with: - go-version: "1.21" + gpg_private_key: ${{ secrets.OKP4_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.OKP4_BOT_GPG_PASSPHRASE }} + git_config_global: true + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Release project - uses: cycjimmy/semantic-release-action@v2 + uses: cycjimmy/semantic-release-action@v4 with: - semantic_version: 19.0.2 + semantic_version: 22.0.5 branch: main extra_plugins: | @semantic-release/changelog @semantic-release/exec @semantic-release/git - @google/semantic-release-replace-plugin + semantic-release-replace-plugin@1.2.7 extends: | - conventional-changelog-conventionalcommits + conventional-changelog-conventionalcommits@7.0.1 env: GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }} GIT_AUTHOR_NAME: ${{ secrets.OKP4_BOT_GIT_AUTHOR_NAME }}