From 9820ca43faf10ec394728cba2420e2b0b9c74529 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 8 Sep 2023 16:37:40 -0400 Subject: [PATCH] fix: commit tags and rebuilds --- build-system/scripts/build | 67 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/build-system/scripts/build b/build-system/scripts/build index 1a37abad347..a12cb43de59 100755 --- a/build-system/scripts/build +++ b/build-system/scripts/build @@ -63,6 +63,40 @@ retry ensure_repo $REPOSITORY $ECR_REGION refresh_lifecycle CONTENT_HASH=$(calculate_content_hash $REPOSITORY) echo "Content hash: $CONTENT_HASH" +# Extract version from commit tag +# Check if there is a commit tag +if [[ -n "$COMMIT_TAG" ]]; then + + # Check if it's a repo-specific tag + if [[ "$COMMIT_TAG" == *"/"* ]]; then + REPO_NAME="${COMMIT_TAG%%/*}" + COMMIT_TAG_VERSION="${COMMIT_TAG#*/}" + echo "Tag was made for: $REPO_NAME" + echo "Version: $COMMIT_TAG_VERSION" + + # Check if REPO_NAME is equal to REPOSITORY + if [ "$REPO_NAME" != "$REPOSITORY" ]; then + echo "REPO_NAME ($REPO_NAME) does not match REPOSITORY ($REPOSITORY). Ignoring..." + COMMIT_TAG_VERSION="" + fi + else + COMMIT_TAG_VERSION=$COMMIT_TAG + fi + + # TODO #2155 dont seem to be able to install npx + # # We are building a tagged commit. Check it's a valid semver. + # VERSION=$(npx semver $COMMIT_TAG_VERSION) + # if [ -z "$VERSION" ]; then + # COMMIT_TAG_VERSION="" + # else + # COMMIT_TAG_VERSION=$VERSION + # fi + # fix: we need to use a different content hash for a commit tag + CONTENT_HASH="$CONTENT_HASH$COMMIT_TAG_VERSION" +else + COMMIT_TAG_VERSION="" +fi + cd $BUILD_DIR # If we have previously successful commit, we can early out if nothing relevant has changed since. @@ -114,39 +148,6 @@ for PARENT in $PARENTS; do retry docker tag $PARENT_IMAGE_URI $ECR_DEPLOY_URL/$PARENT done - -# Extract version from commit tag -# Check if there is a commit tag -if [[ -n "$COMMIT_TAG" ]]; then - - # Check if it's a repo-specific tag - if [[ "$COMMIT_TAG" == *"/"* ]]; then - REPO_NAME="${COMMIT_TAG%%/*}" - COMMIT_TAG_VERSION="${COMMIT_TAG#*/}" - echo "Tag was made for: $REPO_NAME" - echo "Version: $COMMIT_TAG_VERSION" - - # Check if REPO_NAME is equal to REPOSITORY - if [ "$REPO_NAME" != "$REPOSITORY" ]; then - echo "REPO_NAME ($REPO_NAME) does not match REPOSITORY ($REPOSITORY). Ignoring..." - COMMIT_TAG_VERSION="" - fi - else - COMMIT_TAG_VERSION=$COMMIT_TAG - fi - - # We are building a tagged commit. Check it's a valid semver. - VERSION=$(npx semver $COMMIT_TAG_VERSION) - if [ -z "$VERSION" ]; then - COMMIT_TAG_VERSION="" - else - COMMIT_TAG_VERSION=$VERSION - fi -else - COMMIT_TAG_VERSION="" -fi - - # Pull, build and push each named stage to cache. STAGE_CACHE_FROM="" CACHE_FROM=""