default: help
help:
	@echo "Please use \`make <target>' where <target> is one of:"
	@echo "  help             to show this message"
	@echo "  test             to run unit tests"
	@echo "  docs             to build the collection documentation"
	@echo "  clean            to remove temporary build files"

test:
	molecule test --all

build:
	ansible-galaxy collection build --force .

install: build
	ansible-galaxy collection install --force *.tar.gz

release:
ifeq ($(VERSION),)
    $(error Need a value for VERSION, e.g., make release VERSION=1.2.3 SUMMARY="Some summary.")
endif
ifeq ($(SUMMARY),)
    $(error Need a value for SUMMARY, e.g., make release VERSION=1.2.3 SUMMARY="Some summary.")
endif
	git checkout main
	git pull
	git checkout -b release-$(VERSION)
	mkdir -p changelogs/fragments
	echo "release_summary: $(SUMMARY)" > changelogs/fragments/release_summary.yml
	echo "$(VERSION)" > VERSION
	yq -yi '.version = "$(VERSION)"' galaxy.yml
	antsibull-changelog release
	git add .
	git commit -m "Release $(VERSION)"
	git push origin release-$(VERSION)
clean:
	rm -rf *.tar.gz

.PHONY: help test release clean build install
