Skip to content

Commit

Permalink
chore: update sonarcloud properties when releasing the project (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya authored Sep 13, 2023
1 parent eb91328 commit 2ac1530
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scripts/pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ readonly DRY_RUN="${DRY_RUN:-true}"
readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly MKDOCS_FILE="${ROOT_DIR}/mkdocs.yml"
readonly SONARCLOUD_FILE="${ROOT_DIR}/sonar-project.properties"
readonly VERSION_FILE="${ROOT_DIR}/internal/version.go"

readonly REPOSITORY="github.com/testcontainers/testcontainers-go"
Expand All @@ -27,11 +28,12 @@ function main() {
bumpVersion "${version}"
}

# This function is used to bump the version in the version.go file and in the mkdocs.yml file.
# This function is used to bump the version in those files that refer to the project version.
function bumpVersion() {
local versionToBumpWithoutV="${1}"
local versionToBump="v${versionToBumpWithoutV}"

# Bump version in the mkdocs descriptor file
if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/latest_version: .*/latest_version: ${versionToBump}/g\" ${MKDOCS_FILE} > ${MKDOCS_FILE}.tmp"
echo "mv ${MKDOCS_FILE}.tmp ${MKDOCS_FILE}"
Expand All @@ -40,6 +42,16 @@ function bumpVersion() {
mv ${MKDOCS_FILE}.tmp ${MKDOCS_FILE}
fi

# Bump version in the sonarcloud properties file
if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/sonar\.projectVersion=.*/sonar\.projectVersion=${versionToBump}/g\" ${SONARCLOUD_FILE} > ${SONARCLOUD_FILE}.tmp"
echo "mv ${SONARCLOUD_FILE}.tmp ${SONARCLOUD_FILE}"
else
sed "s/sonar\.projectVersion=.*/sonar\.projectVersion=${versionToBump}/g" ${SONARCLOUD_FILE} > ${SONARCLOUD_FILE}.tmp
mv ${SONARCLOUD_FILE}.tmp ${SONARCLOUD_FILE}
fi

# Bump version across all modules, in their go.mod files
for directory in "${DIRECTORIES[@]}"
do
cd "${ROOT_DIR}/${directory}"
Expand All @@ -65,6 +77,7 @@ function bumpVersion() {
NON_RELEASED_STRING='Not available until the next release of testcontainers-go <a href=\"https:\/\/github.com\/testcontainers\/testcontainers-go\"><span class=\"tc-version\">:material-tag: main<\/span><\/a>'
RELEASED_STRING="Since testcontainers-go <a href=\\\"https:\/\/github.com\/testcontainers\/testcontainers-go\/releases\/tag\/v${versionEscapingDots}\\\"><span class=\\\"tc-version\\\">:material-tag: v${versionEscapingDots}<\/span><\/a>"

# Update the since-version in those modules that were added in the current version
ls | grep -v "index.md" | while read -r module_file; do
if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/${NON_RELEASED_STRING}/${RELEASED_STRING}/g\" ${module_file} > ${module_file}.tmp"
Expand Down

0 comments on commit 2ac1530

Please sign in to comment.