versioning and wp plugin updates
This commit is contained in:
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
@receiver(pre_save, sender=PluginVersion)
|
||||
def auto_build_plugin_on_release(sender, instance, **kwargs):
|
||||
"""
|
||||
Automatically build ZIP package when a version is marked as released or update_ready.
|
||||
Automatically build ZIP package when a version is marked as released.
|
||||
|
||||
This ensures:
|
||||
1. ZIP file is always up-to-date with source code
|
||||
@@ -25,36 +25,32 @@ def auto_build_plugin_on_release(sender, instance, **kwargs):
|
||||
3. No manual intervention needed for releases
|
||||
|
||||
Triggers on:
|
||||
- New version created with status 'released' or 'update_ready'
|
||||
- Existing version status changed to 'released' or 'update_ready'
|
||||
"""
|
||||
release_statuses = ['released', 'update_ready']
|
||||
- New version created with status 'released'
|
||||
- Existing version status changed to 'released'
|
||||
|
||||
# Check if this version should have a ZIP built
|
||||
Note: Only 'released' status makes the version available for download.
|
||||
"""
|
||||
# Only build ZIP when status is 'released'
|
||||
should_build = False
|
||||
|
||||
if not instance.pk:
|
||||
# New instance - build if status is a release status
|
||||
if instance.status in release_statuses:
|
||||
# New instance - build if status is released
|
||||
if instance.status == 'released':
|
||||
should_build = True
|
||||
logger.info(f"New plugin version {instance.plugin.slug} v{instance.version} created with status '{instance.status}' - building ZIP")
|
||||
logger.info(f"New plugin version {instance.plugin.slug} v{instance.version} created with status 'released' - building ZIP")
|
||||
else:
|
||||
# Existing instance - check if status changed to a release status
|
||||
# Existing instance - check if status changed to released
|
||||
try:
|
||||
old_instance = PluginVersion.objects.get(pk=instance.pk)
|
||||
old_status = old_instance.status
|
||||
new_status = instance.status
|
||||
|
||||
# Build if moving to a release status from a non-release status
|
||||
if new_status in release_statuses and old_status not in release_statuses:
|
||||
# Build if moving to released from any other status
|
||||
if new_status == 'released' and old_status != 'released':
|
||||
should_build = True
|
||||
logger.info(f"Building plugin ZIP for {instance.plugin.slug} v{instance.version} (status: {old_status} -> {new_status})")
|
||||
elif old_status == new_status and new_status in release_statuses:
|
||||
# No status change, but already released - no rebuild
|
||||
return
|
||||
elif old_status in release_statuses and new_status in release_statuses:
|
||||
# Moving between release statuses - no rebuild
|
||||
logger.info(f"Plugin {instance.plugin.slug} v{instance.version}: Status changing from {old_status} to {new_status}, no rebuild needed")
|
||||
logger.info(f"Building plugin ZIP for {instance.plugin.slug} v{instance.version} (status: {old_status} -> released)")
|
||||
elif old_status == 'released' and new_status == 'released':
|
||||
# No status change, already released - no rebuild
|
||||
return
|
||||
except PluginVersion.DoesNotExist:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user