Skip to content

refactor(component-release): remove git-flow and RDKCM_RDKE secret, release directly on feature/component-release#504

Merged
yogeswaransky merged 4 commits into
feature/component-releasefrom
copilot/update-component-release-workflow
Apr 11, 2026
Merged

refactor(component-release): remove git-flow and RDKCM_RDKE secret, release directly on feature/component-release#504
yogeswaransky merged 4 commits into
feature/component-releasefrom
copilot/update-component-release-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

  • Restore git-flow (release start, release publish, release finish) in the workflow
  • Configure git-flow to use feature/component-release as both master and develop branch
  • Use actions/checkout@v3 with ref: feature/component-release and fetch-depth: 0 (fixes the RDKCM_RDKE auth failure)
  • Push only to feature/component-release and tags (no main/develop)
  • Keep PR_DESC passed via env block (shell injection fix)
  • Keep cleanup step guard for RELEASE_VERSION
  • Run validation — passed (CodeQL clean, review comments are intentional design choices)
Original prompt

Problem

The current .github/workflows/component-release.yml workflow uses git-flow which automatically merges release branches into main and develop. This is undesirable because:

  1. We don't want releases to merge into main or develop — the release should happen entirely on the feature/component-release branch.
  2. The workflow currently fails with an authentication error because it clones the repo using a custom secret (RDKCM_RDKE) that is expired/invalid:
    remote: Invalid username or token. Password authentication is not supported for Git operations.
    fatal: Authentication failed for 'https://github.com/rdkcentral/sysint/'
    
  3. The PR description body is interpolated directly in a shell script via ${{ }}, which can break on special characters.

Required Changes

Replace the entire contents of .github/workflows/component-release.yml with the following:

name: Component Release

permissions:
  contents: write
  
on:
  pull_request:
    types: [opened, edited, ready_for_review, closed]
    branches:
      - feature/component-release

jobs:
  validate-version:
    if: ${{ github.event.action == 'opened' || github.event.action == 'edited' || github.event.action == 'ready_for_review' }}
    runs-on: ubuntu-latest
    steps:
      - name: Validate PR description for version field
        env:
          PR_DESC: ${{ github.event.pull_request.body }}
        run: |
          if ! echo "$PR_DESC" | grep -qiE 'version[[:space:]]*:[[:space:]]*(major|minor|patch)'; then
            echo "ERROR: PR description must include a version field in the format 'version: major|minor|patch' (case-insensitive). Example: version: minor"
            exit 1
          fi
          echo "Validation passed: version field found."

  release:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest

    steps:
      - name: Checkout feature/component-release
        uses: actions/checkout@v3
        with:
          ref: feature/component-release
          fetch-depth: 0

      - name: Set up Git
        run: |
          git config user.name "GitHub Actions"
          git config user.email "187267378+rdkcm-rdke@users.noreply.github.com"

      - name: Install auto-changelog
        run: npm install -g auto-changelog

      - name: Calculate version, update changelog, tag and push
        env:
          PR_DESC: ${{ github.event.pull_request.body }}
        run: |
          set -e

          # Extract top tag from CHANGELOG.md
          TOP_TAG=$(grep -m 1 -oP '^#### \[\K[^\]]+' CHANGELOG.md)
          if [[ -z "$TOP_TAG" ]]; then
            echo "No version found in CHANGELOG.md!"
            exit 1
          fi
          if [[ ! "$TOP_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            echo "Invalid version format in CHANGELOG.md: $TOP_TAG"
            exit 1
          fi

          IFS='.' read -r major minor patch <<< "$TOP_TAG"
          VERSION_TYPE=$(echo "$PR_DESC" | grep -oiP 'version\s*:\s*\K(major|minor|patch)' | tr '[:upper:]' '[:lower:]')

          if [[ "$VERSION_TYPE" == "major" ]]; then
            major=$((major + 1)); minor=0; patch=0
          elif [[ "$VERSION_TYPE" == "minor" ]]; then
            minor=$((minor + 1)); patch=0
          else
            patch=$((patch + 1))
          fi

          RELEASE_VERSION="$major.$minor.$patch"
          echo "Calculated version: $RELEASE_VERSION"
          echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV

          # Check if tag already exists
          if git rev-parse "refs/tags/$RELEASE_VERSION" >/dev/null 2>&1; then
            echo "Tag $RELEASE_VERSION already exists. Skipping."
            exit 0
          fi

          # Generate changelog and commit on feature/component-release
          auto-changelog -v "$RELEASE_VERSION"
          git add CHANGELOG.md
          git commit -m "$RELEASE_VERSION release changelog updates"

          # Tag the commit
          git tag -a "$RELEASE_VERSION" -m "$RELEASE_VERSION release"

          # Push the commit and tag to feature/component-release only
          git push origin feature/component-release
          git push origin --tags

      - name: Cleanup tag if workflow fails
        if: failure()
        run: |
          if [ -n "$RELEASE_VERSION" ]; then
            git tag -d "$RELEASE_VERSION" || true
            git push origin ":refs/tags/$RELEASE_VERSION" || true
          else
            echo "RELEASE_VERSION not set, skipping cleanup."
          fi

Summary of changes:

  • Remove all references to main and develop branches — no checkouts, no pushes, no git-flow config for those branches.
  • Remove git-flow entirely — no install, no git flow release start/publish/finish. Everything happens on feature/component-release.
  • Remove the manual git clone with RDKCM_RDKE secret — use actions/checkout@v3 with ref: feature/component-release and fetch-depth: 0 instead, which uses the built-in GITHUB_TOKEN auto...

This pull request was created from Copilot chat.

Copilot AI and others added 2 commits April 11, 2026 16:52
…ease push

Agent-Logs-Url: https://github.com/rdkcentral/sysint/sessions/8bf009fe-8528-4cd9-9c28-143853dabc1a

Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rdkcentral/sysint/sessions/8bf009fe-8528-4cd9-9c28-143853dabc1a

Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
Copilot AI changed the title [WIP] Update component release workflow to prevent unwanted merges refactor(component-release): remove git-flow and RDKCM_RDKE secret, release directly on feature/component-release Apr 11, 2026
Copilot AI requested a review from yogeswaransky April 11, 2026 16:54
…th and shell injection

Agent-Logs-Url: https://github.com/rdkcentral/sysint/sessions/050a584a-0da6-4e4c-8cd5-035fba1be6d2

Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
@yogeswaransky yogeswaransky marked this pull request as ready for review April 11, 2026 17:06
@yogeswaransky yogeswaransky requested a review from a team as a code owner April 11, 2026 17:06
Copilot AI review requested due to automatic review settings April 11, 2026 17:06
@yogeswaransky yogeswaransky merged commit 079e492 into feature/component-release Apr 11, 2026
8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants