Skip to content

Commit 326c6cc

Browse files
authored
174.dockter.1 (#176)
* #174 Refactor to template * #174 Refactor to template * #174 Refactor to template * #174 Prepare for versioned release * #174 Prepare for versioned release
1 parent 309ed8c commit 326c6cc

13 files changed

+122
-119
lines changed

.github/workflows/go-test-darwin.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@ name: go-test-darwin.yaml
66
on: [push]
77

88
env:
9-
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"
109
LD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
1110
DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
11+
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"
1212

1313
jobs:
1414
build:
1515
runs-on: macos-latest
1616
strategy:
1717
matrix:
18-
go: ["1.20"]
18+
go: ["1.20", "1.21"]
1919
name: Go ${{ matrix.go }} - darwin
2020
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v3
23-
with:
24-
fetch-depth: 0
25-
- name: Setup go
26-
uses: actions/setup-go@v4
27-
with:
28-
go-version: ${{ matrix.go }}
2921
- name: Checkout repository
3022
uses: actions/checkout@v3
3123
with:

.github/workflows/go-test-linux.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
go: ["1.20"]
18+
go: ["1.20", "1.21"]
1919
name: Go ${{ matrix.go }} - linux
2020
steps:
2121
- name: Checkout repository

.github/workflows/make-go-github-file.yaml

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ on:
77

88
jobs:
99
make-go-github-file:
10-
name: Update cmd/version.go
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v3
15-
with:
16-
fetch-depth: "0"
17-
- name: Make github.go file
18-
uses: Senzing/github-action-make-go-github-file@main
10+
uses: Senzing/build-resources/.github/workflows/make-go-github-file.yaml@main
11+
secrets:
12+
SENZING_GITHUB_GPG_PRIVATE_KEY: ${{ secrets.SENZING_GITHUB_GPG_PRIVATE_KEY }}
13+
SENZING_GITHUB_GPG_PASSPHRASE: ${{ secrets.SENZING_GITHUB_GPG_PASSPHRASE }}
14+
SENZING_GITHUB_ACTOR: ${{ secrets.SENZING_GITHUB_ACTOR }}

.gitignore

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
14
# Binaries for programs and plugins
25
*.exe
36
*.exe~
@@ -13,5 +16,16 @@
1316

1417
# Dependency directories (remove the comment below to include it)
1518
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
23+
# macOS artifacts
24+
.DS_STORE
25+
26+
# Visual Studio code
27+
.vscode
1628
.history
17-
target/
29+
30+
# Makefile
31+
target/

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
-
1212

13+
## [0.4.14] - 2023-08-17
14+
15+
### Changed in 0.4.14
16+
17+
- In `go.mod` update to `go 1.21`
18+
- In `Dockerfile` update to `golang:1.21.0-bullseye`
19+
- Update dependencies
20+
- github.com/senzing/g2-sdk-go-base v0.2.4
21+
- github.com/senzing/go-cmdhelping v0.1.7
22+
- github.com/senzing/go-common v0.2.13
23+
1324
## [0.4.13] - 2023-08-08
1425

1526
### Changed in 0.4.13

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# -----------------------------------------------------------------------------
44

55
ARG IMAGE_SENZINGAPI_RUNTIME=senzing/senzingapi-runtime:3.6.0
6-
ARG IMAGE_GO_BUILDER=golang:1.20.4
6+
ARG IMAGE_GO_BUILDER=golang:1.21.0-bullseye
77
ARG IMAGE_FINAL=senzing/senzingapi-runtime:3.6.0
88

99
# -----------------------------------------------------------------------------

Makefile

+54-69
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Makefile that builds serve-grpc, a "go" program.
1+
# Makefile for serve-grpc.
22

3-
# Detect the operating system and architecture
3+
# Detect the operating system and architecture.
44

55
include Makefile.osdetect
66

@@ -24,13 +24,13 @@ BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's
2424
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
2525
GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^[email protected]:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')
2626
PATH := $(MAKEFILE_DIRECTORY)/bin:$(PATH)
27-
GO_OSARCH = $(subst /, ,$@)
28-
GO_OS = $(word 1, $(GO_OSARCH))
29-
GO_ARCH = $(word 2, $(GO_OSARCH))
3027

3128
# Recursive assignment ('=')
3229

3330
CC = gcc
31+
GO_OSARCH = $(subst /, ,$@)
32+
GO_OS = $(word 1, $(GO_OSARCH))
33+
GO_ARCH = $(word 2, $(GO_OSARCH))
3434

3535
# Conditional assignment. ('?=')
3636
# Can be overridden with "export"
@@ -43,9 +43,6 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
4343

4444
.EXPORT_ALL_VARIABLES:
4545

46-
-include Makefile.$(OSTYPE)
47-
-include Makefile.$(OSTYPE)_$(OSARCH)
48-
4946
# -----------------------------------------------------------------------------
5047
# The first "make" target runs as default.
5148
# -----------------------------------------------------------------------------
@@ -54,8 +51,14 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
5451
default: help
5552

5653
# -----------------------------------------------------------------------------
57-
# Build
58-
# - The "build" target is implemented in Makefile.OS.ARCH files.
54+
# Operating System / Architecture targets
55+
# -----------------------------------------------------------------------------
56+
57+
-include Makefile.$(OSTYPE)
58+
-include Makefile.$(OSTYPE)_$(OSARCH)
59+
60+
# -----------------------------------------------------------------------------
61+
# Dependency management
5962
# -----------------------------------------------------------------------------
6063

6164
.PHONY: dependencies
@@ -64,6 +67,11 @@ dependencies:
6467
@go get -t -u ./...
6568
@go mod tidy
6669

70+
# -----------------------------------------------------------------------------
71+
# Build
72+
# - The "build" target is implemented in Makefile.OS.ARCH files.
73+
# - docker-build: https://docs.docker.com/engine/reference/commandline/build/
74+
# -----------------------------------------------------------------------------
6775

6876
PLATFORMS := darwin/amd64 linux/amd64 windows/amd64
6977
$(PLATFORMS):
@@ -72,20 +80,6 @@ $(PLATFORMS):
7280
@GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)
7381

