ソースを参照

append vendor.tgz to each release (#2288)

mmetc 2 年 前
コミット
4c4b545e9b

+ 2 - 2
.github/workflows/release_publish-package.yml

@@ -44,11 +44,11 @@ jobs:
             ${{ runner.os }}-${{ matrix.go-version }}-go-
             ${{ runner.os }}-${{ matrix.go-version }}-go-
 
 
       - name: Build the binaries
       - name: Build the binaries
-        run: make release
+        run: make vendor release
 
 
       - name: Upload to release
       - name: Upload to release
         env:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
         run: |
           tag_name="${GITHUB_REF##*/}"
           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"

+ 4 - 2
.gitignore

@@ -30,8 +30,10 @@ test/coverage/*
 *.swp
 *.swp
 *.swo
 *.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
 # crowdsec binaries
 cmd/crowdsec-cli/cscli
 cmd/crowdsec-cli/cscli

+ 16 - 4
Makefile

@@ -137,13 +137,25 @@ localstack:
 localstack-stop:
 localstack-stop:
 	docker-compose -f test/localstack/docker-compose.yml down
 	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
 .PHONY: vendor
 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
 .PHONY: package
 package:
 package:

+ 0 - 5
plugins/notifications/dummy/Makefile

@@ -16,8 +16,3 @@ build: clean
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
-
-.PHONY: vendor
-vendor:
-	@echo "vendoring $(PLUGIN) plugin..."
-	@$(GOCMD) mod vendor

+ 0 - 5
plugins/notifications/email/Makefile

@@ -16,8 +16,3 @@ build: clean
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
-
-.PHONY: vendor
-vendor:
-	@echo "vendoring $(PLUGIN) plugin..."
-	@$(GOCMD) mod vendor

+ 0 - 5
plugins/notifications/http/Makefile

@@ -16,8 +16,3 @@ build: clean
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
-
-.PHONY: vendor
-vendor:
-	@echo "vendoring $(PLUGIN) plugin..."
-	@$(GOCMD) mod vendor

+ 0 - 5
plugins/notifications/slack/Makefile

@@ -16,8 +16,3 @@ build: clean
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
-
-.PHONY: vendor
-vendor:
-	@echo "vendoring $(PLUGIN) plugin..."
-	@$(GOCMD) mod vendor

+ 0 - 5
plugins/notifications/splunk/Makefile

@@ -16,8 +16,3 @@ build: clean
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
 	@$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR)
-
-.PHONY: vendor
-vendor:
-	@echo "vendoring $(PLUGIN) plugin..."
-	@$(GOCMD) mod vendor