Skip to content

Commit 1c7e319

Browse files
authored
Internal: Update release branch with main branch [TMZ-803] (#583)
1 parent 2a43d8c commit 1c7e319

File tree

7 files changed

+135
-365
lines changed

7 files changed

+135
-365
lines changed

.cursor/rules/github-workflows.mdc

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
description: GitHub Workflows and Actions YAML Rules for Hello Theme
3+
globs: ["**/*.yml", "**/*.yaml"]
4+
alwaysApply: true
5+
---
6+
7+
# GitHub Workflows and Actions YAML Rules for Hello Theme
8+
9+
## Core Principles
10+
11+
### Assume Happy Path
12+
- Remove defensive checks that add little value
13+
- Assume branches exist, labels are correct, and operations succeed
14+
- Let failures fail naturally rather than adding extensive error handling
15+
- Focus on core functionality, not edge case handling
16+
17+
### Keep Workflows Concise
18+
- Target 50-100 lines per workflow file
19+
- Extract complex logic to reusable scripts in `.github/scripts/`
20+
- Inline simple logic (templates, simple string operations)
21+
- Remove debugging and verbose logging
22+
23+
### No Emojis
24+
- Never use emojis in workflow files, PR titles, or messages
25+
- Use plain text for all output and notifications
26+
27+
## Script Extraction Guidelines
28+
29+
### Extract to Scripts When:
30+
- Logic is complex (5+ lines of bash)
31+
- Logic is reused in multiple places
32+
- Logic benefits from testing independently
33+
34+
### Keep Inline When:
35+
- Simple template strings
36+
- Single-line operations
37+
- Direct GitHub Actions expressions
38+
39+
## Workflow Structure
40+
41+
### Essential Steps Only
42+
- Checkout repository
43+
- Core workflow logic
44+
- Error handling only for critical failures
45+
46+
### Remove These Steps:
47+
- Debugging/logging steps
48+
- Redundant validation steps
49+
- Conflict marker detection (redundant)
50+
51+
## Code Style
52+
53+
### YAML Formatting
54+
- Use consistent indentation (2 spaces)
55+
- Keep line length reasonable (max 120 characters)
56+
- Use multi-line strings for readability when needed
57+
- Empty line at end of file
58+
59+
## Examples
60+
61+
### Bad: Debugging Clutter
62+
```yaml
63+
- name: Log trigger and PR information
64+
run: |
65+
echo "Trigger: ${{ github.event.action }}"
66+
echo "PR #${{ github.event.pull_request.number }}"
67+
# ... more debugging output
68+
```
69+
70+
### Bad: Unnecessary Validation
71+
```yaml
72+
if [ ! -f "style.css" ]; then
73+
echo "::error:: Missing style.css"
74+
continue
75+
fi
76+
# Assume happy path - these checks add little value
77+
```

.github/actions/theme-slack-notification-release/action.yml

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,24 @@ inputs:
77
PACKAGE_VERSION:
88
required: true
99
description: 'Release version'
10-
BUILD_ZIP_PATH:
11-
required: true
12-
description: 'Path to theme zip file'
13-
GITHUB_RELEASE_URL:
14-
required: true
15-
description: 'GitHub release URL'
1610
SLACK_CHANNEL:
1711
required: false
1812
default: '#tmz-hello-delivery'
1913
description: 'Slack channel to send notification to'
20-
WPORG_DEPLOYMENT_STATUS:
21-
required: false
22-
default: 'skipped'
23-
description: 'WordPress.org deployment status (deployed|skipped|disabled)'
2414

2515
runs:
2616
using: 'composite'
2717
steps:
28-
- name: Prepare deployment message
29-
id: deployment-message
30-
shell: bash
31-
run: |
32-
case "${{ inputs.WPORG_DEPLOYMENT_STATUS }}" in
33-
"deployed")
34-
MESSAGE="📦 *WordPress.org Deployment*\\n• ✅ Automatically deployed to WordPress.org\\n• Theme available at: https://wordpress.org/themes/hello-elementor/\\n• No manual upload required! 🎉"
35-
;;
36-
"disabled")
37-
MESSAGE="📦 *WordPress.org Deployment*\\n• ⚠️ Disabled in configuration\\n• Manual upload required to WordPress.org\\n• Download zip from GitHub release below"
38-
;;
39-
*)
40-
MESSAGE="📦 *WordPress.org Deployment*\\n• ⚠️ Skipped (deploy_to_wporg: false)\\n• Manual upload required to WordPress.org\\n• Download zip from GitHub release below"
41-
;;
42-
esac
43-
echo "DEPLOYMENT_MESSAGE=$MESSAGE" >> $GITHUB_ENV
44-
45-
- name: Get file info
46-
id: file-info
47-
shell: bash
48-
run: |
49-
if [ -f "${{ inputs.BUILD_ZIP_PATH }}" ]; then
50-
FILE_SIZE=$(stat -c%s "${{ inputs.BUILD_ZIP_PATH }}" 2>/dev/null || stat -f%z "${{ inputs.BUILD_ZIP_PATH }}")
51-
FILE_SIZE_MB=$(echo "scale=2; $FILE_SIZE / 1024 / 1024" | bc -l 2>/dev/null || echo "$((FILE_SIZE / 1024 / 1024)).0")
52-
echo "FILE_SIZE=$FILE_SIZE" >> $GITHUB_ENV
53-
echo "FILE_SIZE_MB=${FILE_SIZE_MB}MB" >> $GITHUB_ENV
54-
else
55-
echo "FILE_SIZE_MB=Unknown" >> $GITHUB_ENV
56-
fi
57-
5818
- name: Post to Slack
5919
shell: bash
6020
env:
6121
CLOUD_SLACK_BOT_TOKEN: ${{ inputs.CLOUD_SLACK_BOT_TOKEN }}
6222
SLACK_CHANNEL: ${{ inputs.SLACK_CHANNEL }}
6323
PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }}
64-
FILE_SIZE_MB: ${{ env.FILE_SIZE_MB }}
65-
DEPLOYMENT_MESSAGE: ${{ env.DEPLOYMENT_MESSAGE }}
66-
GITHUB_RELEASE_URL: ${{ inputs.GITHUB_RELEASE_URL }}
67-
BUILD_ZIP_PATH: ${{ inputs.BUILD_ZIP_PATH }}
6824
run: |
6925
node << 'NODE_SCRIPT'
7026
const slackChannel = process.env.SLACK_CHANNEL || '#tmz-hello-delivery';
7127
const packageVersion = process.env.PACKAGE_VERSION || '';
72-
const fileSizeMb = process.env.FILE_SIZE_MB || 'Unknown';
73-
const deploymentMessage = (process.env.DEPLOYMENT_MESSAGE || '').replace(/\\n/g, '\n');
74-
const githubReleaseUrl = process.env.GITHUB_RELEASE_URL || '';
75-
const buildZipPath = process.env.BUILD_ZIP_PATH || '';
7628
7729
const payload = {
7830
text: `Hello Elementor v${packageVersion} Released!`,
@@ -81,7 +33,7 @@ runs:
8133
type: 'header',
8234
text: {
8335
type: 'plain_text',
84-
text: `🚀 Hello Elementor v${packageVersion} Released!`
36+
text: `Hello Elementor v${packageVersion} Released!`
8537
}
8638
},
8739
{
@@ -97,40 +49,6 @@ runs:
9749
{
9850
type: 'mrkdwn',
9951
text: `*Version:*\nv${packageVersion}`
100-
},
101-
{
102-
type: 'mrkdwn',
103-
text: `*Package Size:*\n${fileSizeMb}`
104-
}
105-
]
106-
},
107-
{
108-
type: 'section',
109-
text: {
110-
type: 'mrkdwn',
111-
text: deploymentMessage
112-
}
113-
},
114-
{
115-
type: 'actions',
116-
elements: [
117-
{
118-
type: 'button',
119-
text: {
120-
type: 'plain_text',
121-
text: '📥 Download Release'
122-
},
123-
url: githubReleaseUrl,
124-
style: 'primary'
125-
}
126-
]
127-
},
128-
{
129-
type: 'context',
130-
elements: [
131-
{
132-
type: 'mrkdwn',
133-
text: `Build: ${buildZipPath}`
13452
}
13553
]
13654
}
@@ -151,15 +69,3 @@ runs:
15169
echo "📢 Slack notification sent!"
15270
echo " - Channel: ${{ inputs.SLACK_CHANNEL }}"
15371
echo " - Version: v${{ inputs.PACKAGE_VERSION }}"
154-
echo " - Release: ${{ inputs.GITHUB_RELEASE_URL }}"
155-
case "${{ inputs.WPORG_DEPLOYMENT_STATUS }}" in
156-
"deployed")
157-
echo " - WordPress.org: ✅ Automatically deployed"
158-
;;
159-
"disabled")
160-
echo " - WordPress.org: ⚠️ Disabled in configuration"
161-
;;
162-
*)
163-
echo " - WordPress.org: ⚠️ Skipped (deploy_to_wporg: false)"
164-
;;
165-
esac

