Skip to content

Commit

Permalink
Require go 1.20 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Mar 7, 2023
1 parent 4f39d84 commit 19cc560
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-binary-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build and upload binary package
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20.1
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.20.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/functional_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20.1
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.20.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20.1
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.20.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get


PREFIX?="/"
PID_DIR = $(PREFIX)"/var/run/"
BINARY_NAME=crowdsec-custom-bouncer
Expand All @@ -28,7 +27,7 @@ all: clean test build
static: clean
$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) -v -a -tags netgo -ldflags '-w -extldflags "-static"'

build: clean
build: goversion clean
$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) -v

test:
Expand Down Expand Up @@ -59,3 +58,5 @@ release: build
func-tests: build
pipenv install --dev
pipenv run pytest -v

include mk/goversion.mk
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/crowdsecurity/cs-custom-bouncer

go 1.19
go 1.20

require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
Expand Down
23 changes: 23 additions & 0 deletions mk/goversion.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

BUILD_REQUIRE_GO_MAJOR ?= 1
BUILD_REQUIRE_GO_MINOR ?= 20

BUILD_GOVERSION = $(subst go,,$(shell go env GOVERSION))

go_major_minor = $(subst ., ,$(BUILD_GOVERSION))
GO_MAJOR_VERSION = $(word 1, $(go_major_minor))
GO_MINOR_VERSION = $(word 2, $(go_major_minor))

GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR)

.PHONY: goversion
goversion:
@if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
exit 0; \
elif [ $(GO_MAJOR_VERSION) -lt $(BUILD_REQUIRE_GO_MAJOR) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(BUILD_REQUIRE_GO_MINOR) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi
8 changes: 4 additions & 4 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Additional labels for pre-release and build metadata are available as extensions
*/

var (
Version string // = "v0.0.0"
BuildDate string // = "I don't remember exactly"
Tag string // = "dev"
GoVersion = runtime.Version() // = "1.13"
Version string // = "v0.0.0"
BuildDate string // = "2023-03-06_09:55:34"
Tag string // = "dev"
GoVersion = runtime.Version()[2:] // = "1.20"
)

func ShowStr() string {
Expand Down

0 comments on commit 19cc560

Please sign in to comment.