Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/config/release.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
"changelog_section": "## Changelog",
"build_artifacts": ["hello-theme.zip"],
"wordpress_org": {
"manual_upload": true,
"theme_slug": "hello-elementor"
"auto_deploy": true,
"theme_slug": "hello-elementor",
"svn_url": "https://themes.svn.wordpress.org/hello-elementor/",
"skip_pre_releases": true,
"validation_required": true
}
},
"notifications": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Release Preparation (Hello Elementor)'
name: 'Automated Release'

on:
workflow_dispatch:
Expand All @@ -20,6 +20,11 @@
type: boolean
description: 'Dry run (test without creating actual release)?'
required: false
default: true
deploy_to_wporg:
type: boolean
description: 'Deploy to WordPress.org theme repository?'
required: false
default: false
slack_channel:
type: string
Expand All @@ -40,8 +45,6 @@
jobs:
release:
runs-on: ubuntu-22.04
# Workflow design: version files are bumped early, used for build/release, then automatically restored
# by peter-evans/create-pull-request action. Error cleanup ensures consistent state on any failure.
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -52,7 +55,7 @@
- name: Load Release Configuration
id: config
run: |
echo "📋 Loading Hello Elementor release configuration..."
echo "📋 Loading release configuration..."
CONFIG_FILE=".github/config/release.json"
if [ ! -f "$CONFIG_FILE" ]; then
Expand All @@ -71,13 +74,17 @@
BLOCKED_ACTORS=$(jq -r '.security.blocked_actors[]' "$CONFIG_FILE" | tr '\n' ' ')
RELEASE_BRANCHES=$(jq -r '.repository.release_branches[]' "$CONFIG_FILE" | tr '\n' ' ')
CONFIG_THEME_SLUG=$(jq -r '.release.wordpress_org.theme_slug' "$CONFIG_FILE")
AUTO_DEPLOY_ENABLED=$(jq -r '.release.wordpress_org.auto_deploy' "$CONFIG_FILE")
echo "ALLOWED_REPOS=$ALLOWED_REPOS" >> $GITHUB_ENV
echo "BLOCKED_ACTORS=$BLOCKED_ACTORS" >> $GITHUB_ENV
echo "RELEASE_BRANCHES=$RELEASE_BRANCHES" >> $GITHUB_ENV
echo "CONFIG_THEME_SLUG=$CONFIG_THEME_SLUG" >> $GITHUB_ENV
echo "AUTO_DEPLOY_ENABLED=$AUTO_DEPLOY_ENABLED" >> $GITHUB_ENV
echo "✅ Hello Elementor release configuration loaded successfully"
echo "✅ Release configuration loaded successfully"
echo " - Theme slug: $CONFIG_THEME_SLUG"
echo " - Auto-deploy enabled: $AUTO_DEPLOY_ENABLED"
- name: Pre-flight checks
run: |
Expand All @@ -86,6 +93,7 @@
echo "Current Branch: ${{ github.ref_name }}"
echo "Version Type: ${{ inputs.version_type }}"
echo "Dry Run: ${{ inputs.dry_run }}"
echo "Deploy to WordPress.org: ${{ inputs.deploy_to_wporg }}"
echo "Repository: ${{ github.repository }}"
echo "Actor: ${{ github.actor }}"
Expand All @@ -106,7 +114,7 @@
echo "⚠️ Warning: Running on unauthorized repository: ${{ github.repository }}"
fi
# Check actor permissions (basic validation)
# Check actor permissions
for blocked_actor in ${{ env.BLOCKED_ACTORS }}; do
if [ "${{ github.actor }}" == "$blocked_actor" ]; then
echo "❌ Error: Blocked actor cannot create releases: ${{ github.actor }}"
Expand Down Expand Up @@ -158,12 +166,12 @@
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "CLEAN_PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "Current Hello Elementor version: $PACKAGE_VERSION"
echo "Current version: $PACKAGE_VERSION"
- name: Bump Theme Version (Dry Run)
if: ${{ inputs.dry_run == true }}
run: |
echo "🧪 DRY RUN: Would bump Hello Elementor version from ${{ env.CLEAN_PACKAGE_VERSION }}"
echo "🧪 DRY RUN: Would bump version from ${{ env.CLEAN_PACKAGE_VERSION }}"
CURRENT_VERSION="${{ env.CLEAN_PACKAGE_VERSION }}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
Expand All @@ -189,7 +197,6 @@
echo "DRY_RUN_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "🧪 DRY RUN: Version would be: $CURRENT_VERSION → $NEW_VERSION"
echo "🧪 DRY RUN: Changelog validation will use current version: $CURRENT_VERSION"
- name: Bump Theme Version (Actual)
if: ${{ inputs.dry_run == false }}
Expand All @@ -198,27 +205,12 @@
CLEAN_PACKAGE_VERSION: ${{ env.CLEAN_PACKAGE_VERSION }}
VERSION_TYPE: ${{ inputs.version_type }}

