-
Notifications
You must be signed in to change notification settings - Fork 1
Add Version receiver and Component Release workflow #139
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
Open
gomathishankar37
wants to merge
2
commits into
develop
Choose a base branch
from
feature/refactoring
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,104 @@ | ||
| name: Release Component | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version_type: | ||
| description: 'Type of version bump (major, minor, patch, none)' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - major | ||
| - minor | ||
| - patch | ||
|
gomathishankar37 marked this conversation as resolved.
|
||
| component_repo: | ||
| description: 'Repository name of the component triggering the release' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-slim | ||
|
gomathishankar37 marked this conversation as resolved.
Outdated
|
||
| steps: | ||
| - name: Set up Git | ||
| run: | | ||
| git config --global user.name "GitHub Actions" | ||
| git config --global user.email "[email protected]" | ||
|
|
||
| - name: Install git-flow and auto-changelog | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y git-flow | ||
| npm install -g auto-changelog | ||
|
|
||
| - name: Clone the component repo and start release | ||
| run: | | ||
| set -e | ||
| git clone https://x-access-token:${{ secrets.RDKCM_RDKE }}@github.com/${{ github.event.inputs.component_repo }} project | ||
|
gomathishankar37 marked this conversation as resolved.
Outdated
|
||
| cd project | ||
| git fetch --all | ||
| git checkout main || git checkout -b main origin/main | ||
| git checkout develop || git checkout -b develop origin/develop | ||
|
|
||
| echo "[component-release.yml] INFO: Configuring git-flow for the repository" | ||
| git config gitflow.branch.master main | ||
| git config gitflow.branch.develop develop | ||
| git config gitflow.prefix.feature feature/ | ||
| git config gitflow.prefix.bugfix bugfix/ | ||
| git config gitflow.prefix.release release/ | ||
| git config gitflow.prefix.hotfix hotfix/ | ||
| git config gitflow.prefix.support support/ | ||
| git config gitflow.prefix.versiontag '' | ||
|
|
||
| echo "[component-release.yml] INFO: git config completed" | ||
| TOP_TAG=$(grep -m 1 -oP '^#### \[\K[^\]]+' CHANGELOG.md) | ||
|
gomathishankar37 marked this conversation as resolved.
Outdated
|
||
| if [[ -z "$TOP_TAG" ]]; then | ||
| echo "[component-release.yml] ERROR: No version found in CHANGELOG.md!" | ||
| exit 1 | ||
| fi | ||
| if [[ ! "$TOP_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "[component-release.yml] ERROR: Invalid version format in CHANGELOG.md: $TOP_TAG. Expected format: major.minor.patch" | ||
| exit 1 | ||
| fi | ||
| IFS='.' read -r major minor patch <<< "$TOP_TAG" | ||
| VERSION_TYPE="${{ github.event.inputs.version_type }}" | ||
| if [[ "$VERSION_TYPE" == "major" ]]; then | ||
| major=$((major + 1)); minor=0; patch=0 | ||
| elif [[ "$VERSION_TYPE" == "minor" ]]; then | ||
| minor=$((minor + 1)); patch=0 | ||
| elif [[ "$VERSION_TYPE" == "patch" ]]; then | ||
| patch=$((patch + 1)) | ||
| fi | ||
| RELEASE_VERSION="$major.$minor.$patch" | ||
| echo "[component-release.yml] INFO: Using calculated version: $RELEASE_VERSION" | ||
| echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | ||
|
|
||
| if git rev-parse "refs/tags/$RELEASE_VERSION" >/dev/null 2>&1; then | ||
| echo "[component-release.yml] INFO: Tag $RELEASE_VERSION already exists. Skipping release." | ||
| exit 0 | ||
| fi | ||
|
gomathishankar37 marked this conversation as resolved.
|
||
|
|
||
| git flow release start $RELEASE_VERSION | ||
| auto-changelog -v $RELEASE_VERSION | ||
| git add CHANGELOG.md | ||
| git commit -m "$RELEASE_VERSION release changelog updates" | ||
| git flow release publish | ||
|
|
||
| - name: Finish release and push | ||
| run: | | ||
| set -e | ||
| cd project | ||
| git flow release finish -m "$RELEASE_VERSION release" $RELEASE_VERSION | ||
| git push origin main | ||
| git push origin --tags | ||
| git push origin develop | ||
|
|
||
| - name: Cleanup tag if workflow fails | ||
| if: failure() | ||
| run: | | ||
| cd project | ||
| git tag -d $RELEASE_VERSION || true | ||
| git push origin :refs/tags/$RELEASE_VERSION || true | ||
|
gomathishankar37 marked this conversation as resolved.
Outdated
|
||
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.