Simplify adding farmOS repository to composer.json. #414

This commit is contained in:
paul121 2021-02-26 08:39:52 -08:00 committed by Michael Stenta
parent 805ba19ee3
commit 8c6e508baf
1 changed files with 4 additions and 2 deletions

View File

@ -20,12 +20,14 @@ rm -rf project
git checkout ${PROJECT_VERSION}
git reset --hard
# Replace the farmOS repository and version in composer.json.
# Add the farmOS repository to composer.json.
composer config repositories.farmos git ${FARMOS_REPO}
# Replace the farmOS version in composer.json.
# If FARMOS_VERSION is a valid semantic versioning string, we assume that it is
# a tagged version, and replace the entire version string in composer.json.
# Or, if FARMOS_VERSION is not "2.x", we assume that it is a branch, and
# prepend it with "dev-". Otherwise (FARMOS_VERSION is "2.x"), do nothing.
sed -i 's|"repositories": \[|"repositories": \[ {"type": "git", "url": "'"${FARMOS_REPO}"'"},|g' composer.json
if [[ "${FARMOS_VERSION}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
sed -i 's|"farmos/farmos": "2.x-dev"|"farmos/farmos": "'"${FARMOS_VERSION}"'"|g' composer.json
elif ! [ "${FARMOS_VERSION}" = "2.x" ]; then