From 29e703eb5ebe6f23d4477ff2bd507c920bcda544 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 15 Dec 2024 15:00:52 +0100 Subject: [PATCH] feat: version rust --- sonar.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sonar.sh b/sonar.sh index 1c2949e..a893748 100755 --- a/sonar.sh +++ b/sonar.sh @@ -16,15 +16,17 @@ if [[ -n "${CI_COMMIT_PULL_REQUEST}" ]]; then sonarOpts=(-Dsonar.pullrequest.key="${CI_COMMIT_PULL_REQUEST}" -Dsonar.pullrequest.branch="${CI_COMMIT_SOURCE_BRANCH}" -Dsonar.pullrequest.base="${CI_COMMIT_TARGET_BRANCH}") fi +version= + if [[ -f "package.json" ]]; then - version=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json) - sonarOpts+=(-Dsonar.projectVersion="${version}") + version=$(awk -F'"' '/"version": ".+"/ { print $4; exit; }' package.json) +elif [[ -f "Cargo.toml" ]]; then + version=$(awk -F'"' '/^version =/ { print $2; exit; }' Cargo.toml) +elif [[ -d "gradle" ]]; then + version=$(./gradlew --gradle-user-home /tmp/.gradle --project-cache-dir /tmp/.cachegradle properties -PbuildDir=/tmp/.buildgradle -q | awk '/^version:/ {print $2}') fi -if [[ -d "gradle" ]]; then - version=$(./gradlew --gradle-user-home /tmp/.gradle --project-cache-dir /tmp/.cachegradle properties -PbuildDir=/tmp/.buildgradle -q | awk '/^version:/ {print $2}') - sonarOpts+=(-Dsonar.projectVersion="${version}") -fi +sonarOpts+=(-Dsonar.projectVersion="${version}") set -x sonar-scanner -Dsonar.working.directory=/tmp/.scannerwork -Dsonar.qualitygate.wait=true "${sonarOpts[@]}" || true