Open jmalloc opened 2 years ago
@jmalloc @ezzatron
The following makes the client self updating:
CORE_VERSION_FILE := $(MF_PROJECT_ROOT)/artifacts/core-version.txt
REMOTE_CORE_VERSION := $(shell curl -Is https://makefiles.dev/v1 | grep etag | cut -d ':' -f2 | xargs)
LOCAL_CORE_VERSION := $(shell cat "${CORE_VERSION_FILE}" 2>/dev/null)
UPDATE_FILE := artifacts/update.touch
# precommit --- Perform tasks that need to be executed before committing.
.PHONY: precommit
precommit:: update
# update --- Checks for updates and applies if required.
.PHONY: update
update: update-core $(UPDATE_FILE)
# update-core --- Checks if core needs updating.
.PHONY: update-core
update-core:
ifneq ($(REMOTE_CORE_VERSION),$(LOCAL_CORE_VERSION))
@echo "Remote core version: '$(REMOTE_CORE_VERSION)'"
@echo "Local core version: '$(LOCAL_CORE_VERSION)'"
@echo "Core update required"
@rm -f $(UPDATE_FILE)
endif
$(UPDATE_FILE):
@rm -rf $(MF_ROOT) artifacts
@mkdir -p "$(@D)"
@echo "$(REMOTE_CORE_VERSION)" > $(CORE_VERSION_FILE)
@touch "$@"
As it stands there's no notification that the cached makefiles in a project are out of date.
I don't think it's worth making this too fancy, just do a
HEAD
of the download URL and compare the ETag, something like that.Perhaps on
make precommit
would be best?