Skip to content

Commit 2839cfd

Browse files
committed
Enhance Makefile and templates to support major versioning for Go modules
1 parent e43c79b commit 2839cfd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ standalone: validate_plugin validate_version prebuild.go
2828
cd work && \
2929
go run generate/generator.go templates . $(plugin) $(plugin_version) $(plugin_github_url) && \
3030
if [ ! -z "$(plugin_version)" ]; then \
31-
echo "go get $(plugin_github_url)@$(plugin_version)" && \
32-
go get $(plugin_github_url)@$(plugin_version); \
31+
MAJOR_VERSION=$$(echo $(plugin_version) | grep -o '^v[0-9]\+' || echo "v1") && \
32+
if [ "$$MAJOR_VERSION" = "v1" ] || [ "$$MAJOR_VERSION" = "v0" ]; then \
33+
echo "go get $(plugin_github_url)@$(plugin_version)" && \
34+
go get $(plugin_github_url)@$(plugin_version); \
35+
else \
36+
echo "go get $(plugin_github_url)/$$MAJOR_VERSION@$(plugin_version)" && \
37+
go get $(plugin_github_url)/$$MAJOR_VERSION@$(plugin_version); \
38+
fi; \
3339
fi && \
3440
go mod tidy && \
3541
$(MAKE) -C ./fdw clean && \
@@ -61,8 +67,14 @@ render: validate_plugin validate_version prebuild.go
6167
cd work && \
6268
go run generate/generator.go templates . $(plugin) $(plugin_version) $(plugin_github_url) && \
6369
if [ ! -z "$(plugin_version)" ]; then \
64-
echo "go get $(plugin_github_url)@$(plugin_version)" && \
65-
go get $(plugin_github_url)@$(plugin_version); \
70+
MAJOR_VERSION=$$(echo $(plugin_version) | grep -o '^v[0-9]\+' || echo "v1") && \
71+
if [ "$$MAJOR_VERSION" = "v1" ] || [ "$$MAJOR_VERSION" = "v0" ]; then \
72+
echo "go get $(plugin_github_url)@$(plugin_version)" && \
73+
go get $(plugin_github_url)@$(plugin_version); \
74+
else \
75+
echo "go get $(plugin_github_url)/$$MAJOR_VERSION@$(plugin_version)" && \
76+
go get $(plugin_github_url)/$$MAJOR_VERSION@$(plugin_version); \
77+
fi; \
6678
fi && \
6779
go mod tidy
6880

templates/hub/hub_local_plugin.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package hub
22

33
import (
4-
{{.Plugin}} "{{.PluginGithubUrl}}/{{.Plugin}}"
4+
{{.Plugin}} "{{.PluginGithubUrl}}{{if .PluginVersion}}{{if not (or (eq (slice .PluginVersion 0 2) "v1") (eq (slice .PluginVersion 0 2) "v0"))}}/{{slice .PluginVersion 0 2}}{{end}}{{end}}/{{.Plugin}}"
55
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
66
)
77

0 commit comments

Comments
 (0)