Skip to content

Commit

Permalink
Merge pull request #4 from okp4/chore/configure
Browse files Browse the repository at this point in the history
Chore/configure
  • Loading branch information
amimart authored Mar 12, 2024
2 parents cae1c9c + 937659f commit 3d55aa3
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 107 deletions.
49 changes: 0 additions & 49 deletions .github/workflows/publish-pr.yml

This file was deleted.

28 changes: 20 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
- 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 }}
Expand Down
18 changes: 9 additions & 9 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
34 changes: 7 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module okp4/template-go
module okp4/minio-auth-plugin

go 1.21

Expand Down
4 changes: 2 additions & 2 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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"

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`

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "okp4/template-go/cmd"
import "okp4/minio-auth-plugin/cmd"

func main() {
cmd.Execute()
Expand Down

0 comments on commit 3d55aa3

Please sign in to comment.