-
Notifications
You must be signed in to change notification settings - Fork 6
RDKE-1065: Automated Component Release workflow #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4aee73e
RDKE-1065: Semi Automated Release workflow
yogeswaransky c21d6eb
RDKE-1065: Semi Automated Release workflow
yogeswaransky 862e27f
RDKE-1065: Semi Automated Release workflow
yogeswaransky ba8e94d
RDKE-1065: Semi Automated Release workflow
yogeswaransky 9e28f9b
RDKE-1065: Semi Automated Release workflow
yogeswaransky 5927ed1
RDKE-1065: Separated release workflow for Maintainer approval
yogeswaransky a80d017
RDKE-1065: Separated release workflow for Maintainer approval
yogeswaransky f6a551e
RDKE-1065: Separated release workflow for Maintainer approval
yogeswaransky 111ba26
RDKE-1065: Separated release workflow for Maintainer approval
yogeswaransky 50e01bb
Rename README.md to component-release-workflow-usage.md
tdeva14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
.github/workflows/component-release-finish-on-approval.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: Component Release Finish On Approval | ||
|
|
||
| on: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: release-finish-${{ github.event.pull_request.head.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| finish-release: | ||
| name: Finish release when PR is approved | ||
| if: > | ||
| github.event.review.state == 'approved' && | ||
| github.event.pull_request.base.ref == 'develop' && | ||
| startsWith(github.event.pull_request.head.ref, 'release/') | ||
| runs-on: comcast-ubuntu-latest | ||
| env: | ||
| REPO: ${{ github.repository }} | ||
| ACTOR: ${{ github.event.review.user.login }} | ||
| GH_TOKEN: ${{ secrets.RDKCM_RDKE }} | ||
| RELEASE_BRANCH: ${{ github.event.pull_request.head.ref }} | ||
|
yogeswaransky marked this conversation as resolved.
|
||
|
|
||
| steps: | ||
| - name: Check approval status | ||
| id: approvals | ||
| run: | | ||
| set -euo pipefail | ||
| pr_number="${{ github.event.pull_request.number }}" | ||
| decision=$(gh pr view --repo "${REPO}" "${pr_number}" --json reviewDecision -q '.reviewDecision') | ||
| echo "PR #${pr_number} review decision: ${decision}" | ||
| if [ "${decision}" = "APPROVED" ]; then | ||
| echo "should_finish=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "PR is not fully approved yet. Waiting." | ||
| echo "should_finish=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
yogeswaransky marked this conversation as resolved.
|
||
|
|
||
| - name: Checkout repository | ||
| if: steps.approvals.outputs.should_finish == 'true' | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ssh-key: ${{ secrets.RDKCM_DEPLOY_KEY }} | ||
|
|
||
| - name: Install release tools | ||
| if: steps.approvals.outputs.should_finish == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| sudo apt-get update | ||
| sudo apt-get install -y git-flow | ||
|
yogeswaransky marked this conversation as resolved.
|
||
|
|
||
| - name: Configure git identity | ||
| if: steps.approvals.outputs.should_finish == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| git config user.name "${ACTOR}" | ||
| git config user.email "${ACTOR}@users.noreply.github.com" | ||
|
|
||
| - name: Finish release and push | ||
| if: steps.approvals.outputs.should_finish == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| release_version="${RELEASE_BRANCH#release/}" | ||
|
|
||
| git fetch --prune origin | ||
|
|
||
| # Skip if tag already exists | ||
| if git ls-remote --exit-code --tags origin "refs/tags/${release_version}" >/dev/null 2>&1; then | ||
| echo "Tag ${release_version} already exists on origin. Skipping release finish." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Checkout the release branch | ||
| if git show-ref --verify --quiet "refs/heads/${RELEASE_BRANCH}"; then | ||
| git checkout "${RELEASE_BRANCH}" | ||
| elif git ls-remote --exit-code --heads origin "${RELEASE_BRANCH}" >/dev/null 2>&1; then | ||
| git checkout -b "${RELEASE_BRANCH}" "origin/${RELEASE_BRANCH}" | ||
| else | ||
| echo "${RELEASE_BRANCH} does not exist locally or on origin." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure main and develop exist locally | ||
| git checkout main 2>/dev/null || git checkout -b main origin/main | ||
| git checkout develop 2>/dev/null || git checkout -b develop origin/develop | ||
| git checkout "${RELEASE_BRANCH}" | ||
|
yogeswaransky marked this conversation as resolved.
|
||
|
|
||
| # Initialize git-flow | ||
| git flow init -d | ||
|
|
||
| # Finish release: merges to main + develop, creates tag | ||
| git flow release finish -m "Release ${release_version}" "${release_version}" | ||
| git push origin main | ||
| git push origin --tags | ||
| git push origin develop | ||
|
Copilot marked this conversation as resolved.
|
||
| git push origin --delete "${RELEASE_BRANCH}" || true | ||
|
|
||
| - name: Close the release PR | ||
| if: steps.approvals.outputs.should_finish == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| pr_number="${{ github.event.pull_request.number }}" | ||
| gh pr close "${pr_number}" --repo "${REPO}" --comment "Release finished by automation. Merged via git flow release finish." || true | ||
|
|
||
| - name: Workflow summary | ||
| if: always() | ||
| run: | | ||
| { | ||
| echo "## Release Finish On Approval" | ||
| echo "- Repository: ${REPO}" | ||
| echo "- Release branch: ${RELEASE_BRANCH}" | ||
| echo "- Triggered by review: ${{ github.event.review.state }}" | ||
| echo "- Finished release: ${{ steps.approvals.outputs.should_finish || 'false' }}" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Automated Release Workflow | ||
|
|
||
| Automates main release and hotfix flows via GitHub Actions. | ||
|
|
||
| ## Workflows | ||
|
|
||
| ### 1. Component Release (`component-release.yml`) | ||
|
|
||
| Triggered manually from the **Actions** tab via `workflow_dispatch`. | ||
|
|
||
| #### Inputs | ||
|
|
||
| | Input | Required | Description | | ||
| |-------|----------|-------------| | ||
| | `release_version` | Yes | Release version (for example: `5.2.0`, `5.2.0-rc1`) | | ||
| | `release_type` | Yes | `main` or `hotfix` | | ||
| | `release_mode` | Yes | `approvable` or `auto-complete` (ignored for hotfix) | | ||
| | `source_branch` | Hotfix only | Support branch for hotfix (for example: `support/5.0`) | | ||
|
|
||
| #### Concurrency | ||
|
|
||
| Runs are serialized per release key: | ||
|
|
||
| - `component-release-<release_type>-<release_version>` | ||
|
|
||
| This prevents two runs for the same version/type from racing on branches/tags. | ||
|
|
||
| #### Release Modes | ||
|
|
||
| **Main release - auto-complete** | ||
| 1. Validates version format. | ||
| 2. Runs `git flow release start` -> changelog -> `release publish` -> `release finish`. | ||
| 3. Pushes `main`, `develop`, and tags. | ||
|
|
||
| **Main release - approvable** | ||
| 1. Validates version format. | ||
| 2. Runs `git flow release start` -> changelog -> `release publish`. | ||
| 3. Creates a PR: `release/<version>` -> `develop`. | ||
| 4. Stops and waits for PR approval. | ||
| 5. On approval, the second workflow finishes the release. | ||
|
|
||
| **Hotfix (always auto-complete)** | ||
| 1. Requires `source_branch` input. | ||
| 2. Validates `source_branch` against `^[A-Za-z0-9._/-]+$`. | ||
| 3. Creates/uses `hotfix/<version>` from `source_branch`, updates changelog, merges back into `source_branch` only. | ||
| 4. Creates tag `<version>`. | ||
| 5. Pushes only `source_branch` and tag (`main`/`develop` are not pushed). | ||
|
|
||
| ### 2. Component Release Finish On Approval (`component-release-finish-on-approval.yml`) | ||
|
|
||
| Triggered on approved review for `release/*` PRs targeting `develop`. | ||
|
|
||
| #### What it does | ||
| 1. Verifies PR review decision is `APPROVED`. | ||
| 2. Checks out release branch. | ||
| 3. Runs `git flow release finish` (merge to `main` + `develop`, create tag). | ||
| 4. Pushes `main`, `develop`, and tags. | ||
| 5. Closes the release PR. | ||
|
|
||
| ## Authentication and Secrets | ||
|
|
||
| Both workflows use: | ||
|
|
||
| - `RDKCM_DEPLOY_KEY`: SSH private key used by checkout and git push operations. | ||
| - `RDKCM_RDKE`: token used by `gh` API/CLI calls. | ||
|
|
||
| ## Failure Cleanup Safety | ||
|
|
||
| On failure, cleanup only removes refs created by the current run: | ||
|
|
||
| - Deletes tag only if the run created that tag. | ||
| - Deletes `release/<version>` only if the run created that local release branch. | ||
| - Deletes `hotfix/<version>` only if the run created that local hotfix branch. | ||
| - Skips cleanup if repository checkout is unavailable. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Repository Settings | ||
|
|
||
| - **Settings -> Actions -> General -> Workflow permissions**: set to **Read and write permissions**. | ||
| - **Settings -> Actions -> General**: enable **Allow GitHub Actions to create and approve pull requests**. | ||
|
|
||
| ### Branch Protection | ||
|
|
||
| - For approvable flow: enforce PR review rules on `develop`. | ||
| - For auto-complete flow pushes to `develop`: ensure the automation actor has appropriate bypass rights in repository rules. | ||
|
|
||
| ## Version Format | ||
|
|
||
| Accepted examples: | ||
|
|
||
| - `5.2.0` | ||
| - `5.2.0-rc1` | ||
| - `5.2.0v1` | ||
| - `5.2.0.beta2` | ||
|
|
||
| Rule: `major.minor.patch` digits with optional suffix. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.