diff --git a/.env b/.env deleted file mode 100644 index d61757b..0000000 --- a/.env +++ /dev/null @@ -1,22 +0,0 @@ -# Environment variables for the build process - -PROJECTNAME=go-collections - -MODULE=github.com/cloud-native-toolkit/go-collections - -# Go related variables. -GOBASE=$(shell pwd) -GOPATH=$(GOBASE)/vendor:$(GOBASE) # You can remove or change the path after last colon. -GOBIN=$(GOBASE)/bin -GOFILES=$(wildcard *.go) -GOTESTS=$(shell find . -name "*_test.go" | grep -v vendor | xargs -I{} dirname {} | sed -E "s~[.]~${MODULE}~g") -VERSION=v0.0.0 - -# Redirect error output to a file, so we can show it in development mode. -STDERR=/tmp/.$(PROJECTNAME)-stderr.txt - -# PID file will store the server process id when it's running on development mode -PID=/tmp/.$(PROJECTNAME)-api-server.pid - -# Make is verbose in Linux. Make it silent. -MAKEFLAGS += --silent diff --git a/.github/release-drafter.yaml b/.github/release-drafter.yaml new file mode 100644 index 0000000..b0cf9d2 --- /dev/null +++ b/.github/release-drafter.yaml @@ -0,0 +1,28 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +categories: + - title: 'Features' + labels: + - 'feature' + - 'enhancement' + - title: 'Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: 'Maintenance' + label: 'chore' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + $CHANGES diff --git a/.github/workflows/library-build.yaml b/.github/workflows/library-build.yaml new file mode 100644 index 0000000..0358e41 --- /dev/null +++ b/.github/workflows/library-build.yaml @@ -0,0 +1,28 @@ +name: Library build + +# Controls when the workflow will run +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '^1.24.5' # The Go version to download (if necessary) and use. + + - name: Build code + run: | + make build + + - name: Test code + run: | + make test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..fcae374 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,61 @@ +name: Release module + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch +on: + push: + branches: + - main + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + release: + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: actions/checkout@v4 + + # Drafts your next Release notes as Pull Requests are merged into "main" + - name: Create release + id: create-release + uses: release-drafter/release-drafter@v6 + with: + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + config-name: release-drafter.yaml + publish: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '^1.24.5' # The Go version to download (if necessary) and use. + + - name: Update version + run: | + TAG_NAME=$(echo "${{ steps.create-release.outputs.tag_name }}" | sed "s/v//g") + cat Makefile | sed "s/^VERSION .*/VERSION ?= ${TAG_NAME}/g" > /tmp/Makefile + diff Makefile /tmp/Makefile && echo "" || echo "" + cp /tmp/Makefile Makefile + + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + git add -u + + git commit -m "Update version to ${TAG_NAME} Makefile" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish release + id: publish-release + uses: eregon/publish-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} + with: + release_id: ${{ steps.create-release.outputs.id }} diff --git a/Makefile b/Makefile index 57fef47..0fd63b0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,26 @@ -include .env +# Environment variables for the build process + +PROJECTNAME=go-collections + +MODULE=github.com/cloud-native-toolkit/go-collections + +# Go related variables. +GOBASE=$(shell pwd) +GOPATH=$(GOBASE)/vendor:$(GOBASE) # You can remove or change the path after last colon. +GOBIN=$(GOBASE)/bin +GOFILES=$(wildcard *.go) +GOTESTS=$(shell find . -name "*_test.go" | grep -v vendor | xargs -I{} dirname {} | sed -E "s~[.]~${MODULE}~g") +VERSION ?= v0.0.0 + +# Redirect error output to a file, so we can show it in development mode. +STDERR=/tmp/.$(PROJECTNAME)-stderr.txt + +# PID file will store the server process id when it's running on development mode +PID=/tmp/.$(PROJECTNAME)-api-server.pid + +# Make is verbose in Linux. Make it silent. +MAKEFLAGS += --silent + go-compile: go-clean go-get go-build diff --git a/go.mod b/go.mod index 5b1cedb..a60b316 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/cloud-native-toolkit/go-collections -go 1.23.0 - -toolchain go1.24.4 +go 1.24.5 require ( github.com/onsi/ginkgo/v2 v2.23.4