Skip to content

Commit 5943de6

Browse files
committed
Update s9pk.mk
1 parent b21a43e commit 5943de6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

s9pk.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ install: | check-deps check-init
7777
printf "\n🚀 Installing %s to %s ...\n" "$$S9PK" "$$HOST"; \
7878
start-cli package install -s "$$S9PK"
7979

80+
publish: | all
81+
@REGISTRY=$$(awk -F'/' '/^registry:/ {print $$3}' ~/.startos/config.yaml); \
82+
if [ -z "$$REGISTRY" ]; then \
83+
echo "Error: You must define \"registry: https://my-registry.tld\" in ~/.startos/config.yaml"; \
84+
exit 1; \
85+
fi; \
86+
S3BASE=$$(awk -F'/' '/^s9pk-s3base:/ {print $$3}' ~/.startos/config.yaml); \
87+
if [ -z "$$S3BASE" ]; then \
88+
echo "Error: You must define \"s3base: https://s9pks.my-s3-bucket.tld\" in ~/.startos/config.yaml"; \
89+
exit 1; \
90+
fi; \
91+
command -v s3cmd >/dev/null || \
92+
(echo "Error: s3cmd not found. It must be installed to publish using s3." && exit 1); \
93+
printf "\n🚀 Publishing to %s; indexing on %s ...\n" "$$S3BASE" "$$REGISTRY"; \
94+
for s9pk in *.s9pk; do \
95+
age=$$(( $$(date +%s) - $$(stat -c %Y "$$s9pk") )); \
96+
if [ "$$age" -gt 3600 ]; then \
97+
printf "\033[1;33m⚠️ %s is %d minutes old. Publish anyway? [y/N] \033[0m" "$$s9pk" "$$((age / 60))"; \
98+
read -r ans; \
99+
case "$$ans" in [yY]*) ;; *) echo "Skipping $$s9pk"; continue ;; esac; \
100+
fi; \
101+
start-cli s9pk publish "$$s9pk"; \
102+
done
103+
80104
check-deps:
81105
@command -v start-cli >/dev/null || \
82106
(echo "Error: start-cli not found. Please see https://docs.start9.com/latest/developer-guide/sdk/installing-the-sdk" && exit 1)

0 commit comments

Comments
 (0)