From ce53c14cc208f6d5ec20bb0e2c39f9434b084660 Mon Sep 17 00:00:00 2001 From: parull249 <103111355+parull249@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:14:17 +0530 Subject: [PATCH 1/2] Create sync-version.yml --- .github/workflows/sync-version.yml | 117 +++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/sync-version.yml diff --git a/.github/workflows/sync-version.yml b/.github/workflows/sync-version.yml new file mode 100644 index 0000000..f0ea3d6 --- /dev/null +++ b/.github/workflows/sync-version.yml @@ -0,0 +1,117 @@ +name: Release + +on: + repository_dispatch: + types: [version_update] + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.PAT }} + + - name: Load version + run: | + VERSION="${{ github.event.client_payload.version }}" + + if [ -z "$VERSION" ]; then + echo "Version is missing" + 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 "Using version $VERSION" + + - name: Compare current version + run: | + CURRENT_VERSION=$(jq -r '.version' bower.json) + + if [ -z "$CURRENT_VERSION" ] || [ "$CURRENT_VERSION" = "null" ]; then + echo "Could not read the current version from bower.json" + exit 1 + fi + + echo "Current version: $CURRENT_VERSION" + echo "Incoming version: $VERSION" + + if [ "$CURRENT_VERSION" = "$VERSION" ]; then + echo "The version is already up to date. No changes needed." + exit 0 + fi + + echo "New version detected. Continuing with release process." + + - 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 + + - name: Update package.json + run: | + jq --arg VERSION "$VERSION" '.version = $VERSION' package.json > tmp.json + mv tmp.json package.json + + - name: Update bower.json + run: | + jq --arg VERSION "$VERSION" '.version = $VERSION' bower.json > tmp.json + mv tmp.json bower.json + + - name: Commit changes + run: | + git config user.name "froala-travis-bot" + git config user.email "froala_git_travis_bot@idera.com" + git add . + git commit -m "chore: release v${VERSION}" || echo "Nothing to commit" + git push origin "$BRANCH" + + - name: Commit & push + run: | + git config user.name "froala-travis-bot" + git config user.email "froala_git_travis_bot@idera.com" + + git add package.json bower.json + git commit -m "chore: release v${VERSION}" || echo "Nothing to commit" + git push origin "$BRANCH" + + - 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" From 47c2b518b40f3fe2ba8e6dcce4392e382e1d25bf Mon Sep 17 00:00:00 2001 From: parull249 <103111355+parull249@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:16:22 +0530 Subject: [PATCH 2/2] Create auto-release.yml --- .github/workflows/auto-release.yml | 85 ++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..246c02e --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,85 @@ +name: Auto Release – angular + +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: + - 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 + + + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.PAT }} + fetch-depth: 0 + + + - 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" + + + - 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<> $GITHUB_ENV + echo "$CLEAN_NOTES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.PAT }} + run: | + gh release create "v${VERSION}" \ + --title "Release ${VERSION}" \ + --notes "$RELEASE_NOTES" \ + --latest