7482

75-
.PHONY: build-all $(PLATFORMS)
76-
build-all: $(PLATFORMS)
77-
@mv $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME).exe
78-
79-
# -----------------------------------------------------------------------------
80-
# Test
81-
# - The "test" target is implemented in Makefile.OS.ARCH files.
82-
# -----------------------------------------------------------------------------
83-
84-
# -----------------------------------------------------------------------------
85-
# docker-build
86-
# - https://docs.docker.com/engine/reference/commandline/build/
87-
# -----------------------------------------------------------------------------
88-
8983
.PHONY: docker-build
9084
docker-build:
9185
@docker build \
@@ -98,33 +92,17 @@ docker-build:
9892
--tag $(DOCKER_IMAGE_NAME):$(BUILD_VERSION) \
9993
.
10094

101-
102-
.PHONY: docker-build-package
103-
docker-build-package:
104-
@docker build \
105-
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
106-
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
107-
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
108-
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
109-
--no-cache \
110-
--file package.Dockerfile \
111-
--tag $(DOCKER_BUILD_IMAGE_NAME) \
112-
.
113-
11495
# -----------------------------------------------------------------------------
115-
# Package
116-
# - The "package" target is implemented in Makefile.OS.ARCH files.
96+
# Test
97+
# - The "test" target is implemented in Makefile.OS.ARCH files.
11798
# -----------------------------------------------------------------------------
11899

100+
119101
# -----------------------------------------------------------------------------
120102
# Run
103+
# - The "run" target is implemented in Makefile.OS.ARCH files.
121104
# -----------------------------------------------------------------------------
122105

123-
.PHONY: run
124-
run:
125-
@go run main.go
126-
127-
128106
.PHONY: docker-run
129107
docker-run:
130108
@docker run \
@@ -134,20 +112,25 @@ docker-run:
134112
$(DOCKER_IMAGE_NAME)
135113

136114
# -----------------------------------------------------------------------------
137-
# Utility targets
115+
# Package
116+
# - The "package" target is implemented in Makefile.OS.ARCH files.
138117
# -----------------------------------------------------------------------------
139118

140-
.PHONY: new-sqlite
141-
new-sqlite:
142-
@rm -rf /tmp/sqlite
143-
@mkdir /tmp/sqlite
144-
@cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db
145-
146-
.PHONY: update-pkg-cache
147-
update-pkg-cache:
148-
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
149-
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)
119+
.PHONY: docker-build-package
120+
docker-build-package:
121+
@docker build \
122+
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
123+
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
124+
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
125+
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
126+
--no-cache \
127+
--file package.Dockerfile \
128+
--tag $(DOCKER_BUILD_IMAGE_NAME) \
129+
.
150130

