Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update sonarcloud properties when releasing the project #1615

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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