.github/config/release.json

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
PR_NUMBER="$1"
5+
TARGET="$2"
6+
ORIGINAL_BRANCH="$3"
7+
8+
CLEAN_BRANCH=$(echo "$ORIGINAL_BRANCH" | sed 's|^[^/]*/||g')
9+
SANITIZED_BRANCH=$(echo "$CLEAN_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
10+
SANITIZED_BRANCH=${SANITIZED_BRANCH:0:35}
11+
TIMESTAMP=$(date +%s)
12+
BRANCH="${SANITIZED_BRANCH}-cherry-pick-pr${PR_NUMBER}-${TIMESTAMP}"
13+
14+
echo "$BRANCH"
15+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
PR_TITLE="$1"
5+
PR_NUMBER="$2"
6+
TARGET="$3"
7+
8+
PR_TICKETS=$(echo "$PR_TITLE" | grep -o '\[[A-Z]\{2,\}-[0-9]\+\]' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
9+
10+
if [ -n "$PR_TICKETS" ]; then
11+
TITLE_WITHOUT_TICKETS=$(echo "$PR_TITLE" | sed 's/\[[A-Z]\{2,\}-[0-9]\+\]//g' | sed 's/[[:space:]]*$//')
12+
CHERRY_PICK_TITLE="$TITLE_WITHOUT_TICKETS (CP #${PR_NUMBER}${TARGET}) ${PR_TICKETS}"
13+
else
14+
CHERRY_PICK_TITLE="$PR_TITLE (CP #${PR_NUMBER}${TARGET})"
15+
fi
16+
17+
echo "$CHERRY_PICK_TITLE"
18+

.github/workflows/build.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Build
22

3-
on: [push, pull_request]
4-
3+
on:
4+
push:
5+
pull_request:
6+
workflow_call:
57

68
jobs:
79
build_plugin:
@@ -41,24 +43,14 @@ jobs:
4143
echo "The Theme version is:"
4244
echo "${{ env.PACKAGE_VERSION }}"
4345
echo "The Theme slug is:"
44-
echo "${{ env.THEME_SLUG }}"
46+
echo "hello-elementor"
4547
echo "End debug Info"
4648
echo "exitcode=$?" >> $GITHUB_OUTPUT
4749
- name: Install Dependencies
4850
run: npm ci
4951
- name: Install Composer dependencies
5052
run:
5153
composer install --no-dev
52-
- name: Bump version on push to release or develop
53-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/release/') || github.ref == 'refs/heads/develop')
54-
run: |
55-
npm config set git-tag-version false
56-
if [ "${GITHUB_REF:11}" == "develop" ];
57-
then npm version patch
58-
fi
59-
if [[ "${GITHUB_REF:11:7}" == "release" ]];
60-
then npm version minor
61-
fi
6254
- name: Build
6355
run: npm run zip
6456
- name: Upload zip file to GitHub actions artifact

0 commit comments

Comments
 (0)