mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
Workflow build increment logic
This commit is contained in:
@@ -672,7 +672,20 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ "$SOURCE_FORMAT" == *"native"* ]] && [[
|
|||||||
if [[ "$IS_MANUAL" == true ]]; then
|
if [[ "$IS_MANUAL" == true ]]; then
|
||||||
echo "==> Detected rebuild of same base version $CHANGELOG_BASE, incrementing version"
|
echo "==> Detected rebuild of same base version $CHANGELOG_BASE, incrementing version"
|
||||||
|
|
||||||
if [[ "$CHANGELOG_VERSION" =~ ^([0-9.]+)\+git$ ]]; then
|
# If REBUILD_RELEASE is set, use that number directly
|
||||||
|
if [[ -n "${REBUILD_RELEASE:-}" ]]; then
|
||||||
|
if [[ "$CHANGELOG_VERSION" =~ ^([0-9.]+)\+git([0-9]+)(\.[a-f0-9]+)?$ ]]; then
|
||||||
|
BASE_VERSION="${BASH_REMATCH[1]}"
|
||||||
|
GIT_NUM="${BASH_REMATCH[2]}"
|
||||||
|
GIT_HASH="${BASH_REMATCH[3]}"
|
||||||
|
NEW_VERSION="${BASE_VERSION}+git${GIT_NUM}${GIT_HASH}ppa${REBUILD_RELEASE}"
|
||||||
|
echo " Using REBUILD_RELEASE=$REBUILD_RELEASE: $CHANGELOG_VERSION -> $NEW_VERSION"
|
||||||
|
else
|
||||||
|
BASE_VERSION=$(echo "$CHANGELOG_VERSION" | sed 's/ppa[0-9]*$//')
|
||||||
|
NEW_VERSION="${BASE_VERSION}ppa${REBUILD_RELEASE}"
|
||||||
|
echo " Using REBUILD_RELEASE=$REBUILD_RELEASE: $CHANGELOG_VERSION -> $NEW_VERSION"
|
||||||
|
fi
|
||||||
|
elif [[ "$CHANGELOG_VERSION" =~ ^([0-9.]+)\+git$ ]]; then
|
||||||
BASE_VERSION="${BASH_REMATCH[1]}"
|
BASE_VERSION="${BASH_REMATCH[1]}"
|
||||||
NEW_VERSION="${BASE_VERSION}+gitppa1"
|
NEW_VERSION="${BASE_VERSION}+gitppa1"
|
||||||
echo " Adding PPA number: $CHANGELOG_VERSION -> $NEW_VERSION"
|
echo " Adding PPA number: $CHANGELOG_VERSION -> $NEW_VERSION"
|
||||||
@@ -704,11 +717,27 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ "$SOURCE_FORMAT" == *"native"* ]] && [[
|
|||||||
fi
|
fi
|
||||||
elif [[ "$CHANGELOG_VERSION" =~ ^([0-9.]+)(-([0-9]+))?$ ]]; then
|
elif [[ "$CHANGELOG_VERSION" =~ ^([0-9.]+)(-([0-9]+))?$ ]]; then
|
||||||
BASE_VERSION="${BASH_REMATCH[1]}"
|
BASE_VERSION="${BASH_REMATCH[1]}"
|
||||||
NEW_VERSION="${BASE_VERSION}ppa1"
|
# Check if old DSC has ppa suffix even if changelog doesn't
|
||||||
echo " Warning: Native format cannot have Debian revision, converting to PPA format: $CHANGELOG_VERSION -> $NEW_VERSION"
|
if [[ "$OLD_DSC_VERSION" =~ ppa([0-9]+)$ ]]; then
|
||||||
|
OLD_PPA_NUM="${BASH_REMATCH[1]}"
|
||||||
|
NEW_PPA_NUM=$((OLD_PPA_NUM + 1))
|
||||||
|
NEW_VERSION="${BASE_VERSION}ppa${NEW_PPA_NUM}"
|
||||||
|
echo " Incrementing PPA number from old DSC: $OLD_DSC_VERSION -> $NEW_VERSION"
|
||||||
|
else
|
||||||
|
NEW_VERSION="${BASE_VERSION}ppa1"
|
||||||
|
echo " Adding PPA number: $CHANGELOG_VERSION -> $NEW_VERSION"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
NEW_VERSION="${CHANGELOG_VERSION}ppa1"
|
# Check if old DSC has ppa suffix for unknown formats
|
||||||
echo " Warning: Could not parse version format, appending ppa1: $CHANGELOG_VERSION -> $NEW_VERSION"
|
if [[ "$OLD_DSC_VERSION" =~ ppa([0-9]+)$ ]]; then
|
||||||
|
OLD_PPA_NUM="${BASH_REMATCH[1]}"
|
||||||
|
NEW_PPA_NUM=$((OLD_PPA_NUM + 1))
|
||||||
|
NEW_VERSION="${CHANGELOG_VERSION}ppa${NEW_PPA_NUM}"
|
||||||
|
echo " Incrementing PPA number from old DSC: $OLD_DSC_VERSION -> $NEW_VERSION"
|
||||||
|
else
|
||||||
|
NEW_VERSION="${CHANGELOG_VERSION}ppa1"
|
||||||
|
echo " Warning: Could not parse version format, appending ppa1: $CHANGELOG_VERSION -> $NEW_VERSION"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$SOURCE_DIR" ]] || [[ ! -d "$SOURCE_DIR" ]] || [[ ! -d "$SOURCE_DIR/debian" ]]; then
|
if [[ -z "$SOURCE_DIR" ]] || [[ ! -d "$SOURCE_DIR" ]] || [[ ! -d "$SOURCE_DIR/debian" ]]; then
|
||||||
|
|||||||
@@ -283,22 +283,29 @@ if [ "$IS_GIT_PACKAGE" = true ] && [ -n "$GIT_REPO" ]; then
|
|||||||
# Check if we're rebuilding the same commit (increment PPA number if so)
|
# Check if we're rebuilding the same commit (increment PPA number if so)
|
||||||
BASE_VERSION="${UPSTREAM_VERSION}+git${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}"
|
BASE_VERSION="${UPSTREAM_VERSION}+git${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}"
|
||||||
CURRENT_VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null || echo "")
|
CURRENT_VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null || echo "")
|
||||||
PPA_NUM=1
|
|
||||||
|
|
||||||
# If current version matches the base version, increment PPA number
|
# Use REBUILD_RELEASE if provided, otherwise auto-increment
|
||||||
# Escape special regex characters in BASE_VERSION for pattern matching
|
if [[ -n "${REBUILD_RELEASE:-}" ]]; then
|
||||||
ESCAPED_BASE=$(echo "$BASE_VERSION" | sed 's/\./\\./g' | sed 's/+/\\+/g')
|
PPA_NUM=$REBUILD_RELEASE
|
||||||
if [[ "$CURRENT_VERSION" =~ ^${ESCAPED_BASE}ppa([0-9]+)$ ]]; then
|
info "Using REBUILD_RELEASE=$REBUILD_RELEASE for PPA number"
|
||||||
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
|
||||||
if [[ "$IS_MANUAL" == true ]]; then
|
|
||||||
info "Detected rebuild of same commit (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
|
||||||
else
|
|
||||||
info "Detected rebuild of same commit (current: $CURRENT_VERSION). Not a manual run, skipping."
|
|
||||||
success "No changes needed (commit matches)."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
info "New commit or first build, using PPA number $PPA_NUM"
|
PPA_NUM=1
|
||||||
|
|
||||||
|
# If current version matches the base version, increment PPA number
|
||||||
|
# Escape special regex characters in BASE_VERSION for pattern matching
|
||||||
|
ESCAPED_BASE=$(echo "$BASE_VERSION" | sed 's/\./\\./g' | sed 's/+/\\+/g')
|
||||||
|
if [[ "$CURRENT_VERSION" =~ ^${ESCAPED_BASE}ppa([0-9]+)$ ]]; then
|
||||||
|
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
||||||
|
if [[ "$IS_MANUAL" == true ]]; then
|
||||||
|
info "Detected rebuild of same commit (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
||||||
|
else
|
||||||
|
info "Detected rebuild of same commit (current: $CURRENT_VERSION). Not a manual run, skipping."
|
||||||
|
success "No changes needed (commit matches)."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
info "New commit or first build, using PPA number $PPA_NUM"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
||||||
@@ -429,16 +436,23 @@ elif [ -n "$GIT_REPO" ]; then
|
|||||||
|
|
||||||
# Get current version to check if we need to increment PPA number
|
# Get current version to check if we need to increment PPA number
|
||||||
CURRENT_VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null || echo "")
|
CURRENT_VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null || echo "")
|
||||||
PPA_NUM=1
|
|
||||||
|
# Use REBUILD_RELEASE if provided, otherwise auto-increment
|
||||||
|
if [[ -n "${REBUILD_RELEASE:-}" ]]; then
|
||||||
|
PPA_NUM=$REBUILD_RELEASE
|
||||||
|
info "Using REBUILD_RELEASE=$REBUILD_RELEASE for PPA number"
|
||||||
|
else
|
||||||
|
PPA_NUM=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$SOURCE_FORMAT" == *"native"* ]]; then
|
if [[ "$SOURCE_FORMAT" == *"native"* ]]; then
|
||||||
# Native format: 0.2.1ppa1 (no dash, no revision)
|
# Native format: 0.2.1ppa1 (no dash, no revision)
|
||||||
BASE_VERSION="${LATEST_TAG}"
|
BASE_VERSION="${LATEST_TAG}"
|
||||||
# Check if we're rebuilding the same version (increment PPA number if so)
|
# Check if we're rebuilding the same version (increment PPA number if so)
|
||||||
if [[ "$CURRENT_VERSION" =~ ^${LATEST_TAG}ppa([0-9]+)$ ]]; then
|
if [[ -z "${REBUILD_RELEASE:-}" ]] && [[ "$CURRENT_VERSION" =~ ^${LATEST_TAG}ppa([0-9]+)$ ]]; then
|
||||||
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
||||||
info "Detected rebuild of same version (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
info "Detected rebuild of same version (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
||||||
else
|
elif [[ -z "${REBUILD_RELEASE:-}" ]]; then
|
||||||
info "New version or first build, using PPA number $PPA_NUM"
|
info "New version or first build, using PPA number $PPA_NUM"
|
||||||
fi
|
fi
|
||||||
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
||||||
@@ -447,7 +461,7 @@ elif [ -n "$GIT_REPO" ]; then
|
|||||||
BASE_VERSION="${LATEST_TAG}-1"
|
BASE_VERSION="${LATEST_TAG}-1"
|
||||||
# Check if we're rebuilding the same version (increment PPA number if so)
|
# Check if we're rebuilding the same version (increment PPA number if so)
|
||||||
ESCAPED_BASE=$(echo "$BASE_VERSION" | sed 's/\./\\./g' | sed 's/-/\\-/g')
|
ESCAPED_BASE=$(echo "$BASE_VERSION" | sed 's/\./\\./g' | sed 's/-/\\-/g')
|
||||||
if [[ "$CURRENT_VERSION" =~ ^${ESCAPED_BASE}ppa([0-9]+)$ ]]; then
|
if [[ -z "${REBUILD_RELEASE:-}" ]] && [[ "$CURRENT_VERSION" =~ ^${ESCAPED_BASE}ppa([0-9]+)$ ]]; then
|
||||||
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
PPA_NUM=$((BASH_REMATCH[1] + 1))
|
||||||
if [[ "$IS_MANUAL" == true ]]; then
|
if [[ "$IS_MANUAL" == true ]]; then
|
||||||
info "Detected rebuild of same version (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
info "Detected rebuild of same version (current: $CURRENT_VERSION), incrementing PPA number to $PPA_NUM"
|
||||||
@@ -456,7 +470,7 @@ elif [ -n "$GIT_REPO" ]; then
|
|||||||
success "No changes needed (version matches)."
|
success "No changes needed (version matches)."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
elif [[ -z "${REBUILD_RELEASE:-}" ]]; then
|
||||||
info "New version or first build, using PPA number $PPA_NUM"
|
info "New version or first build, using PPA number $PPA_NUM"
|
||||||
fi
|
fi
|
||||||
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
NEW_VERSION="${BASE_VERSION}ppa${PPA_NUM}"
|
||||||
|
|||||||
Reference in New Issue
Block a user