Skip to content

Commit

Permalink
Use ci_matching_branch/ in bump_dependency.bash (#580)
Browse files Browse the repository at this point in the history
* Part of #564.
* Fix replacing ign-fuel-tools branch name with main
  Replace branch name before swapping - for _ in DEP_LIB.
* Make source code pull request after metadata
  The source code PRs will fail without the metadata,
  so commit the metadata first.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters authored Dec 3, 2021
1 parent 99e54bb commit 670d76f
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions release-repo-scripts/bump_dependency.bash
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ commitAndPR() {

# Sanity check that we're on a bump branch already
local CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ ! $CURRENT_BRANCH = bump_* ]]
if [[ ! $CURRENT_BRANCH =~ bump_* ]]
then
echo -e "${RED}${REPO}: Something's wrong, trying to commit to branch ${CURRENT_BRANCH}.${DEFAULT}"
return
Expand Down Expand Up @@ -313,49 +313,10 @@ for ((i = 0; i < "${#LIBRARIES[@]}"; i++)); do
PREV_VER="$((${VER}-1))"
LIB_UPPER=`echo ${LIB#"ign-"} | tr a-z A-Z`
ORG=${IGN_ORG}
BUMP_BRANCH="bump_${COLLECTION}_${LIB}${VER}"
BUMP_BRANCH="ci_matching_branch/bump_${COLLECTION}_${LIB}${VER}"

echo -e "${BLUE_BG}Processing [${LIB}]${DEFAULT_BG}"

##################
# source code
##################

echo -e "${GREEN}${LIB}: source code${DEFAULT}"

cloneIfNeeded ${ORG} ${LIB}
startFromCleanBranch ${BUMP_BRANCH} main

# Check if main branch of that library is the correct version
PROJECT_NAME="${LIB_}${VER}"
PROJECT_NAME="${PROJECT_NAME/ign_/ignition-}"
PROJECT="project.*(${PROJECT_NAME}"
if ! grep -q ${PROJECT} "CMakeLists.txt"; then
echo -e "${RED}Wrong project name on [CMakeLists.txt], looking for [$PROJECT_NAME].${DEFAULT}"
exit
fi

echo -e "${GREEN}${LIB}: Updating source code${DEFAULT}"
for ((j = 0; j < "${#LIBRARIES[@]}"; j++)); do

DEP_LIB=${LIBRARIES[$j]#"ign-"}
DEP_VER=${VERSIONS[$j]}
DEP_PREV_VER="$((${DEP_VER}-1))"

find . -type f ! -name 'Changelog.md' ! -name 'Migration.md' -print0 | xargs -0 sed -i "s ${DEP_LIB}${DEP_PREV_VER} ${DEP_LIB}${DEP_VER} g"

# Second run with _ instead of -, to support multiple variations of fuel-tools
DEP_LIB=${DEP_LIB//-/_}
find . -type f ! -name 'Changelog.md' ! -name 'Migration.md' -print0 | xargs -0 sed -i "s ${DEP_LIB}${DEP_PREV_VER} ${DEP_LIB}${DEP_VER} g"

# Replace collection yaml branch names with main
if [[ "${LIB}" == "ign-${COLLECTION}" ]]; then
find . -type f -name "collection-${COLLECTION}.yaml" -print0 | xargs -0 sed -i "s ign-${DEP_LIB}${DEP_VER} main g"
fi
done

commitAndPR ${ORG} main

##################
# release repo
##################
Expand Down Expand Up @@ -384,7 +345,7 @@ for ((i = 0; i < "${#LIBRARIES[@]}"; i++)); do
echo -e "${GREEN}${LIB}: homebrew${DEFAULT}"

cd ${TEMP_DIR}/homebrew-simulation
startFromCleanBranch bump_${COLLECTION}_${LIB} master
startFromCleanBranch ${BUMP_BRANCH} master

# expand ign-* to ignition-*
FORMULA_BASE=${LIB/ign/ignition}
Expand Down Expand Up @@ -469,6 +430,45 @@ for ((i = 0; i < "${#LIBRARIES[@]}"; i++)); do

commitAndPR ${TOOLING_ORG} master

##################
# source code
##################

echo -e "${GREEN}${LIB}: source code${DEFAULT}"

cloneIfNeeded ${ORG} ${LIB}
startFromCleanBranch ${BUMP_BRANCH} main

# Check if main branch of that library is the correct version
PROJECT_NAME="${LIB_}${VER}"
PROJECT_NAME="${PROJECT_NAME/ign_/ignition-}"
PROJECT="project.*(${PROJECT_NAME}"
if ! grep -q ${PROJECT} "CMakeLists.txt"; then
echo -e "${RED}Wrong project name on [CMakeLists.txt], looking for [$PROJECT_NAME].${DEFAULT}"
exit
fi

echo -e "${GREEN}${LIB}: Updating source code${DEFAULT}"
for ((j = 0; j < "${#LIBRARIES[@]}"; j++)); do

DEP_LIB=${LIBRARIES[$j]#"ign-"}
DEP_VER=${VERSIONS[$j]}
DEP_PREV_VER="$((${DEP_VER}-1))"

find . -type f ! -name 'Changelog.md' ! -name 'Migration.md' -print0 | xargs -0 sed -i "s ${DEP_LIB}${DEP_PREV_VER} ${DEP_LIB}${DEP_VER} g"

# Replace collection yaml branch names with main
if [[ "${LIB}" == "ign-${COLLECTION}" ]]; then
find . -type f -name "collection-${COLLECTION}.yaml" -print0 | xargs -0 sed -i "s ign-${DEP_LIB}${DEP_VER} main g"
fi

# Second run with _ instead of -, to support multiple variations of fuel-tools
DEP_LIB=${DEP_LIB//-/_}
find . -type f ! -name 'Changelog.md' ! -name 'Migration.md' -print0 | xargs -0 sed -i "s ${DEP_LIB}${DEP_PREV_VER} ${DEP_LIB}${DEP_VER} g"
done

commitAndPR ${ORG} main

# Collection ends here
if ! [[ $VER == ?(-)+([0-9]) ]] ; then
continue
Expand Down

0 comments on commit 670d76f

Please sign in to comment.