Skip to content
Open
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
98 changes: 98 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Auto Release – WordPress

on:
pull_request:
types: [closed]
branches:
- master

permissions:
contents: write

jobs:
release:
# Run only when PR is merged
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest


steps:
# --------------------------------------------
# Validate release intent
# --------------------------------------------
- name: Validate release intent
id: intent
uses: actions/github-script@v6
with:
script: |
const body = context.payload.pull_request.body || '';
const title = context.payload.pull_request.title || '';
const text = `${title}\n${body}`;

core.setOutput(
'release',
/release:\s*yes/i.test(text) ? 'true' : 'false'
);

- name: Stop if not a release PR
if: steps.intent.outputs.release == 'false'
run: |
echo "Not a release PR. Skipping auto-release."
exit 0

# --------------------------------------------
# Checkout merged code
# --------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0

# --------------------------------------------
# Read version from repo (SOURCE OF TRUTH)
# Adjust this if you store version elsewhere
# --------------------------------------------
- name: Read version from bower.json
run: |
VERSION=$(jq -r '.version' bower.json)

if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
echo "Failed to determine version from bower.json"
exit 1
fi

if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid version format: $VERSION"
exit 1
fi

echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Releasing version $VERSION"

# --------------------------------------------
# Prepare clean release notes from PR body
# --------------------------------------------
- name: Prepare release notes
run: |
PR_BODY="${{ github.event.pull_request.body }}"

CLEAN_NOTES=$(echo "$PR_BODY" | sed \
-e '/^release:\s*/Id' \
-e '/^## Release Notes.*$/Id')

echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$CLEAN_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

# --------------------------------------------
# Create GitHub Release (NO artifacts)
# --------------------------------------------
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
gh release create "v${VERSION}" \
--title "Release ${VERSION}" \
--notes "$RELEASE_NOTES" \
--latest
136 changes: 136 additions & 0 deletions .github/workflows/sync-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Sync Version – Python SDK

on:
repository_dispatch:
types: [version_update]

permissions:
contents: write
pull-requests: write

jobs:
sync:
runs-on: ubuntu-latest

steps:
# --------------------------------------------
# Checkout repository
# --------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0

# --------------------------------------------
# Load & validate version
# --------------------------------------------
- name: Load & validate version
run: |
VERSION="${{ github.event.client_payload.version }}"
VERSION="${VERSION//,/\.}"

if [ -z "$VERSION" ]; then
echo "Version missing in dispatch payload"
exit 1
fi

if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid version format: $VERSION"
exit 1
fi

echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Dispatching version $VERSION"

# --------------------------------------------
# Compare current version
# --------------------------------------------
- name: Compare current version
run: |
CURRENT_VERSION=$(jq -r '.version' bower.json)

if [ -z "$CURRENT_VERSION" ] || [ "$CURRENT_VERSION" = "null" ]; then
echo "Unable to determine current version from bower.json"
exit 1
fi

echo "Current version : $CURRENT_VERSION"
echo "Incoming version: $VERSION"

if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "Versions are identical. Denying PR creation."
exit 0
fi

echo "Version change detected. Proceeding."

# --------------------------------------------
# Prepare release branch
# --------------------------------------------
- name: Prepare release branch
run: |
BRANCH="release-v${VERSION}"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV

git fetch origin

if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
git checkout "$BRANCH"
git pull origin "$BRANCH"
else
git checkout -b "$BRANCH"
fi

# --------------------------------------------
# Update bower.json version + dependency
# --------------------------------------------
- name: Update bower.json
run: |
# Update SDK version
jq ".version = \"$VERSION\"" bower.json > tmp.json
mv tmp.json bower.json

# Update froala-wysiwyg-editor dependency
jq ".dependencies[\"froala-wysiwyg-editor\"] = \"^$VERSION\"" bower.json > tmp.json
mv tmp.json bower.json


# --------------------------------------------
# Commit & push
# --------------------------------------------
- name: Commit & push
run: |
git config user.name "froala-travis-bot"
git config user.email "froala_git_travis_bot@idera.com"

git add bower.json
git commit -m "chore: release Python SDK v${VERSION}" || echo "Nothing to commit"

git push origin "$BRANCH"

# --------------------------------------------
# Create Pull Request
# --------------------------------------------
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.PAT }}
RELEASE_NOTES: ${{ github.event.client_payload.release_notes }}
run: |
git fetch origin master

if git diff --quiet origin/master..."$BRANCH"; then
echo "No commits between $BRANCH and master. Skipping PR creation."
exit 0
fi

PR_BODY=$(printf \
"release: yes\n\n## Release Notes (from primary repo)\n\n%s\n" \
"$RELEASE_NOTES")

gh pr create \
--base master \
--head "$BRANCH" \
--title "Release v${VERSION}" \
--body "$PR_BODY" \
|| echo "Pull request already exists"
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "froala-editor-python-sdk",
"version": "5.0.1",
"version": "3.0.7",
"author": "Florin Marius Popescu <florin@froala.com> (https://www.froala.com/)",
"description": "Node.js SDK for Froala Editor",
"keywords": [
Expand All @@ -16,6 +16,6 @@
"bower_components"
],
"dependencies": {
"froala-wysiwyg-editor": "^5.0.1"
"froala-wysiwyg-editor": "^3.0.7"
}
}