131+
# -----------------------------------------------------------------------------
132+
# Utility targets
133+
# -----------------------------------------------------------------------------
151134

152135
.PHONY: clean
153136
clean:
@@ -159,26 +142,28 @@ clean:
159142
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true
160143

161144

145+
.PHONY: help
146+
help:
147+
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
148+
@echo "Makefile targets:"
149+
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
150+
151+
162152
.PHONY: print-make-variables
163153
print-make-variables:
164154
@$(foreach V,$(sort $(.VARIABLES)), \
165155
$(if $(filter-out environment% default automatic, \
166156
$(origin $V)),$(warning $V=$($V) ($(value $V)))))
167157

168-
# -----------------------------------------------------------------------------
169-
# Help
170-
# -----------------------------------------------------------------------------
171158

172-
.PHONY: help
173-
help:
174-
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
175-
@echo "Makefile targets:"
176-
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
159+
.PHONY: setup
160+
setup:
161+
@rm -rf /tmp/sqlite
162+
@mkdir /tmp/sqlite
163+
@cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db
177164

178-
# -----------------------------------------------------------------------------
179-
# Optionally include platform-specific settings and targets.
180-
# - Note: This is last because the "last one wins" when over-writing targets.
181-
# -----------------------------------------------------------------------------
182165

183-
# -include Makefile.$(OSTYPE)
184-
# -include Makefile.$(OSTYPE)_$(OSARCH)
166+
.PHONY: update-pkg-cache
167+
update-pkg-cache:
168+
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
169+
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)

Makefile.darwin

+4-8
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,14 @@ test:
3737
# Run
3838
# -----------------------------------------------------------------------------
3939

40-
# -----------------------------------------------------------------------------
41-
# Package
42-
# -----------------------------------------------------------------------------
43-
44-
.PHONY: package
45-
package:
46-
@echo "The 'package' target is not implemented for darwin"
40+
.PHONY: run
41+
run:
42+
@go run -exec macos_exec_dyld.sh main.go
4743

4844
# -----------------------------------------------------------------------------
4945
# Makefile targets supported only by this platform.
5046
# -----------------------------------------------------------------------------
5147

5248
.PHONY: only-darwin
5349
only-darwin:
54-
@echo "Only darwin has this Makefile target."
50+
@echo "Only darwin has this Makefile target."

Makefile.linux

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Makefile extensions for linux.
22

3-
# -----------------------------------------------------------------------------
4-
# Variables
5-
# -----------------------------------------------------------------------------
6-
73
# -----------------------------------------------------------------------------
84
# Makefile targets supported by all platforms.
95
# -----------------------------------------------------------------------------
@@ -38,6 +34,11 @@ test:
3834
# Run
3935
# -----------------------------------------------------------------------------
4036

37+
.PHONY: run
38+
run:
39+
@go run main.go
40+
41+
4142
.PHONY: run-serve-grpc
4243
run-serve-grpc: build
4344
@target/linux-amd64/serve-grpc
@@ -46,6 +47,7 @@ run-serve-grpc: build
4647
.PHONY: run-serve-grpc-trace
4748
run-serve-grpc-trace: build
4849
@target/linux-amd64/serve-grpc --log-level TRACE --engine-log-level 1
50+
4951
# -----------------------------------------------------------------------------
5052
# Package
5153
# -----------------------------------------------------------------------------
@@ -63,4 +65,4 @@ package: docker-build-package
6365

6466
.PHONY: only-linux
6567
only-linux:
66-
@echo "Only linux has this Makefile target."
68+
@echo "Only linux has this Makefile target."

Makefile.windows

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ test:
3232
# Run
3333
# -----------------------------------------------------------------------------
3434

35+
.PHONY: run
36+
run:
37+
@go run main.go
38+
3539
# -----------------------------------------------------------------------------
3640
# Package
3741
# -----------------------------------------------------------------------------
3842

39-
.PHONY: package
40-
package:
41-
@echo "The 'package' target is not implemented for windows"
4243

4344
# -----------------------------------------------------------------------------
4445
# Makefile targets supported only by this platform.
4546
# -----------------------------------------------------------------------------
4647

4748
.PHONY: only-windows
4849
only-windows:
49-
@echo "Only windows has this Makefile target."
50+
@echo "Only windows has this Makefile target."

0 commit comments

Comments
 (0)