- name: Validate current versions (Dry Run)
if: ${{ inputs.dry_run == true }}
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "🔍 Validating CURRENT versions ($CURRENT_VERSION)..."
bash .github/scripts/validate-versions-release.sh
- name: Validate changelog for updated version (Dry Run)
if: ${{ inputs.dry_run == true }}
uses: ./.github/actions/get-changelog-from-readme-release
with:
VERSION: ${{ env.DRY_RUN_VERSION }}

- name: Validate changelog for new version (Actual)
if: ${{ inputs.dry_run == false }}
- name: Validate changelog for new version
uses: ./.github/actions/get-changelog-from-readme-release
with:
VERSION: ${{ env.PACKAGE_VERSION }}

# Build with version-bumped files to ensure release assets contain correct versions
- name: Build Hello Elementor Theme
- name: Build Theme
id: build
uses: ./.github/actions/build-theme-release
with:
Expand All @@ -232,10 +224,8 @@
echo " - Tag: v${{ env.PACKAGE_VERSION }}"
echo " - Build file: ${{ env.BUILD_ZIP_PATH }}"
echo " - Changelog: ${{ env.CHANGELOG_FILE }}"
echo "RELEASE_URL=https://github.com/elementor/hello-theme/releases/tag/v${{ env.PACKAGE_VERSION }}" >> $GITHUB_ENV
echo "RELEASE_URL=https://github.com/${{ github.repository }}/releases/tag/v${{ env.PACKAGE_VERSION }}" >> $GITHUB_ENV
# Create GitHub release with version-bumped assets before repository cleanup
# This ensures the published release contains the correct version numbers
- name: Create GitHub Release (Actual)
if: ${{ inputs.dry_run == false }}
id: create-release
Expand All @@ -248,103 +238,205 @@
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}

