Skip to content

The open alternative to Salesforce, designed for AI.

Treat the current upgrade version directory as previous once its tag exists (#26137)

Paul Rastoinc2d6ae0e2e88
diff --git a/.github/actions/upgrade-mutation-guard/action.yaml b/.github/actions/upgrade-mutation-guard/action.yaml
index 295bc860201..8198399803c 100644
--- a/.github/actions/upgrade-mutation-guard/action.yaml
+++ b/.github/actions/upgrade-mutation-guard/action.yaml
@@ -1,9 +1,10 @@
name: Upgrade Mutation Guard
description: >
Validates that added/modified upgrade commands stay in the current version
- directory and keep timestamps real and append-only, diffed against a given
- base. Shared by the PR-level guard (base = PR base) and the merge-queue guard
- (base = merge candidate's base, i.e. the current tip of main).
+ directory (frozen as well once its tag exists) and keep timestamps real and
+ append-only, diffed against a given base. Shared by the PR-level guard
+ (base = PR base) and the merge-queue guard (base = merge candidate's base,
+ i.e. the current tip of main).
inputs:
base_sha:
@@ -55,6 +56,32 @@ runs:
ADDED_FILES=$(echo "$DIFF" | awk '$1 == "A" { print $2 } $1 ~ /^[RC]/ { print $3 }')
MODIFIED_FILES=$(echo "$DIFF" | awk '$1 == "M" { print $2 }')
+ # Between the tag push and the version bump PR, TWENTY_CURRENT_VERSION
+ # still names the released version. Once its tag exists, its directory
+ # is a previous version like any other: the tag already shipped it.
+ # The lookup only runs when the change touches that directory, and a
+ # lookup that cannot answer fails the check instead of passing it.
+ IS_CURRENT_VERSION_RELEASED=false
+
+ if echo "$ADDED_FILES $MODIFIED_FILES" | grep -qF "upgrade-version-command/${CURRENT_DIR}/"; then
+ LS_REMOTE_STATUS=0
+ git ls-remote --exit-code --tags origin "refs/tags/twenty/v${CURRENT_VERSION}" >/dev/null || LS_REMOTE_STATUS=$?
+
+ case "$LS_REMOTE_STATUS" in
+ 0)
+ IS_CURRENT_VERSION_RELEASED=true
+ echo "twenty/v${CURRENT_VERSION} is already tagged: ${CURRENT_DIR} is frozen until the version bump lands."
+ ;;
+ 2)
+ echo "twenty/v${CURRENT_VERSION} is not tagged yet: ${CURRENT_DIR} is writable."
+ ;;
+ *)
+ echo "::error::Could not determine whether twenty/v${CURRENT_VERSION} is tagged (git ls-remote exited ${LS_REMOTE_STATUS}). Re-run the job."
+ exit 1
+ ;;
+ esac
+ fi
+
ADDED_OFFENDERS=""
MODIFIED_OFFENDERS=""
@@ -64,7 +91,7 @@ runs:
for file in "$@"; do
VERSION_DIR=$(echo "$file" | sed -n 's|.*upgrade-version-command/\([0-9]*-[0-9]*\)/.*|\1|p')
- if [ -n "$VERSION_DIR" ] && [ "$VERSION_DIR" != "$CURRENT_DIR" ]; then
+ if [ -n "$VERSION_DIR" ] && { [ "$VERSION_DIR" != "$CURRENT_DIR" ] || [ "$IS_CURRENT_VERSION_RELEASED" = "true" ]; }; then
if [ "$category" = "added" ]; then
ADDED_OFFENDERS="$ADDED_OFFENDERS\n - $file (version directory: $VERSION_DIR)"
else
@@ -78,7 +105,11 @@ runs:
check_files "modified" $MODIFIED_FILES
if [ -n "$ADDED_OFFENDERS" ] || [ -n "$MODIFIED_OFFENDERS" ]; then
- echo "This change touches upgrade command files outside the current version directory ($CURRENT_DIR / $CURRENT_VERSION)."
+ if [ "$IS_CURRENT_VERSION_RELEASED" = "true" ]; then
+ echo "This change touches upgrade command files of a released version: twenty/v${CURRENT_VERSION} is already tagged, so ${CURRENT_DIR} is frozen."
+ else
+ echo "This change touches upgrade command files outside the current version directory ($CURRENT_DIR / $CURRENT_VERSION)."
+ fi
if [ -n "$ADDED_OFFENDERS" ]; then
echo ""
@@ -94,7 +125,11 @@ runs:
echo ""
echo "If this is intentional, add the label 'ci:allow-previous-version-upgrade-mutation' to the PR and re-run CI."
- echo "Otherwise, move your changes to the current version directory ($CURRENT_DIR)."
+ if [ "$IS_CURRENT_VERSION_RELEASED" = "true" ]; then
+ echo "Otherwise, wait for the version bump PR to land, then regenerate your command under the next version."
+ else
+ echo "Otherwise, move your changes to the current version directory ($CURRENT_DIR)."
+ fi
echo "::error::Upgrade commands were added or modified in non-current version directories."
exit 1