Skip to content

Commit

Permalink
[chore] correctly escape . characters during release preparation (ope…
Browse files Browse the repository at this point in the history
…n-telemetry#10631)

#### Description
This PR fixes an issue where the `.` character in a version string (e.g.
`1.2.3`) was interpreted by `sed` as any character and therefore needed
to be properly escaped. This happened during the prepare-release
workflow.
The version string for the current stable and current beta version
strings provided at pipeline start is replaced as follows:
```
1.2.3 -> 1[.]2[.]3
```

This ensures that `sed` searches for the literal `.` character instead
of interpreting it as a wildcard character.
I specifically used the `[]` syntax to avoid the hassle of "how many
backslashes do i need until it's properly escaped?". (and that for bash
and sed, which work different on different OSes anyways which makes it
hard to test as well)


#### Link to tracking issue
Fixes open-telemetry#9748

Signed-off-by: Moritz Wiesinger <[email protected]>
  • Loading branch information
mowies authored Jul 22, 2024
1 parent 0e14c22 commit a211cc8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/scripts/release-prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ if [ "${CANDIDATE_STABLE}" == "" ] && [ "${CANDIDATE_BETA}" == "" ]; then
exit 1
fi

# Expand CURRENT_STABLE and CURRENT_BETA to escape . character by using [.]
CURRENT_STABLE_ESCAPED=${CURRENT_STABLE//./[.]}
CURRENT_BETA_ESCAPED=${CURRENT_BETA//./[.]}

RELEASE_VERSION=v${CANDIDATE_STABLE}/v${CANDIDATE_BETA}
if [ "${CANDIDATE_STABLE}" == "" ]; then
RELEASE_VERSION="v${CANDIDATE_BETA}"
Expand All @@ -26,14 +30,14 @@ git add --all
git commit -m "Changelog update ${RELEASE_VERSION}"

if [ "${CANDIDATE_STABLE}" != "" ]; then
make prepare-release PREVIOUS_VERSION="${CURRENT_STABLE}" RELEASE_CANDIDATE="${CANDIDATE_STABLE}" MODSET=stable
make prepare-release PREVIOUS_VERSION="${CURRENT_STABLE_ESCAPED}" RELEASE_CANDIDATE="${CANDIDATE_STABLE}" MODSET=stable
COMMANDS+="
- make prepare-release PREVIOUS_VERSION=${CURRENT_STABLE} RELEASE_CANDIDATE=${CANDIDATE_STABLE} MODSET=stable"
- make prepare-release PREVIOUS_VERSION=${CURRENT_STABLE_ESCAPED} RELEASE_CANDIDATE=${CANDIDATE_STABLE} MODSET=stable"
fi
if [ "${CANDIDATE_BETA}" != "" ]; then
make prepare-release PREVIOUS_VERSION="${CURRENT_BETA}" RELEASE_CANDIDATE="${CANDIDATE_BETA}" MODSET=beta
make prepare-release PREVIOUS_VERSION="${CURRENT_BETA_ESCAPED}" RELEASE_CANDIDATE="${CANDIDATE_BETA}" MODSET=beta
COMMANDS+="
- make prepare-release PREVIOUS_VERSION=${CURRENT_BETA} RELEASE_CANDIDATE=${CANDIDATE_BETA} MODSET=beta"
- make prepare-release PREVIOUS_VERSION=${CURRENT_BETA_ESCAPED} RELEASE_CANDIDATE=${CANDIDATE_BETA} MODSET=beta"
fi
git push origin "${BRANCH}"

Expand Down

0 comments on commit a211cc8

Please sign in to comment.