From 4c4b545e9bb50157cdf464d967c49ab257af0cab Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Wed, 21 Jun 2023 09:52:33 +0200 Subject: [PATCH] append vendor.tgz to each release (#2288) --- .github/workflows/release_publish-package.yml | 4 ++-- .gitignore | 6 ++++-- Makefile | 20 +++++++++++++++---- plugins/notifications/dummy/Makefile | 5 ----- plugins/notifications/email/Makefile | 5 ----- plugins/notifications/http/Makefile | 5 ----- plugins/notifications/slack/Makefile | 5 ----- plugins/notifications/splunk/Makefile | 5 ----- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release_publish-package.yml b/.github/workflows/release_publish-package.yml index 94b2c4c74..668634aae 100644 --- a/.github/workflows/release_publish-package.yml +++ b/.github/workflows/release_publish-package.yml @@ -44,11 +44,11 @@ jobs: ${{ runner.os }}-${{ matrix.go-version }}-go- - name: Build the binaries - run: make release + run: make vendor release - name: Upload to release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | tag_name="${GITHUB_REF##*/}" - hub release edit -a crowdsec-release.tgz -m "" "$tag_name" + hub release edit -a crowdsec-release.tgz -a vendor.tgz -m "" "$tag_name" diff --git a/.gitignore b/.gitignore index 4c5cb0a1f..bf0355f06 100644 --- a/.gitignore +++ b/.gitignore @@ -30,8 +30,10 @@ test/coverage/* *.swp *.swo -# Dependency directories (remove the comment below to include it) -# vendor/ +# Dependencies are not vendored by default, but a tarball is created by "make vendor" +# and provided in the release. Used by freebsd, gentoo, etc. +vendor/ +vendor.tgz # crowdsec binaries cmd/crowdsec-cli/cscli diff --git a/Makefile b/Makefile index d6f1b95f2..6b829b326 100644 --- a/Makefile +++ b/Makefile @@ -137,13 +137,25 @@ localstack: localstack-stop: docker-compose -f test/localstack/docker-compose.yml down +# list of plugins that contain go.mod +PLUGIN_VENDOR = $(foreach plugin,$(PLUGINS),$(shell if [ -f $(PLUGINS_DIR)/$(plugin)/go.mod ]; then echo $(PLUGINS_DIR)/$(plugin); fi)) + .PHONY: vendor vendor: - @echo "Vendoring dependencies" - @$(GOCMD) mod vendor - @$(foreach plugin,$(PLUGINS), \ - $(MAKE) -C $(PLUGINS_DIR)/$(plugin) vendor $(MAKE_FLAGS); \ + $(foreach plugin_dir,$(PLUGIN_VENDOR), \ + cd $(plugin_dir) >/dev/null && \ + $(GOCMD) mod vendor && \ + cd - >/dev/null; \ ) + $(GOCMD) mod vendor + tar -czf vendor.tgz vendor $(foreach plugin_dir,$(PLUGIN_VENDOR),$(plugin_dir)/vendor) + +.PHONY: vendor-remove +vendor-remove: + $(foreach plugin_dir,$(PLUGIN_VENDOR), \ + $(RM) $(plugin_dir)/vendor; \ + ) + $(RM) vendor vendor.tgz .PHONY: package package: diff --git a/plugins/notifications/dummy/Makefile b/plugins/notifications/dummy/Makefile index 612ec6c86..d45d6f198 100644 --- a/plugins/notifications/dummy/Makefile +++ b/plugins/notifications/dummy/Makefile @@ -16,8 +16,3 @@ build: clean .PHONY: clean clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -.PHONY: vendor -vendor: - @echo "vendoring $(PLUGIN) plugin..." - @$(GOCMD) mod vendor diff --git a/plugins/notifications/email/Makefile b/plugins/notifications/email/Makefile index a386625ac..ae548af0a 100644 --- a/plugins/notifications/email/Makefile +++ b/plugins/notifications/email/Makefile @@ -16,8 +16,3 @@ build: clean .PHONY: clean clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -.PHONY: vendor -vendor: - @echo "vendoring $(PLUGIN) plugin..." - @$(GOCMD) mod vendor diff --git a/plugins/notifications/http/Makefile b/plugins/notifications/http/Makefile index 44ee8c58f..56f490772 100644 --- a/plugins/notifications/http/Makefile +++ b/plugins/notifications/http/Makefile @@ -16,8 +16,3 @@ build: clean .PHONY: clean clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -.PHONY: vendor -vendor: - @echo "vendoring $(PLUGIN) plugin..." - @$(GOCMD) mod vendor diff --git a/plugins/notifications/slack/Makefile b/plugins/notifications/slack/Makefile index e950eba92..f43303eb8 100644 --- a/plugins/notifications/slack/Makefile +++ b/plugins/notifications/slack/Makefile @@ -16,8 +16,3 @@ build: clean .PHONY: clean clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -.PHONY: vendor -vendor: - @echo "vendoring $(PLUGIN) plugin..." - @$(GOCMD) mod vendor diff --git a/plugins/notifications/splunk/Makefile b/plugins/notifications/splunk/Makefile index a49c87bd6..a7f04f4d0 100644 --- a/plugins/notifications/splunk/Makefile +++ b/plugins/notifications/splunk/Makefile @@ -16,8 +16,3 @@ build: clean .PHONY: clean clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -.PHONY: vendor -vendor: - @echo "vendoring $(PLUGIN) plugin..." - @$(GOCMD) mod vendor