# Repository maintenance steps happen after release creation
# Note: peter-evans/create-pull-request automatically restores working directory
# This design ensures release assets are created before any git cleanup occurs
- name: Set Release URL
if: ${{ inputs.dry_run == false }}
run: |
echo "RELEASE_URL=${{ steps.create-release.outputs.html_url }}" >> $GITHUB_ENV
# WordPress.org Deployment Section
- name: WordPress.org Deployment Validation
if: ${{ inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true' }}
run: |
echo "🔍 **WordPress.org Deployment Pre-flight**"
echo " - Theme: Hello Elementor"
echo " - Version: ${{ env.PACKAGE_VERSION }}"
echo " - SVN URL: https://themes.svn.wordpress.org/${{ env.CONFIG_THEME_SLUG }}"
echo " - Build directory: ./${{ env.CONFIG_THEME_SLUG }}"
echo " - Dry run: ${{ inputs.dry_run }}"
# Validate build directory exists
if [ ! -d "./${{ env.CONFIG_THEME_SLUG }}" ]; then
echo "❌ Build directory not found: ./${{ env.CONFIG_THEME_SLUG }}"
exit 1
fi
# Validate required theme files
for file in style.css index.php functions.php readme.txt; do
if [ ! -f "./${{ env.CONFIG_THEME_SLUG }}/$file" ]; then
echo "❌ Required file missing: $file"
exit 1
fi
done
echo "✅ Pre-flight validation passed"
- name: Deploy to WordPress.org (Dry Run)
if: ${{ inputs.dry_run == true && inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true' }}
uses: 10up/action-wordpress-plugin-deploy@stable

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Automated Release' step
Uses Step
uses '10up/action-wordpress-plugin-deploy' with ref 'stable', not a pinned commit hash
with:
dry-run: true
env:
SVN_URL: https://themes.svn.wordpress.org/${{ env.CONFIG_THEME_SLUG }}
SLUG: ${{ env.CONFIG_THEME_SLUG }}
VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_DIR: ./${{ env.CONFIG_THEME_SLUG }}

# Skip PR creation for 'current' version type since no version bump occurs
- name: Deploy to WordPress.org Theme Repository
if: ${{ inputs.dry_run == false && inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true' }}
uses: 10up/action-wordpress-plugin-deploy@stable

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Automated Release' step
Uses Step
uses '10up/action-wordpress-plugin-deploy' with ref 'stable', not a pinned commit hash
env:
SVN_URL: https://themes.svn.wordpress.org/${{ env.CONFIG_THEME_SLUG }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: ${{ env.CONFIG_THEME_SLUG }}
VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_DIR: ./${{ env.CONFIG_THEME_SLUG }}

- name: WordPress.org Deployment Status
if: ${{ inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true' }}
run: |
if [ "${{ inputs.dry_run }}" == "true" ]; then
echo "🧪 **WordPress.org SVN Dry Run Complete!**"
echo ""
echo "📋 **Validation Results:**"
echo " - SVN repository structure: ✅ Validated"
echo " - Theme files preparation: ✅ Validated"
echo " - File exclusions (build process): ✅ Applied correctly"
echo " - Version consistency: ✅ Verified"
echo " - WordPress.org compatibility: ✅ Confirmed"
echo ""
echo "🚀 **Ready for Production Deployment!**"
echo " - Re-run workflow with dry_run: false to deploy"
echo " - All validations passed successfully"
else
echo "🚀 **WordPress.org Theme Deployment Complete!**"
echo ""
echo "📦 **Deployment Details:**"
echo " - Theme: Hello Elementor"
echo " - Version: v${{ env.PACKAGE_VERSION }}"
echo " - SVN Repository: Updated"
echo " - Theme Directory: https://wordpress.org/themes/${{ env.CONFIG_THEME_SLUG }}/"
echo ""
echo "⏰ **Timeline:**"
echo " - SVN commit: Immediate ✅"
echo " - Theme directory update: 15-60 minutes ⏰"
echo " - WordPress admin visibility: 15-60 minutes ⏰"
echo ""
echo "✅ **Next Steps:**"
echo " - Monitor WordPress.org for theme availability"
echo " - Test installation from WordPress admin"
echo " - Update support documentation if needed"
fi
# Repository maintenance - only for actual releases
- name: Create PR With Bumped Version
if: ${{ inputs.dry_run == false && inputs.version_type != 'current' }}
uses: ./.github/actions/create-pr-with-bumped-theme-version-release
with:
base_branch: ${{ inputs.release_branch }}
# Use NEW_VERSION (bumped version) instead of CLEAN_PACKAGE_VERSION (old version)
# This ensures PR title/branch reflects the actual new version (e.g., "Release v3.4.5")
# Fallback to CLEAN_PACKAGE_VERSION for safety if NEW_VERSION is not set
package_version: ${{ env.NEW_VERSION || env.CLEAN_PACKAGE_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}

# Update main branch version if new version > main version
- name: Update Main Branch Version
if: ${{ inputs.dry_run == false && inputs.version_type != 'current' }}
uses: ./.github/actions/update-main-branch-version-release
with:
new_version: ${{ env.NEW_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set Release URL
if: ${{ inputs.dry_run == false }}
run: |
echo "RELEASE_URL=${{ steps.create-release.outputs.html_url }}" >> $GITHUB_ENV
- name: Send Slack Notification (Dry Run)
if: false
if: ${{ inputs.dry_run == true && inputs.deploy_to_wporg == true }}
run: |
echo "🧪 DRY RUN: Would send Slack notification"
echo " - Channel: ${{ inputs.slack_channel }}"
echo " - Version: v${{ env.PACKAGE_VERSION }}"
echo " - Message: Hello Elementor release preparation complete (DRY RUN)"
echo " - Message: Release preparation complete (DRY RUN)"
- name: Slack Notification Skipped
if: ${{ inputs.dry_run == true }}
if: ${{ inputs.deploy_to_wporg == false }}
run: |
echo "📢 Slack notification skipped (release-preparation workflow)"
echo " - Only full releases with WordPress.org deployment trigger Slack notifications"
echo "📢 Slack notification skipped (deploy_to_wporg: false)"
echo " - Only WordPress.org deployments trigger Slack notifications"
- name: Send Slack Notification (Actual)
if: false
if: ${{ inputs.dry_run == false && inputs.deploy_to_wporg == true }}
uses: ./.github/actions/theme-slack-notification-release
with:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_ZIP_PATH: ${{ env.BUILD_ZIP_PATH }}
GITHUB_RELEASE_URL: ${{ env.RELEASE_URL }}
SLACK_CHANNEL: ${{ inputs.slack_channel }}
WPORG_DEPLOYMENT_STATUS: 'skipped'
WPORG_DEPLOYMENT_STATUS: ${{ (inputs.deploy_to_wporg == true && env.AUTO_DEPLOY_ENABLED == 'true') && 'deployed' || 'skipped' }}

- name: Manual Upload Instructions
- name: Deployment Summary
run: |
if [ "${{ inputs.dry_run }}" == "true" ]; then
echo "🧪 **DRY RUN COMPLETE!**"
echo "🧪 **AUTOMATED RELEASE DRY RUN COMPLETE!**"
echo ""
echo "📋 **This was a test run - no actual release was created**"
echo ""
echo "🔍 **What would have happened:**"
echo "1. Version would be bumped to: v${{ env.PACKAGE_VERSION }}"
echo "2. Hello Elementor theme would be built: ${{ env.BUILD_ZIP_PATH }}"
echo "2. Theme would be built: ${{ env.BUILD_ZIP_PATH }}"
echo "3. GitHub release would be created: ${{ env.RELEASE_URL }}"
echo "4. Slack notification would be sent to #release"
echo "4. Slack notification would be sent to ${{ inputs.slack_channel }}"
if [ "${{ inputs.deploy_to_wporg }}" == "true" ] && [ "${{ env.AUTO_DEPLOY_ENABLED }}" == "true" ]; then
echo "5. WordPress.org SVN deployment would be executed"
echo " - Theme deployed to WordPress.org theme repository"
echo " - SVN trunk and tags updated automatically"
echo " - Manual upload process eliminated! 🎉"
elif [ "${{ inputs.deploy_to_wporg }}" == "false" ]; then
echo "5. WordPress.org deployment: ⚠️ Skipped (deploy_to_wporg: false)"
else
echo "5. WordPress.org deployment: ⚠️ Disabled in config (auto_deploy: false)"
fi
echo ""
echo "✅ **Dry run validation passed - ready for actual release!**"
echo " - Re-run this workflow with dry_run: false"
else
bash .github/scripts/generate-upload-instructions-release.sh
echo "🚀 **AUTOMATED RELEASE DEPLOYMENT COMPLETE!**"
echo ""
echo "📦 **Release Details:**"
echo " - Theme: Hello Elementor v${{ env.PACKAGE_VERSION }}"
echo " - GitHub Release: ${{ env.RELEASE_URL }}"
echo " - Build Package: ${{ env.BUILD_ZIP_PATH }}"
if [ "${{ inputs.deploy_to_wporg }}" == "true" ] && [ "${{ env.AUTO_DEPLOY_ENABLED }}" == "true" ]; then
echo " - WordPress.org: ✅ Automatically deployed"
echo " - Theme Directory: https://wordpress.org/themes/${{ env.CONFIG_THEME_SLUG }}/"
echo " - Manual upload: ❌ No longer required!"
elif [ "${{ inputs.deploy_to_wporg }}" == "false" ]; then
echo " - WordPress.org: ⚠️ Skipped (deploy_to_wporg: false)"
else
echo " - WordPress.org: ⚠️ Disabled in config"
fi
echo ""
echo "✅ **Next Steps:**"
if [ "${{ inputs.deploy_to_wporg }}" == "true" ] && [ "${{ env.AUTO_DEPLOY_ENABLED }}" == "true" ]; then
echo " - Monitor WordPress.org theme directory (15-60 minutes)"
echo " - Test theme installation from WordPress admin"
fi
echo " - Update documentation and announce release"
echo " - Celebrate the automated deployment! 🎊"
fi
# Error recovery: restore repository to clean state on any workflow failure
# Design principle: always return to original branch state for consistency
# This prevents partial updates and ensures repository remains in sync with branch
# Error recovery
- name: Cleanup on Error
if: ${{ always() && !inputs.dry_run && failure() }}
run: |
echo "🧹 Workflow failed - restoring to original state..."
# Restore all version-bumped files to their original branch state
# This maintains consistency between working directory and remote branch
if ! git diff --quiet; then
echo "⚠️ Found modified files, restoring original versions..."
# Restore specific files that were version-bumped earlier in workflow
git checkout -- package.json functions.php style.css readme.txt 2>/dev/null || true
git checkout -- assets/scss/style.scss 2>/dev/null || true
echo "✅ Files restored to original state"
else
echo "ℹ️ Working directory already clean"
fi
# Remove temporary files generated during workflow execution
rm -f temp-changelog-from-readme.txt 2>/dev/null || true
rm -f *.bak 2>/dev/null || true
echo "🔍 Final state check:"
git status --porcelain || true
Loading