diff --git a/.gitlab/scripts/check-semantic-version.sh b/.gitlab/scripts/check-semantic-version.sh index 5cfd5019b58d1607163610a43d7cd0919ccd9832..539dac85777eda838685fd05e3e2d2674c3637e3 100755 --- a/.gitlab/scripts/check-semantic-version.sh +++ b/.gitlab/scripts/check-semantic-version.sh @@ -4,3 +4,10 @@ SEMANTIC_VERSION_REGEX='^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' cat - | grep -qE "$SEMANTIC_VERSION_REGEX" + +exit_code=$? +if [ $exit_code -ne 0 ]; then + echo "The given version doesn't match the semantic versioning format." +fi + +exit $exit_code diff --git a/Makefile b/Makefile index 9fa6cf45a698fade39d550a6acddd4a2de20447d..259b129416d9ff96d64776f88caf004abb8cf773 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,12 @@ backports: .PHONY: release release: - @echo -n $(VERSION) | ./.gitlab/scripts/check-semantic-version.sh - @[ "main" = "$(shell git rev-parse --abbrev-ref HEAD)" ] || echo "Please checkout the main branch first: git checkout main" + echo "Starting release process for $(VERSION) ..." + @echo "$(VERSION)" | ./.gitlab/scripts/check-semantic-version.sh + @[ "main" = "$(shell git rev-parse --abbrev-ref HEAD)" ] || (echo "Please checkout the main branch first: git checkout main" && false) + @[ -n "$(GITLAB_TOKEN)" ] || (echo "Please set the GITLAB_TOKEN environment variable" && false) @echo "Creating changelog ..." - @curl --method POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" 'https://gitlab.com/api/v4/projects/components%2Fopentofu/repository/changelog' --data "version=$(VERSION)&message='Add changelog for $(VERSION) [skip ci]'" + @curl --fail-with-body --request POST --header "PRIVATE-TOKEN: $(GITLAB_TOKEN)" 'https://gitlab.com/api/v4/projects/components%2Fopentofu/repository/changelog' --data "version=$(VERSION)&message='Add changelog for $(VERSION) [skip ci]'" @echo "Pulling changelog ..." @git pull @echo "Tagging $(VERSION) ..."