summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
1 files changed, 9 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index f7987a8..f346841 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,9 @@ BUILD_DIR ?= build
TAG ?= $(shell date +%Y%m%d)
JSON_TARBALL := $(BUILD_DIR)/release-$(TAG)-json.tar.gz
PHP_TARBALL := $(BUILD_DIR)/release-$(TAG)-php.tar.gz
+R2_BUCKET ?=
-.PHONY: build build-php update clean
+.PHONY: build build-php update release clean
build: build-json build-php
@@ -31,5 +32,12 @@ $(BUILD_DIR)/.metadata.zh.updated:
LANGUAGE=ZH_CN BUILD_DIR="$(BUILD_DIR)/json" ./scripts/update-metadata.sh
touch "$@"
+release:
+ifndef R2_BUCKET
+ $(error R2_BUCKET is missing. Please set it to your Cloudflare R2 bucket name.)
+endif
+ find "$(BUILD_DIR)" -type f \( -name "release-$(TAG)-*.tar.gz" -o -name "release-$(TAG)-*.tar.gz.sha256" \) \
+ \( -exec sh -c 'f="$$1"; name=$$(basename "$$f"); npx wrangler r2 object put "$(R2_BUCKET)/releases/$$name" --remote --file "$$f"' sh {} \; -o -quit \)
+
clean:
rm -rf "$(BUILD_DIR)/"