Skip to content
Snippets Groups Projects
Unverified Commit b56a10d9 authored by Timo Furrer's avatar Timo Furrer
Browse files

Outsource release tooling into script

parent 241db5fd
Branches
Tags
No related merge requests found
#!/usr/bin/env bash
set -o errexit
set -o errtrace
if [ -z "$1" ]; then
echo "Error: please provide a version for this release as the first argument." >&2
exit 1
fi
if [ -z "${GITLAB_TOKEN}" ]; then
echo "Error: please set the GITLAB_TOKEN environment variable." >&2
exit 1
fi
if [ "main" = "$(shell git rev-parse --abbrev-ref HEAD)" ]; then
echo "Error: please checkout the main branch first: git checkout main." >&2
exit 1
fi
script_dir=$(dirname "$0")
version="$1"
echo "Verifying release version '${version}' ..."
echo "${version}" | "${script_dir}/check-semantic-version.sh"
echo "Starting release process for ${version} ..."
echo "Determing last stable version ..."
last_stable_version_sha="$(git describe --tags --match '*.*.*' | xargs git rev-list -n1)"
echo "Using commit '${last_stable_version_sha}' to start the changelog from ..."
echo "Creating changelog ..."
curl \
--fail-with-body \
--request POST \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
--header 'Content-Type: application/json' \
'https://gitlab.com/api/v4/projects/components%2Fopentofu/repository/changelog' \
--data "
{
\"version\": \"${version}\",
\"from\": \"${last_stable_version_sha}\",
\"message\": \"Add changelog for ${version}\"
}"
echo "Pulling changelog ..."
git pull
echo "Tagging ${version} ..."
git tag "${version}"
echo "Pushing tag ${version} ..."
git push origin "${version}"
echo "Created tag ${version}, pipeline triggered, release will be available soon!"
RELEASE_SCRIPT = ./.gitlab/scripts/release.sh
.PHONY: all
all: docs
.PHONY: docs
......@@ -17,17 +20,4 @@ docs:
.PHONY: release
release:
@[ -n "$(VERSION)" ] || (echo "Please provide a VERSION argument for this release" && false)
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 --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)"
@echo "Pulling changelog ..."
@git pull
@echo "Tagging $(VERSION) ..."
@git tag $(VERSION)
@echo "Pushing tag $(VERSION) ..."
@git push origin $(VERSION)
@echo "Created tag $(VERSION), pipeline triggered, release will be available soon!"
$(RELEASE_SCRIPT) $(VERSION)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment