Skip to content
Makefile 3.05 KiB
Newer Older
Timo Furrer's avatar
Timo Furrer committed
docs:
	csplit -sf readme -n 1 .gitlab/README.md '/<INPUTS>/'
Timo Furrer's avatar
Timo Furrer committed
	echo '<!-- This document is generated by `make docs` from `.gitlab/README.md` -->' > README.md
	echo >> README.md
Timo Furrer's avatar
Timo Furrer committed
	cat readme0 >> README.md
Timo Furrer's avatar
Timo Furrer committed
	yq '.spec.inputs | .[] | "| `" + key + "` | `" + .default + "` | " + .description + (.options | (" Must be one of " + (. | map("`" + . + "`") | join(", ") + "." )) // "") + " |"' templates/full-pipeline.yml >> README.md
	echo >> README.md
	echo '### Available OpenTofu Versions' >> README.md
	echo >> README.md
	echo 'The following OpenTofu versions are available with this component via the `opentofu_version` input:' >> README.md
	echo >> README.md
	yq -r '.spec.inputs.opentofu_version.options | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' templates/full-pipeline.yml >> README.md
Timo Furrer's avatar
Timo Furrer committed
	tail -n+2 readme1 >> README.md
	rm -f readme0 readme1 readme_inputs.md

BACKPORTS_DIR := backports
BACKPORTS_BASE_FILE := $(BACKPORTS_DIR)/Base.gitlab-ci.yml

.PHONY: backports

backports:
	@mkdir -p $(BACKPORTS_DIR)
	@echo 'variables:' > $(BACKPORTS_BASE_FILE)
	@echo '  # OpenTofu CI/CD component version, see https://gitlab.com/components/opentofu/-/releases' >> $(BACKPORTS_BASE_FILE)
	@echo '  VERSION: "0.1.0-alpha4"' >> $(BACKPORTS_BASE_FILE)
	@echo '  # Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases' >> $(BACKPORTS_BASE_FILE)
	@echo '  OPENTOFU_VERSION: "1.6.0"' >> $(BACKPORTS_BASE_FILE)
	@echo '  TF_ROOT: $${CI_PROJECT_DIR}  # The relative path to the root directory of the OpenTofu project' >> $(BACKPORTS_BASE_FILE)
	@echo '  TF_STATE_NAME: default  # The name of the state file used by the GitLab Managed Terraform state backend'>> $(BACKPORTS_BASE_FILE)
	@sed '1,/^---$$/d' templates/full-pipeline.yml >> $(BACKPORTS_BASE_FILE)
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_validate \]\]/validate/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_build \]\]/build/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_deploy \]\]/deploy/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.stage_cleanup \]\]/cleanup/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's#$$\[\[ inputs.gitlab_opentofu_image \]\]#registry.gitlab.com/components/opentofu/gitlab-opentofu:$$VERSION-opentofu$$OPENTOFU_VERSION#'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.root_dir \]\]/$$TF_ROOT/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.state_name \]\]/$$TF_STATE_NAME/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.auto_apply \]\]/$$TF_AUTO_APPLY/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.auto_destroy \]\]/$$TF_AUTO_DESTROY/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/\.default/.opentofu:default/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^fmt:$$/.opentofu:fmt:/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^validate:$$/.opentofu:validate:/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^plan:$$/.opentofu:plan:/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^apply:$$/.opentofu:apply:/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/destroy:/.opentofu:destroy:/'
	@sed -i $(BACKPORTS_BASE_FILE) -e 's/\[destroy\]/[.opentofu:destroy]/'