tasks: - checkout: force-clean-build: 'true' - script: | #!/bin/bash set -ex docker run --rm --user 555:555 -v ${bamboo.hostvolume}:/code -w /code \ ${bamboo.container_semrel} \ npx semantic-release \ --dry-run --repository-url https://${bamboo.httpsaccesskey_secret}@devstash.vanderlande.com/scm/ittp/as-vi-cnv.git \ --verifyRelease @semantic-release/exec \ --verifyReleaseCmd 'echo "${nextRelease.version}" > .version' # Function to determine the version tag get_version_tag() { if [ -f .version ]; then echo "$(cat .version)" else echo "$(git describe --abbrev=0 --tags | awk '{gsub("^v", ""); print}')" fi } # Function to determine the commit hash get_commit_hash() { echo "$(git log -1 --pretty=format:%h)" } # Get version tag and commit hash version_tag=$(get_version_tag) commit_hash=$(get_commit_hash) override=$(git log -1 --pretty=format:%s | grep -oP '\[docs-override v\K[^\]]+') || true # Determine gtag and template_suffix based on branch if [[ "${bamboo_planRepository_branch}" == "main" || "${bamboo_planRepository_branch}" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then template_suffix="${version_tag}" elif [[ "${bamboo_planRepository_branch}" == docs-* && -n $override ]]; then version_tag="${override}" template_suffix="${override}" else template_suffix="${version_tag}-${commit_hash}" fi # Write to pipeline.parameters echo -e "\ngtag=${version_tag}" >> pipeline.parameters echo -e "\ntemplate_suffix=${template_suffix}" >> pipeline.parameters - inject-variables: file: pipeline.parameters scope: RESULT other: clean-working-dir: true requirements: - system.docker.executable - AGENT_TYPE: Linux_Base_Agent