From 6ec26fe9dc5b288eb50e2f63d2984178277b4e9b Mon Sep 17 00:00:00 2001 From: Netanel Baba Date: Wed, 19 Aug 2026 15:24:36 +0300 Subject: [PATCH 1/4] ci: Consolidate Hello theme release into Deploy workflow Make deploy.yml the single stable release entry point with input-driven semver validation, version bumps, build, force-with-lease push to main, GitHub release, WordPress.org SVN publish, and Slack notification. Co-authored-by: Cursor --- .../actions/build-theme-release/action.yml | 72 ----- .../bump-theme-version-release/action.yml | 164 ------------ .../action.yml | 52 ---- .../create-theme-release-release/action.yml | 68 ----- .../action.yml | 33 --- .../install-dependencies-release/action.yml | 49 ---- .../action.yml | 248 ------------------ .github/scripts/commit-push-bump.sh | 13 - .../scripts/commit-push-release-to-main.sh | 20 ++ .github/scripts/create-git-tag.sh | 14 - .../generate-upload-instructions-release.sh | 69 ----- .../get-changelog-from-readme-release.js | 88 ------- .github/scripts/get-release-branch-name.sh | 14 - .github/scripts/sync-branches.sh | 19 -- .../scripts/update-prerelease-beta-version.js | 35 --- .github/scripts/update-version-in-files.js | 4 +- .github/scripts/validate-release-version.sh | 36 +++ .github/workflows/deploy.yml | 134 ++++++---- .github/workflows/permissions/action.yml | 31 +++ .github/workflows/publish-beta.yml | 102 ------- .github/workflows/publish-patch.yml | 107 -------- .github/workflows/publish-release.yml | 133 ---------- 22 files changed, 176 insertions(+), 1329 deletions(-) delete mode 100644 .github/actions/build-theme-release/action.yml delete mode 100644 .github/actions/bump-theme-version-release/action.yml delete mode 100644 .github/actions/create-pr-with-bumped-theme-version-release/action.yml delete mode 100644 .github/actions/create-theme-release-release/action.yml delete mode 100644 .github/actions/get-changelog-from-readme-release/action.yml delete mode 100644 .github/actions/install-dependencies-release/action.yml delete mode 100644 .github/actions/update-main-branch-version-release/action.yml delete mode 100755 .github/scripts/commit-push-bump.sh create mode 100755 .github/scripts/commit-push-release-to-main.sh delete mode 100755 .github/scripts/create-git-tag.sh delete mode 100755 .github/scripts/generate-upload-instructions-release.sh delete mode 100644 .github/scripts/get-changelog-from-readme-release.js delete mode 100755 .github/scripts/get-release-branch-name.sh delete mode 100755 .github/scripts/sync-branches.sh delete mode 100644 .github/scripts/update-prerelease-beta-version.js create mode 100755 .github/scripts/validate-release-version.sh create mode 100644 .github/workflows/permissions/action.yml delete mode 100644 .github/workflows/publish-beta.yml delete mode 100644 .github/workflows/publish-patch.yml delete mode 100644 .github/workflows/publish-release.yml diff --git a/.github/actions/build-theme-release/action.yml b/.github/actions/build-theme-release/action.yml deleted file mode 100644 index 46e2553a..00000000 --- a/.github/actions/build-theme-release/action.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: 'Build Theme (Release)' -description: 'Build Hello Elementor theme with specified version using Hello Commerce approach' - -inputs: - PACKAGE_VERSION: - description: 'The package version to build (e.g. 3.4.4)' - required: true - BUILD_SCRIPT_PATH: - description: 'Path to build script' - required: false - default: "npm run package:zip" - -runs: - using: "composite" - steps: - - name: Install npm dependencies - shell: bash - run: | - export PUPPETEER_SKIP_DOWNLOAD=true - export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 - npm ci - - - name: Install composer dependencies - shell: bash - run: | - composer install --no-dev --no-scripts --optimize-autoloader - - - name: Set package version - shell: bash - env: - PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }} - run: | - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - echo "Building Hello Elementor theme version: ${PACKAGE_VERSION}" - - - name: Build theme - shell: bash - run: | - if [[ "${{ inputs.BUILD_SCRIPT_PATH }}" == npm* ]]; then - ${{ inputs.BUILD_SCRIPT_PATH }} - else - bash "${{ inputs.BUILD_SCRIPT_PATH }}" - fi - - - name: Set build directory and zip paths - shell: bash - env: - PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }} - run: | - set -e - BUILD_DIR="hello-elementor" - BUILD_ZIP_PATH="hello-elementor.${PACKAGE_VERSION}.zip" - - echo "Setting build paths:" - echo " BUILD_DIR: ${BUILD_DIR}" - echo " BUILD_ZIP_PATH: ${BUILD_ZIP_PATH}" - echo " PACKAGE_VERSION: ${PACKAGE_VERSION}" - - if [ ! -d "$BUILD_DIR" ]; then - echo "❌ Build directory not found: $BUILD_DIR" - echo "Available directories:" - ls -la | head -20 - exit 1 - fi - - echo "✅ Build directory found: $BUILD_DIR" - echo "✅ Zip file: $BUILD_ZIP_PATH" - - echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV - echo "BUILD_ZIP_PATH=${BUILD_ZIP_PATH}" >> $GITHUB_ENV - - echo "✅ Environment variables set in GITHUB_ENV" diff --git a/.github/actions/bump-theme-version-release/action.yml b/.github/actions/bump-theme-version-release/action.yml deleted file mode 100644 index a39f70ea..00000000 --- a/.github/actions/bump-theme-version-release/action.yml +++ /dev/null @@ -1,164 +0,0 @@ -name: 'Bump Theme Version (Release)' -description: 'Updates version across all Hello Elementor theme files including SCSS' - -inputs: - CLEAN_PACKAGE_VERSION: - required: true - description: 'Current clean version (without v prefix)' - VERSION_TYPE: - required: true - description: 'Version bump type (current|patch|minor|major)' - -runs: - using: 'composite' - steps: - - name: Calculate new version - shell: bash - run: | - CURRENT_VERSION="${{ inputs.CLEAN_PACKAGE_VERSION }}" - IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" - - case "${{ inputs.VERSION_TYPE }}" in - "current") - # Keep version as-is for first release - NEW_VERSION="$CURRENT_VERSION" - ;; - "major") - NEW_MAJOR=$((MAJOR + 1)) - NEW_VERSION="$NEW_MAJOR.0.0" - ;; - "minor") - NEW_MINOR=$((MINOR + 1)) - NEW_VERSION="$MAJOR.$NEW_MINOR.0" - ;; - "patch") - NEW_PATCH=$((PATCH + 1)) - NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" - ;; - esac - - echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV - echo "Version will be: $CURRENT_VERSION → $NEW_VERSION" - - - name: Update functions.php version - shell: bash - run: | - sed -i.bak "s/define( 'HELLO_ELEMENTOR_VERSION', '[^']*' );/define( 'HELLO_ELEMENTOR_VERSION', '$NEW_VERSION' );/" functions.php - rm functions.php.bak - # Verify functions.php was actually updated - if ! grep -q "HELLO_ELEMENTOR_VERSION.*$NEW_VERSION" functions.php; then - echo "Error: Failed to update version in functions.php" - exit 1 - fi - echo "✅ Updated functions.php HELLO_ELEMENTOR_VERSION to $NEW_VERSION" - - - name: Update package.json version - shell: bash - run: | - if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then - echo "Version unchanged ($CURRENT_VERSION), skipping npm version bump." - else - npm version --no-git-tag-version $NEW_VERSION - fi - - - name: Update style.css version - shell: bash - run: | - sed -i.bak "s/Version: .*/Version: $NEW_VERSION/" style.css - rm style.css.bak - # Verify style.css was actually updated - if ! grep -q "Version: $NEW_VERSION" style.css; then - echo "Error: Failed to update version in style.css" - echo "Current content:" - grep -A2 -B2 "Version:" style.css || echo "No Version: field found" - exit 1 - fi - echo "✅ Updated style.css Version to $NEW_VERSION" - - - name: Update assets/scss/style.scss version (Hello Theme specific) - shell: bash - run: | - if [ -f "assets/scss/style.scss" ]; then - sed -i.bak -e "s/Version: .*/Version: $NEW_VERSION/" -e "s/Stable tag: .*/Stable tag: $NEW_VERSION/" assets/scss/style.scss - rm assets/scss/style.scss.bak - - # Verify that SCSS file was updated - VALIDATION_PASSED=true - - # Check Version field - if grep -q "Version:" assets/scss/style.scss; then - if ! grep -q "Version: $NEW_VERSION" assets/scss/style.scss; then - echo "Error: Failed to update Version in assets/scss/style.scss" - VALIDATION_PASSED=false - else - echo "✅ Updated assets/scss/style.scss Version to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Version:' field found in assets/scss/style.scss" - fi - - # Check Stable tag field - if grep -q "Stable tag:" assets/scss/style.scss; then - if ! grep -q "Stable tag: $NEW_VERSION" assets/scss/style.scss; then - echo "Error: Failed to update Stable tag in assets/scss/style.scss" - VALIDATION_PASSED=false - else - echo "✅ Updated assets/scss/style.scss Stable tag to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Stable tag:' field found in assets/scss/style.scss" - fi - - if [ "$VALIDATION_PASSED" = "false" ]; then - echo "❌ assets/scss/style.scss version update failed" - exit 1 - fi - else - echo "ℹ️ No assets/scss/style.scss file found, skipping SCSS version update" - fi - - - name: Update readme.txt stable tag and version - shell: bash - run: | - # Update fields that exist in the file - sed -i.bak -e "s/^Stable tag: .*/Stable tag: $NEW_VERSION/" -e "s/^Version: .*/Version: $NEW_VERSION/" readme.txt - rm readme.txt.bak - - # Verify that fields were updated (check each field independently) - VALIDATION_PASSED=true - - # Check if Stable tag field exists and was updated - if grep -q "^Stable tag:" readme.txt; then - if ! grep -q "^Stable tag: $NEW_VERSION" readme.txt; then - echo "Error: Found 'Stable tag:' field but failed to update it to $NEW_VERSION" - VALIDATION_PASSED=false - else - echo "✅ Updated readme.txt Stable tag to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Stable tag:' field found in readme.txt" - fi - - # Check if Version field exists and was updated - if grep -q "^Version:" readme.txt; then - if ! grep -q "^Version: $NEW_VERSION" readme.txt; then - echo "Error: Found 'Version:' field but failed to update it to $NEW_VERSION" - VALIDATION_PASSED=false - else - echo "✅ Updated readme.txt Version to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Version:' field found in readme.txt" - fi - - if [ "$VALIDATION_PASSED" = "false" ]; then - echo "❌ readme.txt version update failed" - exit 1 - fi - - echo "✅ readme.txt version update completed successfully" - - - name: Set PACKAGE_VERSION from NEW_VERSION - shell: bash - run: echo "PACKAGE_VERSION=$NEW_VERSION" >> $GITHUB_ENV diff --git a/.github/actions/create-pr-with-bumped-theme-version-release/action.yml b/.github/actions/create-pr-with-bumped-theme-version-release/action.yml deleted file mode 100644 index 1c10bc8a..00000000 --- a/.github/actions/create-pr-with-bumped-theme-version-release/action.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: 'Create PR With Bumped Theme Version (Release)' -description: 'Creates a pull request with the bumped Hello Elementor theme version' - -inputs: - base_branch: - required: true - description: 'The base branch for the PR' - package_version: - required: true - description: 'The new package version' - token: - required: true - description: 'GitHub token for authentication' - -runs: - using: 'composite' - steps: - - name: Configure Git - shell: bash - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ inputs.token }} - commit-message: "chore: bump Hello Elementor version to v${{ inputs.package_version }}" - branch: release/v${{ inputs.package_version }} - title: "Release Hello Elementor v${{ inputs.package_version }}" - body: | - ## 🚀 Hello Elementor Release v${{ inputs.package_version }} - - This automated PR bumps the Hello Elementor theme version for release. - - ### Changes: - - Updated version in `package.json` - - Updated version in `functions.php` - - Updated version in `style.css` - - Updated version in `readme.txt` - - ### Release: - - GitHub release: https://github.com/elementor/hello-theme/releases/tag/v${{ inputs.package_version }} - - Ready for review and merge! 🎉 - base: ${{ inputs.base_branch }} - add-paths: | - package.json - package-lock.json - functions.php - style.css - readme.txt diff --git a/.github/actions/create-theme-release-release/action.yml b/.github/actions/create-theme-release-release/action.yml deleted file mode 100644 index dd70aae7..00000000 --- a/.github/actions/create-theme-release-release/action.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: 'Create Theme Release (Release)' -description: 'Create GitHub release for Hello Elementor theme' -inputs: - PACKAGE_VERSION: - required: true - description: 'Release version' - BUILD_ZIP_PATH: - required: true - description: 'Path to theme zip file' - CHANGELOG_FILE: - required: true - description: 'Path to changelog file' - PRE_RELEASE: - required: false - default: 'false' - description: 'Is this a pre-release?' - GITHUB_TOKEN: - required: true - description: 'GitHub token for creating releases' - -outputs: - RELEASE_URL: - description: 'URL of the created GitHub release' - value: ${{ steps.create-release.outputs.html_url }} - -runs: - using: 'composite' - steps: - - name: Verify files exist - shell: bash - run: | - if [ ! -f "${{ inputs.BUILD_ZIP_PATH }}" ]; then - echo "Error: Build zip file not found: ${{ inputs.BUILD_ZIP_PATH }}" - exit 1 - fi - - if [ ! -f "${{ inputs.CHANGELOG_FILE }}" ]; then - echo "Error: Changelog file not found: ${{ inputs.CHANGELOG_FILE }}" - exit 1 - fi - - echo "✅ Build zip: ${{ inputs.BUILD_ZIP_PATH }}" - echo "✅ Changelog: ${{ inputs.CHANGELOG_FILE }}" - - - name: Create GitHub release - id: create-release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ inputs.PACKAGE_VERSION }} - name: Hello Elementor v${{ inputs.PACKAGE_VERSION }} - files: | - ${{ inputs.BUILD_ZIP_PATH }} - ${{ inputs.CHANGELOG_FILE }} - body_path: ${{ inputs.CHANGELOG_FILE }} - prerelease: ${{ inputs.PRE_RELEASE }} - token: ${{ inputs.GITHUB_TOKEN }} - generate_release_notes: false - - - name: Release summary - shell: bash - run: | - echo "🚀 **Release Created Successfully!**" - echo "📋 **Release Details:**" - echo " - Version: v${{ inputs.PACKAGE_VERSION }}" - echo " - Pre-release: ${{ inputs.PRE_RELEASE }}" - echo " - Build file: ${{ inputs.BUILD_ZIP_PATH }}" - echo " - Release URL: ${{ steps.create-release.outputs.html_url }}" - echo "RELEASE_URL=${{ steps.create-release.outputs.html_url }}" >> $GITHUB_ENV diff --git a/.github/actions/get-changelog-from-readme-release/action.yml b/.github/actions/get-changelog-from-readme-release/action.yml deleted file mode 100644 index fd912cc4..00000000 --- a/.github/actions/get-changelog-from-readme-release/action.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: 'Get changelog from readme.txt (Release)' -description: 'Get changelog from readme.txt file - Hello Elementor release validation' - -inputs: - VERSION: - description: 'Theme Version' - required: true - -outputs: - CHANGELOG_FILE: - description: 'Path to the extracted changelog file' - value: temp-changelog-from-readme.txt - -runs: - using: "composite" - steps: - - name: Extract changelog from readme.txt - shell: bash - env: - VERSION: ${{ inputs.VERSION }} - run: | - node ./.github/scripts/get-changelog-from-readme-release.js - - - name: Verify changelog file - shell: bash - run: | - if [ ! -f "temp-changelog-from-readme.txt" ]; then - echo "Error: Failed to create changelog file" - exit 1 - fi - - echo "✅ Changelog extracted successfully for version ${{ inputs.VERSION }}" - echo "CHANGELOG_FILE=temp-changelog-from-readme.txt" >> $GITHUB_ENV diff --git a/.github/actions/install-dependencies-release/action.yml b/.github/actions/install-dependencies-release/action.yml deleted file mode 100644 index b92df46b..00000000 --- a/.github/actions/install-dependencies-release/action.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: 'Install Dependencies for Hello Elementor (Release)' -description: 'Install PHP, Composer, and npm dependencies for release workflow' -inputs: - DEVOPS_TOKEN: - description: 'GitHub token for Composer authentication' - required: true - CLOUD_DEVOPS_TOKEN: - description: 'npm registry access token' - required: true -runs: - using: 'composite' - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - - - name: OAuth Composer Authentication - shell: bash - run: composer config -g github-oauth.github.com ${{ inputs.DEVOPS_TOKEN }} - - - name: Install Composer dependencies (cache) - uses: ramsey/composer-install@v2 - with: - custom-cache-key: cache-${{ hashFiles('composer.lock') }} - - - name: Install Composer dependencies (production) - shell: bash - run: composer install --no-dev - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - registry-url: 'https://npm.pkg.github.com' - scope: '@elementor' - cache: 'npm' - - - name: Install npm dependencies - shell: bash - run: | - if npm ci; then - echo "✅ npm ci succeeded" - else - echo "⚠️ npm ci failed, falling back to npm install --legacy-peer-deps" - npm install --legacy-peer-deps - fi - env: - NODE_AUTH_TOKEN: ${{ inputs.CLOUD_DEVOPS_TOKEN }} diff --git a/.github/actions/update-main-branch-version-release/action.yml b/.github/actions/update-main-branch-version-release/action.yml deleted file mode 100644 index 743063a4..00000000 --- a/.github/actions/update-main-branch-version-release/action.yml +++ /dev/null @@ -1,248 +0,0 @@ -name: 'Update Main Branch Version (Release)' -description: 'Updates main branch version only if new version is greater than current main version (Hello Elementor)' - -inputs: - new_version: - required: true - description: 'The new version to potentially update to' - token: - required: true - description: 'GitHub token for authentication' - -runs: - using: 'composite' - steps: - - name: Auto-detect default branch - shell: bash - run: | - # Auto-detect the default branch (supports both 'master' and 'main') - DEFAULT_BRANCH="" - - # Check if main exists, then master, then fallback - if git ls-remote --heads origin main | grep -q "refs/heads/main"; then - DEFAULT_BRANCH="main" - elif git ls-remote --heads origin master | grep -q "refs/heads/master"; then - DEFAULT_BRANCH="main" - else - # Use git symbolic-ref to get the actual default branch - DEFAULT_BRANCH=$(git ls-remote --symref origin HEAD | head -n1 | cut -d$'\t' -f2 | sed 's|refs/heads/||') - if [ -z "$DEFAULT_BRANCH" ]; then - echo "Error: Could not determine default branch" - exit 1 - fi - fi - - echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV - echo "Detected default branch: $DEFAULT_BRANCH" - - - name: Get current default branch version - shell: bash - run: | - DEFAULT_BRANCH="${{ env.DEFAULT_BRANCH }}" - - # Extract package.json first, then parse it with proper error checking - git show "origin/$DEFAULT_BRANCH:package.json" > /tmp/package_temp.json 2>/dev/null || { - echo "Error: Could not extract package.json from $DEFAULT_BRANCH branch" - echo "This is expected if the branch doesn't exist or package.json is missing" - exit 1 - } - - # Parse the JSON file with proper error handling - if ! DEFAULT_BRANCH_VERSION=$(node -p "JSON.parse(require('fs').readFileSync('/tmp/package_temp.json', 'utf8')).version" 2>/dev/null); then - echo "Error: Could not parse version from $DEFAULT_BRANCH branch package.json" - echo "The file exists but JSON parsing failed" - rm -f /tmp/package_temp.json - exit 1 - fi - - # Clean up temporary file - rm -f /tmp/package_temp.json - - echo "DEFAULT_BRANCH_VERSION=$DEFAULT_BRANCH_VERSION" >> $GITHUB_ENV - echo "Current $DEFAULT_BRANCH version: $DEFAULT_BRANCH_VERSION" - - - name: Compare versions (simple numeric comparison) - shell: bash - run: | - NEW_VERSION="${{ inputs.new_version }}" - DEFAULT_BRANCH_VERSION="${{ env.DEFAULT_BRANCH_VERSION }}" - - # Simple version comparison for numeric versions (e.g., 1.2.3) - # Note: This project only uses numeric releases, so we keep this simple - # If comparison fails, we exit early (fail-safe approach) - version_compare() { - local v1="$1" - local v2="$2" - - # Parse version numbers (assumes X.Y.Z format) - IFS='.' read -r v1_major v1_minor v1_patch <<< "$v1" - IFS='.' read -r v2_major v2_minor v2_patch <<< "$v2" - - # Set defaults and validate numeric - v1_major=${v1_major:-0} - v1_minor=${v1_minor:-0} - v1_patch=${v1_patch:-0} - v2_major=${v2_major:-0} - v2_minor=${v2_minor:-0} - v2_patch=${v2_patch:-0} - - # Simple numeric comparison - if [ "$v1_major" -gt "$v2_major" ]; then return 0; fi - if [ "$v1_major" -lt "$v2_major" ]; then return 1; fi - if [ "$v1_minor" -gt "$v2_minor" ]; then return 0; fi - if [ "$v1_minor" -lt "$v2_minor" ]; then return 1; fi - if [ "$v1_patch" -gt "$v2_patch" ]; then return 0; fi - return 1 - } - - if version_compare "$NEW_VERSION" "$DEFAULT_BRANCH_VERSION"; then - echo "✅ New version ($NEW_VERSION) > Default branch version ($DEFAULT_BRANCH_VERSION)" - echo "SHOULD_UPDATE=true" >> $GITHUB_ENV - else - echo "⏭️ New version ($NEW_VERSION) <= Default branch version ($DEFAULT_BRANCH_VERSION)" - echo "Skipping default branch update to preserve higher version" - echo "SHOULD_UPDATE=false" >> $GITHUB_ENV - fi - - - name: Create safe branch name - if: env.SHOULD_UPDATE == 'true' - shell: bash - run: | - NEW_VERSION="${{ inputs.new_version }}" - DEFAULT_BRANCH="${{ env.DEFAULT_BRANCH }}" - - # Sanitize version for branch name - # Note: This project only uses numeric versions (e.g., 1.2.3) so minimal sanitization needed - SAFE_VERSION=$(echo "$NEW_VERSION" | sed 's/[^a-zA-Z0-9.-]/-/g') - echo "BRANCH_NAME=update-$DEFAULT_BRANCH-to-v$SAFE_VERSION" >> $GITHUB_ENV - - - name: Extract and update files from default branch - if: env.SHOULD_UPDATE == 'true' - shell: bash - run: | - NEW_VERSION="${{ inputs.new_version }}" - DEFAULT_BRANCH="${{ env.DEFAULT_BRANCH }}" - - # Simple approach: Extract files directly, fail if any step fails - # Since PRs are manually reviewed, we don't need complex error handling - - # Extract package.json and update version - git show "origin/$DEFAULT_BRANCH:package.json" > package.json || exit 1 - node -e " - const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); - pkg.version = '$NEW_VERSION'; - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); - " || exit 1 - - # Extract and update functions.php (Hello Elementor specific) - git show "origin/$DEFAULT_BRANCH:functions.php" > functions.php || exit 1 - sed -i.bak "s/define( 'HELLO_ELEMENTOR_VERSION', '[^']*' );/define( 'HELLO_ELEMENTOR_VERSION', '$NEW_VERSION' );/" functions.php || exit 1 - rm -f functions.php.bak - # Verify functions.php was actually updated - if ! grep -q "HELLO_ELEMENTOR_VERSION.*$NEW_VERSION" functions.php; then - echo "Error: Failed to update version in functions.php" - exit 1 - fi - - # Extract and update style.css - git show "origin/$DEFAULT_BRANCH:style.css" > style.css || exit 1 - sed -i.bak "s/Version: .*/Version: $NEW_VERSION/" style.css || exit 1 - rm -f style.css.bak - # Verify style.css was actually updated - if ! grep -q "Version: $NEW_VERSION" style.css; then - echo "Error: Failed to update version in style.css" - exit 1 - fi - - # Extract and update assets/scss/style.scss if it exists (Hello Theme specific) - if git show "origin/$DEFAULT_BRANCH:assets/scss/style.scss" > assets/scss/style.scss 2>/dev/null; then - mkdir -p assets/scss - sed -i.bak -e "s/Version: .*/Version: $NEW_VERSION/" -e "s/Stable tag: .*/Stable tag: $NEW_VERSION/" assets/scss/style.scss || exit 1 - rm -f assets/scss/style.scss.bak - echo "✅ Updated assets/scss/style.scss" - else - echo "ℹ️ No assets/scss/style.scss found in $DEFAULT_BRANCH branch" - fi - - # Extract and update readme.txt - git show "origin/$DEFAULT_BRANCH:readme.txt" > readme.txt || exit 1 - # Update fields that exist in the file - sed -i.bak -e "s/^Stable tag: .*/Stable tag: $NEW_VERSION/" -e "s/^Version: .*/Version: $NEW_VERSION/" readme.txt || exit 1 - rm -f readme.txt.bak - - # Verify that fields were updated (check each field independently) - VALIDATION_PASSED=true - - # Check if Stable tag field exists and was updated - if grep -q "^Stable tag:" readme.txt; then - if ! grep -q "^Stable tag: $NEW_VERSION" readme.txt; then - echo "Error: Found 'Stable tag:' field but failed to update it to $NEW_VERSION" - VALIDATION_PASSED=false - else - echo "✅ Updated Stable tag to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Stable tag:' field found in readme.txt" - fi - - # Check if Version field exists and was updated - if grep -q "^Version:" readme.txt; then - if ! grep -q "^Version: $NEW_VERSION" readme.txt; then - echo "Error: Found 'Version:' field but failed to update it to $NEW_VERSION" - VALIDATION_PASSED=false - else - echo "✅ Updated Version to $NEW_VERSION" - fi - else - echo "ℹ️ No 'Version:' field found in readme.txt" - fi - - if [ "$VALIDATION_PASSED" = "false" ]; then - echo "❌ readme.txt version update failed" - exit 1 - fi - - echo "✅ readme.txt version update completed successfully" - - # Generate package-lock.json - npm install --package-lock-only || { - echo "Warning: npm install failed, continuing without package-lock.json update" - echo "This may be due to network issues, registry timeouts, or dependency conflicts" - echo "The version update will proceed without regenerating package-lock.json" - } - - echo "Successfully updated all files" - - - name: Create pull request - if: env.SHOULD_UPDATE == 'true' - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ inputs.token }} - commit-message: "chore: update ${{ env.DEFAULT_BRANCH }} version to v${{ inputs.new_version }}" - branch: ${{ env.BRANCH_NAME }} - title: "Update ${{ env.DEFAULT_BRANCH }} version to v${{ inputs.new_version }}" - body: | - Update ${{ env.DEFAULT_BRANCH }} branch version to v${{ inputs.new_version }} - - **Version Update:** - - New version: v${{ inputs.new_version }} - - Previous ${{ env.DEFAULT_BRANCH }} version: v${{ env.DEFAULT_BRANCH_VERSION }} - - **Files updated:** - - package.json - - functions.php (HELLO_ELEMENTOR_VERSION) - - style.css - - readme.txt - - assets/scss/style.scss (if exists) - - package-lock.json - - Auto-generated by Hello Elementor release preparation workflow. - **Please review manually before merging.** - base: ${{ env.DEFAULT_BRANCH }} - add-paths: | - package.json - package-lock.json - functions.php - style.css - readme.txt diff --git a/.github/scripts/commit-push-bump.sh b/.github/scripts/commit-push-bump.sh deleted file mode 100755 index 973062ba..00000000 --- a/.github/scripts/commit-push-bump.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -eo pipefail - -if [[ -z "$PACKAGE_VERSION" ]]; then - echo "Missing PACKAGE_VERSION env var" - exit 1 -fi - -bash "${GITHUB_WORKSPACE}/.github/scripts/set-git-user.sh" - -echo "Commit and push bump version ${PACKAGE_VERSION}" -git commit -am "Bump ${PACKAGE_VERSION}" -git push diff --git a/.github/scripts/commit-push-release-to-main.sh b/.github/scripts/commit-push-release-to-main.sh new file mode 100755 index 00000000..a8d92954 --- /dev/null +++ b/.github/scripts/commit-push-release-to-main.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -eo pipefail + +if [[ -z "$PACKAGE_VERSION" ]]; then + echo "::error::PACKAGE_VERSION env var is required" + exit 1 +fi + +if [[ -z "$MAIN_LEASE_SHA" ]]; then + echo "::error::MAIN_LEASE_SHA env var is required" + exit 1 +fi + +bash "${GITHUB_WORKSPACE}/.github/scripts/set-git-user.sh" + +git add package.json package-lock.json functions.php readme.txt style.css + +git commit -m "Release ${PACKAGE_VERSION}" + +git push --force-with-lease=refs/heads/main:${MAIN_LEASE_SHA} origin main diff --git a/.github/scripts/create-git-tag.sh b/.github/scripts/create-git-tag.sh deleted file mode 100755 index 3d7e2cd5..00000000 --- a/.github/scripts/create-git-tag.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [[ -z "$PACKAGE_VERSION" ]]; then - echo "Missing PACKAGE_VERSION env var" - exit 1 -fi - -bash "${GITHUB_WORKSPACE}/.github/scripts/set-git-user.sh" - -echo "Create tag v${PACKAGE_VERSION}" -git tag "v${PACKAGE_VERSION}" -if [ $? -eq 0 ]; then - git push origin "v${PACKAGE_VERSION}" -fi diff --git a/.github/scripts/generate-upload-instructions-release.sh b/.github/scripts/generate-upload-instructions-release.sh deleted file mode 100755 index 252b9125..00000000 --- a/.github/scripts/generate-upload-instructions-release.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# generate-upload-instructions-release.sh - Generate manual upload instructions for Hello Elementor theme - -set -e - -# Get current version -PACKAGE_VERSION=$(node -p "require('./package.json').version") -# Use hardcoded hello-theme prefix for GitHub releases (different from package.json name) -BUILD_ZIP="hello-theme-${PACKAGE_VERSION}.zip" - -echo "📋 **Hello Elementor v${PACKAGE_VERSION} - Manual Upload Instructions**" -echo "" -echo "===================================================================" -echo "🚀 RELEASE PREPARATION COMPLETE!" -echo "===================================================================" -echo "" -echo "📦 **Package Details:**" -echo " - Theme: Hello Elementor" -echo " - Version: v${PACKAGE_VERSION}" -echo " - Build File: ${BUILD_ZIP}" -echo " - GitHub Package: ${BUILD_ZIP}" -echo "" -echo "📋 **Manual Upload Steps:**" -echo "" -echo "1. **Download Release Package:**" -echo " - Go to GitHub Releases page" -echo " - Download: ${BUILD_ZIP}" -echo " - Verify file integrity and size" -echo "" -echo "2. **WordPress.org Upload:**" -echo " - Log into WordPress.org developer account" -echo " - Navigate to Hello Elementor theme page" -echo " - Upload the ${BUILD_ZIP} file" -echo " - Update theme description and changelog" -echo "" -echo "3. **Update Theme Repository:**" -echo " - Update theme directory README" -echo " - Verify theme screenshots and assets" -echo " - Update theme tags and compatibility" -echo "" -echo "4. **Post-Release Tasks:**" -echo " - Test theme installation from WordPress.org" -echo " - Update documentation and support materials" -echo " - Announce release on social media and forums" -echo " - Monitor for user feedback and issues" -echo "" -echo "⚠️ **Important Notes:**" -echo " - WordPress.org themes cannot be auto-published" -echo " - Manual review may be required by WordPress.org team" -echo " - Allow 24-48 hours for theme directory updates" -echo " - Keep GitHub release as backup distribution method" -echo "" -echo "✅ **Verification Checklist:**" -echo " □ Package downloaded successfully" -echo " □ Theme uploaded to WordPress.org" -echo " □ Theme description updated" -echo " □ Changelog entries correct" -echo " □ Theme tags and compatibility updated" -echo " □ Installation tested from WordPress.org" -echo " □ Release announced on appropriate channels" -echo "" -echo "🔗 **Quick Links:**" -echo " - GitHub Release: https://github.com/elementor/hello-theme/releases/tag/v${PACKAGE_VERSION}" -echo " - WordPress.org: https://wordpress.org/themes/hello-elementor/" -echo "" -echo "===================================================================" -echo "For questions or issues, contact the development team." -echo "===================================================================" diff --git a/.github/scripts/get-changelog-from-readme-release.js b/.github/scripts/get-changelog-from-readme-release.js deleted file mode 100644 index 4771dc4e..00000000 --- a/.github/scripts/get-changelog-from-readme-release.js +++ /dev/null @@ -1,88 +0,0 @@ -/* eslint-disable no-console */ -'use strict'; - -// get-changelog-from-readme-release.js - Extract changelog from readme.txt for Hello Elementor releases - -const fs = require( 'fs' ); -const { VERSION } = process.env; - -if ( ! VERSION ) { - console.error( 'missing VERSION env var' ); - process.exit( 1 ); -} - -// Try to load marked, fallback to simple parsing if not available -let marked; -try { - marked = require( 'marked' ); -} catch ( error ) { - console.log( 'marked not available, using simple parsing' ); - marked = null; -} - -// Simple changelog parser fallback -function simpleParseChangelog( content, version ) { - const lines = content.split( '\n' ); - let inChangelog = false; - let foundVersion = false; - const changelog = []; - - for ( const line of lines ) { - if ( line.includes( '== Changelog ==' ) ) { - inChangelog = true; - continue; - } - - if ( inChangelog ) { - if ( line.includes( `= ${ version } -` ) ) { - foundVersion = true; - changelog.push( line ); - continue; - } - - if ( foundVersion ) { - if ( line.startsWith( '=' ) && line.includes( '-' ) ) { - // Found next version, stop - break; - } - if ( line.trim() ) { - changelog.push( line ); - } - } - } - } - - return foundVersion ? changelog.join( '\n' ) : null; -} - -// Main execution -const readmeContent = fs.readFileSync( 'readme.txt', 'utf8' ); - -let changelog; -if ( marked ) { - // Use marked parser (original logic would go here) - console.log( 'Using marked parser' ); - // For now, fallback to simple parser even with marked - changelog = simpleParseChangelog( readmeContent, VERSION ); -} else { - // Use simple parser - changelog = simpleParseChangelog( readmeContent, VERSION ); -} - -if ( ! changelog ) { - console.error( `❌ Changelog for version ${ VERSION } is missing` ); - process.exit( 1 ); // Always fail if version is missing -} - -// Write changelog to temp file only if it exists -const changelogFile = 'temp-changelog-from-readme.txt'; -if ( changelog ) { - fs.writeFileSync( changelogFile, changelog ); -} else { - fs.writeFileSync( changelogFile, '' ); -} - -if ( changelog ) { - console.log( `✅ Successfully extracted Hello Elementor changelog for version ${ VERSION }` ); - console.log( `Changelog saved to: ${ changelogFile }` ); -} diff --git a/.github/scripts/get-release-branch-name.sh b/.github/scripts/get-release-branch-name.sh deleted file mode 100755 index 61ad1182..00000000 --- a/.github/scripts/get-release-branch-name.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -eo pipefail - -if [ -z "$INPUT_VERSION" ]; -then - PACKAGE_VERSION=$(node -p "require('./package.json').version") - npm install --no-package-lock --no-save semver@7.3.4 - NEXT_PACKAGE_VERSION=$(npx semver $PACKAGE_VERSION -i minor) - RELEASE_BRANCH="release/${NEXT_PACKAGE_VERSION}" -else - echo "Version var is set to ${INPUT_VERSION}" - RELEASE_BRANCH="release/${INPUT_VERSION}" -fi -echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV diff --git a/.github/scripts/sync-branches.sh b/.github/scripts/sync-branches.sh deleted file mode 100755 index b545eefb..00000000 --- a/.github/scripts/sync-branches.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -eo pipefail - -bash "${GITHUB_WORKSPACE}/.github/scripts/set-git-user.sh" - -npm i semver@7.3.4 --no-package-lock --no-save -PACKAGE_VERSION=$(node -p "require('./package.json').version") -NEXT_PACKAGE_VERSION=$(npx semver $PACKAGE_VERSION -i minor) -NEXT_RELEASE_BRANCH="release/${NEXT_PACKAGE_VERSION}" - -# Merge main -> develop -git checkout develop -git merge origin/main -git push origin develop - -# Merge develop -> next release -git checkout "${NEXT_RELEASE_BRANCH}" -git merge origin/develop -git push origin "${NEXT_RELEASE_BRANCH}" diff --git a/.github/scripts/update-prerelease-beta-version.js b/.github/scripts/update-prerelease-beta-version.js deleted file mode 100644 index a6fda685..00000000 --- a/.github/scripts/update-prerelease-beta-version.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const semverInc = require( 'semver/functions/inc' ); -const packageJson = require( '../../package.json' ); -const fs = require( 'fs' ); - -const bumpVersion = (relativeVersion, lastVersionTagName, bumpsFromCurrentVersion = 1) => { - const lastVersion = packageJson[lastVersionTagName] || ''; - let expectedVersion = relativeVersion; - (new Array( bumpsFromCurrentVersion ).fill( 1 )).forEach(() => { - expectedVersion = semverInc( expectedVersion, 'minor' ); - }); - let currentLastVersionNumber = 0; - -if (lastVersion) { - const splitVersion = lastVersion.split( `-beta` ); - if (splitVersion[0] === expectedVersion) { - const currentLastVersion = splitVersion[splitVersion.length - 1]; - currentLastVersionNumber = Number( currentLastVersion ); - if (Number.isNaN( currentLastVersionNumber )) { - console.error( `invalid beta version: ${currentLastVersion}` ); - process.exit( 1 ); - return; - } - } -} - - const newVersion = `${expectedVersion}-beta${currentLastVersionNumber + 1}`; - packageJson[lastVersionTagName] = newVersion; - fs.writeFileSync( './package.json', JSON.stringify( packageJson, null, 4 ) ); - console.log( newVersion ); -} - -const relativeVersion = packageJson.version; -bumpVersion( relativeVersion, 'last_beta_version' ); diff --git a/.github/scripts/update-version-in-files.js b/.github/scripts/update-version-in-files.js index 9c14764c..13329681 100644 --- a/.github/scripts/update-version-in-files.js +++ b/.github/scripts/update-version-in-files.js @@ -12,13 +12,13 @@ const replaceInFileWithLog = async ( options ) => { const run = async () => { try { await replaceInFileWithLog( { - files: './assets/scss/style.scss', + files: './style.css', from: /Version:.*$/m, to: `Version: ${ VERSION }`, } ); await replaceInFileWithLog( { - files: './assets/scss/style.scss', + files: './style.css', from: /Stable tag:.*$/m, to: `Stable tag: ${ VERSION }`, } ); diff --git a/.github/scripts/validate-release-version.sh b/.github/scripts/validate-release-version.sh new file mode 100755 index 00000000..4f6e258b --- /dev/null +++ b/.github/scripts/validate-release-version.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -eo pipefail + +if [[ -z "$INPUT_VERSION" ]]; then + echo "::error::INPUT_VERSION env var is required" + exit 1 +fi + +if [[ ! "$INPUT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error::Version must be stable SemVer (X.Y.Z). Got: $INPUT_VERSION" + exit 1 +fi + +CURRENT_VERSION=$(node -p "require('./package.json').version") + +version_to_number() { + local version="$1" + local major minor patch + IFS='.' read -r major minor patch <<< "$version" + echo $((major * 1000000 + minor * 1000 + patch)) +} + +INPUT_NUM=$(version_to_number "$INPUT_VERSION") +CURRENT_NUM=$(version_to_number "$CURRENT_VERSION") + +if [ "$INPUT_NUM" -le "$CURRENT_NUM" ]; then + echo "::error::Input version ($INPUT_VERSION) must be greater than current version ($CURRENT_VERSION)" + exit 1 +fi + +if git rev-parse "refs/tags/v${INPUT_VERSION}" >/dev/null 2>&1; then + echo "::error::Tag v${INPUT_VERSION} already exists" + exit 1 +fi + +echo "Release version ${INPUT_VERSION} is valid (current: ${CURRENT_VERSION})" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 000fed46..1186f7d3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,85 +1,125 @@ name: Deploy permissions: - contents: read - actions: read + contents: write + +concurrency: + group: hello-theme-release + cancel-in-progress: false on: workflow_dispatch: inputs: version: - description: 'Write the Theme version that sis about to get released to Production WordPress.org SVN' + description: 'Stable SemVer version to release to Production WordPress.org SVN (e.g. 3.4.10)' required: true type: string jobs: - validate: + release: + if: startsWith(github.repository, 'elementor/') runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Test permissions + uses: ./.github/workflows/permissions + with: + ENVIRONMENT: prod + DEPLOYMENT_PERMITTED: ${{ vars.DEPLOYMENT_PERMITTED_USERS }} + DEPLOYMENT_REPOSITORY_OWNER: elementor + + - name: Checkout main uses: actions/checkout@v4 - - name: Validate branch name + with: + token: ${{ secrets.MAINTAIN_TOKEN }} + ref: main + fetch-depth: 0 + + - name: Capture main lease SHA + run: echo "MAIN_LEASE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Validate release version + env: + INPUT_VERSION: ${{ inputs.version }} + run: bash "${GITHUB_WORKSPACE}/.github/scripts/validate-release-version.sh" + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.x + cache: npm + + - name: Bump version run: | - BRANCH_NAME="${{ github.ref_name }}" - if [[ ! "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+ ]]; then - echo "::error::Branch name must match pattern (e.g., 3.4, 3.5). Current branch: $BRANCH_NAME" - exit 1 - fi - - name: Validate version input + npm config set git-tag-version false + npm version "${{ inputs.version }}" --no-git-tag-version + + - name: Update version in files + env: + VERSION: ${{ inputs.version }} run: | - PACKAGE_VERSION=$(cat package.json | jq -r '.version') - INPUT_VERSION="${{ inputs.version }}" - if [ "$INPUT_VERSION" != "$PACKAGE_VERSION" ]; then - echo "::error::Input version ($INPUT_VERSION) does not match package.json version ($PACKAGE_VERSION)" - exit 1 - fi - - build: - needs: validate - if: ( github.actor == 'ManorHazaz' || github.actor == 'hein-obox' || github.actor == 'KingYes' || github.actor == 'arielk' || github.actor == 'nicoladj77' ) && startsWith( github.repository, 'elementor/' ) - uses: ./.github/workflows/build.yml - secrets: inherit - - deploy: - needs: [validate, build] - if: needs.validate.result == 'success' && needs.build.result == 'success' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Preparing envs + npm install --no-package-lock --no-save replace-in-file@6.2.0 + node ./.github/scripts/update-version-in-files.js + + - name: Validate version consistency + run: bash "${GITHUB_WORKSPACE}/.github/scripts/validate-versions-release.sh" + + - name: Validate changelog + env: + VERSION: ${{ inputs.version }} + run: bash "${GITHUB_WORKSPACE}/.github/scripts/validate-changelog.sh" + + - name: Install dependencies and build run: | - echo "THEME_VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV - - name: Download Artifact - uses: actions/download-artifact@v4 + npm ci + composer install --no-dev + npm run zip + + - name: Commit and push to main + env: + PACKAGE_VERSION: ${{ inputs.version }} + MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} + MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} + MAIN_LEASE_SHA: ${{ env.MAIN_LEASE_SHA }} + run: bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-release-to-main.sh" + + - name: Read changelog from readme.txt + env: + VERSION: ${{ inputs.version }} + run: | + npm install --no-package-lock --no-save marked@2.0.6 + node ./.github/scripts/get-changelog-from-readme-txt.js + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 with: - name: hello-elementor + tag_name: v${{ inputs.version }} + files: hello-elementor.*.zip + body_path: temp-changelog-from-readme.txt + env: + GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }} + - name: Extract Hello Theme build run: | HT_ZIP=$(find . -name "hello-elementor-*.zip" -o -name "hello-elementor.*.zip" -type f | head -1) unzip -q "$HT_ZIP" -d ./tmp/ mv ./tmp/hello-elementor ./hello-elementor rm -rf ./tmp - - name: Validate changelog - env: - VERSION: ${{ env.THEME_VERSION }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/validate-changelog.sh" + - name: Install SVN run: | sudo apt-get update -y sudo apt-get install -y subversion - which svn - svn --version + - name: Publish to WordPress.org SVN env: + THEME_VERSION: ${{ inputs.version }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org.sh" + run: bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org.sh" + - name: Send Slack Notification uses: ./.github/actions/theme-slack-notification-release with: CLOUD_SLACK_BOT_TOKEN: ${{ secrets.CLOUD_SLACK_BOT_TOKEN }} - PACKAGE_VERSION: ${{ env.THEME_VERSION }} + PACKAGE_VERSION: ${{ inputs.version }} SLACK_CHANNEL: "#tmz-hello-delivery" diff --git a/.github/workflows/permissions/action.yml b/.github/workflows/permissions/action.yml new file mode 100644 index 00000000..dd8b820f --- /dev/null +++ b/.github/workflows/permissions/action.yml @@ -0,0 +1,31 @@ +name: Permissions +description: Validate user permissions for the current repository & run the workflow. + +inputs: + ENVIRONMENT: + required: true + description: The environment to deploy to. + DEPLOYMENT_PERMITTED: + description: Comma separated list of users that are permitted to deploy. + required: true + DEPLOYMENT_REPOSITORY_OWNER: + description: The repository owner to restrict. + required: true + +runs: + using: "composite" + steps: + - shell: bash + run: | + if [[ "${{ inputs.DEPLOYMENT_REPOSITORY_OWNER }}" != "${{ github.event.repository.owner.login }}" ]];then + echo "Pass validation outside of main repo owner" + exit 0 + fi + if [[ "${{ inputs.ENVIRONMENT }}" == "dev" ]];then + echo "Pass validation in the development environment" + exit 0 + fi + if ! echo "${{ inputs.DEPLOYMENT_PERMITTED }}" | grep -iq "${{ github.actor }}"; then + echo "::error::No deployment permissions have been granted to the user : ${{ github.actor }}" + exit 1 + fi diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml deleted file mode 100644 index e4ad5067..00000000 --- a/.github/workflows/publish-beta.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Publish Beta Version - -on: [workflow_dispatch] - -jobs: - bump-version: - if: (github.actor == 'ronkelementor' || github.actor == 'KingYes') && startsWith(github.repository, 'elementor/') - runs-on: ubuntu-20.04 - outputs: - prev_version: ${{ steps.bump_version_step.outputs.prev_version }} - steps: - - name: Checkout main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Get release branch - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/get-release-branch-name.sh" - - name: Checkout next release branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: ${{ env.RELEASE_BRANCH }} - - name: Bump version - id: bump_version_step - run: | - npm install --no-package-lock --no-save semver@7.3.4 - PREV_PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version") - NEW_PACKAGE_VERSION=$(node ./.github/scripts/update-prerelease-beta-version.js) - PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version") - - if [[ $PACKAGE_VERSION == *beta1 ]] - then - PREV_PACKAGE_VERSION=$(node -p "require('./package.json').version") - fi - - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - echo "::set-output name=prev_version::${PREV_PACKAGE_VERSION}" - - name: Push new version to beta version to release branch - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-bump.sh" - publish: - needs: bump-version - runs-on: ubuntu-16.04 - steps: - - name: Checkout main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Get release branch - env: - INPUT_VERSION: ${{ github.event.inputs.version }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/get-release-branch-name.sh" - - name: Checkout next release branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: ${{ env.RELEASE_BRANCH }} - - name: Install Dependencies - run: | - PACKAGE_VERSION=$(node -p "require('./package.json').last_beta_version") - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - npm ci - - name: Build - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save replace-in-file@6.2.0 - node ./.github/scripts/update-version-in-files.js - - npm config set git-tag-version false - npm version $VERSION - - npm run zip - - name: Upload zip file to GitHub actions artifact - uses: actions/upload-artifact@v2 - with: - name: hello-elementor.${{ env.PACKAGE_VERSION }} - path: hello-elementor.*.zip - if-no-files-found: error - - name: Create tag - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/create-git-tag.sh" - - name: Create GitHub release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ env.PACKAGE_VERSION }} - files: hello-elementor.*.zip - prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }} diff --git a/.github/workflows/publish-patch.yml b/.github/workflows/publish-patch.yml deleted file mode 100644 index b8d08326..00000000 --- a/.github/workflows/publish-patch.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Publish Patch Version - -on: - workflow_dispatch: - -jobs: - bump-version: - if: (github.actor == 'ronkelementor' || github.actor == 'KingYes') && startsWith(github.repository, 'elementor/') - runs-on: ubuntu-20.04 - outputs: - prev_version: ${{ steps.bump_version_step.outputs.prev_version }} - steps: - - name: Checkout develop branch - uses: actions/checkout@v3 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: develop - - uses: actions/setup-node@v2 - with: - node-version: '14' - - name: Bump version - id: bump_version_step - run: | - npm config set git-tag-version false - PREV_PACKAGE_VERSION=$(node -p "require('./package.json').version") - npm version patch - PACKAGE_VERSION=$(node -p "require('./package.json').version") - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - echo "::set-output name=prev_version::${PREV_PACKAGE_VERSION}" - - name: Update version in files - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save replace-in-file@6.2.0 - node ./.github/scripts/update-version-in-files.js - #npx grunt wp_readme - - name: Check if readme.txt update - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save marked@2.0.6 - node ./.github/scripts/get-changelog-from-readme-txt.js - - name: Push new version to develop - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-bump.sh" - publish: - needs: bump-version - runs-on: ubuntu-20.04 - steps: - - name: Checkout main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Merge develop -> main - uses: devmasx/merge-branch@a1752b9ba42bb417ec19be7dc974e2faf77d3ef2 # v1.3.1 - with: - type: now - from_branch: develop - target_branch: main - github_token: ${{ secrets.MAINTAIN_TOKEN }} - - name: Checkout updated main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Install Dependencies - run: | - PACKAGE_VERSION=$(node -p "require('./package.json').version") - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - npm ci - - name: Build - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - run: npm run zip - - name: Upload zip file to GitHub actions artifact - uses: actions/upload-artifact@v2 - with: - name: hello-elementor.${{ env.PACKAGE_VERSION }} - path: hello-elementor.*.zip - if-no-files-found: error - - name: Create tag - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/create-git-tag.sh" - - name: Read changelog from readme.txt - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save marked@2.0.6 - node ./.github/scripts/get-changelog-from-readme-txt.js - - name: Create GitHub release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ env.PACKAGE_VERSION }} - files: hello-elementor.*.zip - body_path: temp-changelog-from-readme.txt - env: - GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }} - diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index f4b44a8d..00000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: Publish Release Version - -on: - workflow_dispatch: - inputs: - version: - description: 'Release branch version' - required: false - -jobs: - merge-release-branch-to-develop: - if: (github.actor == 'ronkelementor' || github.actor == 'KingYes') && startsWith(github.repository, 'elementor/') - runs-on: ubuntu-20.04 - steps: - - name: Checkout main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Get release branch - env: - INPUT_VERSION: ${{ github.event.inputs.version }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/get-release-branch-name.sh" - - name: Checkout release branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: ${{ env.RELEASE_BRANCH }} - - name: Merge release -> develop - uses: devmasx/merge-branch@a1752b9ba42bb417ec19be7dc974e2faf77d3ef2 # v1.3.1 - with: - type: now - from_branch: ${{ env.RELEASE_BRANCH }} - target_branch: develop - github_token: ${{ secrets.MAINTAIN_TOKEN }} - bump-version: - needs: merge-release-branch-to-develop - runs-on: ubuntu-16.04 - outputs: - prev_version: ${{ steps.bump_version_step.outputs.prev_version }} - steps: - - name: Checkout develop branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: develop - - name: Bump version - id: bump_version_step - run: | - npm config set git-tag-version false - PREV_PACKAGE_VERSION=$(node -p "require('./package.json').version") - npm version minor - PACKAGE_VERSION=$(node -p "require('./package.json').version") - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - echo "::set-output name=prev_version::${PREV_PACKAGE_VERSION}" - - name: Update version in files - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save replace-in-file@6.2.0 - node ./.github/scripts/update-version-in-files.js - #npx grunt wp_readme - - name: Check if readme.txt update - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save marked@2.0.6 - node ./.github/scripts/get-changelog-from-readme-txt.js - - name: Push new version to develop - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/commit-push-bump.sh" - publish: - needs: bump-version - runs-on: ubuntu-16.04 - steps: - - name: Checkout main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Merge develop -> main - uses: devmasx/merge-branch@a1752b9ba42bb417ec19be7dc974e2faf77d3ef2 # v1.3.1 - with: - type: now - from_branch: develop - target_branch: main - github_token: ${{ secrets.MAINTAIN_TOKEN }} - - name: Checkout updated main branch - uses: actions/checkout@v2 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - - name: Install Dependencies - run: | - PACKAGE_VERSION=$(node -p "require('./package.json').version") - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV - npm ci - - name: Build - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - run: npm run zip - - name: Upload zip file to GitHub actions artifact - uses: actions/upload-artifact@v2 - with: - name: hello-elementor.${{ env.PACKAGE_VERSION }} - path: hello-elementor.*.zip - if-no-files-found: error - - name: Create tag - env: - PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} - MAINTAIN_EMAIL: ${{ secrets.MAINTAIN_EMAIL }} - MAINTAIN_USERNAME: ${{ secrets.MAINTAIN_USERNAME }} - run: | - bash "${GITHUB_WORKSPACE}/.github/scripts/create-git-tag.sh" - - name: Read changelog from readme.txt - env: - VERSION: ${{ env.PACKAGE_VERSION }} - run: | - npm install --no-package-lock --no-save marked@2.0.6 - node ./.github/scripts/get-changelog-from-readme-txt.js - - name: Create GitHub release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ env.PACKAGE_VERSION }} - files: hello-elementor.*.zip - body_path: temp-changelog-from-readme.txt - env: - GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }} From 160b20f92e5d83ddbcda96c8b4a7febef32c4473 Mon Sep 17 00:00:00 2001 From: Netanel Baba Date: Wed, 19 Aug 2026 15:25:44 +0300 Subject: [PATCH 2/4] ci: Disable SVN publish in Deploy workflow for testing Co-authored-by: Cursor --- .github/workflows/deploy.yml | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1186f7d3..a7dca1aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -98,24 +98,25 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.MAINTAIN_TOKEN }} - - name: Extract Hello Theme build - run: | - HT_ZIP=$(find . -name "hello-elementor-*.zip" -o -name "hello-elementor.*.zip" -type f | head -1) - unzip -q "$HT_ZIP" -d ./tmp/ - mv ./tmp/hello-elementor ./hello-elementor - rm -rf ./tmp - - - name: Install SVN - run: | - sudo apt-get update -y - sudo apt-get install -y subversion - - - name: Publish to WordPress.org SVN - env: - THEME_VERSION: ${{ inputs.version }} - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} - run: bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org.sh" + # TODO: Re-enable SVN publish after deploy workflow testing is complete + # - name: Extract Hello Theme build + # run: | + # HT_ZIP=$(find . -name "hello-elementor-*.zip" -o -name "hello-elementor.*.zip" -type f | head -1) + # unzip -q "$HT_ZIP" -d ./tmp/ + # mv ./tmp/hello-elementor ./hello-elementor + # rm -rf ./tmp + # + # - name: Install SVN + # run: | + # sudo apt-get update -y + # sudo apt-get install -y subversion + # + # - name: Publish to WordPress.org SVN + # env: + # THEME_VERSION: ${{ inputs.version }} + # SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + # SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + # run: bash "${GITHUB_WORKSPACE}/.github/scripts/publish-theme-to-wordpress-org.sh" - name: Send Slack Notification uses: ./.github/actions/theme-slack-notification-release From 7d3166acaaced90dacc9e14e8837e1778245e4f2 Mon Sep 17 00:00:00 2001 From: Netanel Baba Date: Wed, 19 Aug 2026 15:29:13 +0300 Subject: [PATCH 3/4] ci: Checkout workflow ref before permissions action Local composite actions require the repository on disk before they can run. Co-authored-by: Cursor --- .github/workflows/deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a7dca1aa..03a59919 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,6 +20,11 @@ jobs: if: startsWith(github.repository, 'elementor/') runs-on: ubuntu-latest steps: + - name: Checkout workflow ref + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Test permissions uses: ./.github/workflows/permissions with: From ade55bc19529076ab27fe48a772fab287a968ec3 Mon Sep 17 00:00:00 2001 From: Netanel Baba Date: Wed, 19 Aug 2026 15:32:23 +0300 Subject: [PATCH 4/4] ci: Keep release scripts when preparing main workspace Checkout main for theme files but restore .github from the workflow ref so pre-merge Deploy runs can use the new release scripts. Co-authored-by: Cursor --- .github/workflows/deploy.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 03a59919..c0aaec87 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,7 @@ jobs: - name: Checkout workflow ref uses: actions/checkout@v4 with: + token: ${{ secrets.MAINTAIN_TOKEN }} fetch-depth: 0 - name: Test permissions @@ -32,20 +33,12 @@ jobs: DEPLOYMENT_PERMITTED: ${{ vars.DEPLOYMENT_PERMITTED_USERS }} DEPLOYMENT_REPOSITORY_OWNER: elementor - - name: Checkout main - uses: actions/checkout@v4 - with: - token: ${{ secrets.MAINTAIN_TOKEN }} - ref: main - fetch-depth: 0 - - - name: Capture main lease SHA - run: echo "MAIN_LEASE_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV - - - name: Validate release version - env: - INPUT_VERSION: ${{ inputs.version }} - run: bash "${GITHUB_WORKSPACE}/.github/scripts/validate-release-version.sh" + - name: Prepare main release workspace + run: | + git fetch origin main + echo "MAIN_LEASE_SHA=$(git rev-parse origin/main)" >> $GITHUB_ENV + git checkout -B main origin/main + git checkout "${GITHUB_SHA}" -- .github/ - name: Set up Node.js uses: actions/setup-node@v4 @@ -53,6 +46,11 @@ jobs: node-version: 18.x cache: npm + - name: Validate release version + env: + INPUT_VERSION: ${{ inputs.version }} + run: bash "${GITHUB_WORKSPACE}/.github/scripts/validate-release-version.sh" + - name: Bump version run: | npm config set git-tag-version false