From 170788a653e554c2526ffb68566a6baf90052d37 Mon Sep 17 00:00:00 2001 From: John Ajera <37360952+jajera@users.noreply.github.com> Date: Sat, 26 Apr 2025 04:55:05 +0000 Subject: [PATCH] chore: cleaup code removes unnecessary codes --- .github/workflows/commitmsg-conform.yml | 2 +- .github/workflows/tag.yml | 124 ------------------------ 2 files changed, 1 insertion(+), 125 deletions(-) delete mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/commitmsg-conform.yml b/.github/workflows/commitmsg-conform.yml index 2282eb9..408f9f5 100644 --- a/.github/workflows/commitmsg-conform.yml +++ b/.github/workflows/commitmsg-conform.yml @@ -12,7 +12,7 @@ on: dco: false gpg: required: false - gitHubOrganization: stacksmiths + gitHubOrganization: cloudbuildlab spellcheck: locale: US maximumOfOneCommit: false diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml deleted file mode 100644 index a5991aa..0000000 --- a/.github/workflows/tag.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: Tag Management - -on: - pull_request: - types: [labeled, closed] - push: - branches: - - main - -permissions: - contents: write - -jobs: - tag: - if: | - (github.event_name == 'pull_request' && - github.event.action == 'labeled' && - (github.event.pull_request.labels.*.name == 'version:major' || - github.event.pull_request.labels.*.name == 'version:minor' || - github.event.pull_request.labels.*.name == 'version:patch')) || - (github.event_name == 'pull_request' && - github.event.action == 'closed' && - github.event.pull_request.merged == true && - github.event.pull_request.labels.*.name != 'version:major' && - github.event.pull_request.labels.*.name != 'version:minor' && - github.event.pull_request.labels.*.name != 'version:patch') || - (github.event_name == 'push' && - github.ref == 'refs/heads/main' && - !contains(github.event.head_commit.message, 'Merge pull request')) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get current version - id: get_version - run: | - # Get the latest tag - git fetch --tags - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") - CURRENT_VERSION=${LATEST_TAG#v} - - # Debug information - echo "Event name: ${{ github.event_name }}" - echo "Event action: ${{ github.event.action }}" - echo "Commit message: ${{ github.event.head_commit.message }}" - - # Determine version bump type - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - if [[ "${{ github.event.action }}" == "labeled" ]]; then - if [[ "${{ github.event.pull_request.labels.*.name }}" == "version:major" ]]; then - BUMP_TYPE="major" - elif [[ "${{ github.event.pull_request.labels.*.name }}" == "version:minor" ]]; then - BUMP_TYPE="minor" - elif [[ "${{ github.event.pull_request.labels.*.name }}" == "version:patch" ]]; then - BUMP_TYPE="patch" - else - echo "No version label provided. Skipping version bump." - exit 0 - fi - else - # PR was closed/merged without version label - # Check PR title and body for conventional commit types - PR_TITLE="${{ github.event.pull_request.title }}" - PR_BODY="${{ github.event.pull_request.body }}" - - if [[ "$PR_TITLE" =~ ^(feat|feature)(\([a-z0-9-]+\))?: ]]; then - BUMP_TYPE="minor" - elif [[ "$PR_TITLE" =~ ^(fix|bugfix|hotfix)(\([a-z0-9-]+\))?: ]]; then - BUMP_TYPE="patch" - elif [[ "$PR_TITLE" =~ ^(breaking|break)(\([a-z0-9-]+\))?: ]]; then - BUMP_TYPE="major" - else - # Default to patch for merged PRs without clear indicators - BUMP_TYPE="patch" - fi - fi - else - # Only process direct pushes that aren't PR merges - if [[ "${{ contains(github.event.head_commit.message, 'Merge pull request') }}" == "true" ]]; then - echo "Skipping version bump for PR merge commit" - exit 0 - fi - BUMP_TYPE="patch" - fi - - # Bump version - IFS='.' read -r major minor patch <<< "$CURRENT_VERSION" - case "$BUMP_TYPE" in - major) NEW_VERSION="$((major + 1)).0.0" ;; - minor) NEW_VERSION="$major.$((minor + 1)).0" ;; - patch) NEW_VERSION="$major.$minor.$((patch + 1))" ;; - esac - - # Extract major version - MAJOR_VERSION="v${NEW_VERSION%%.*}" - - echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT - echo "new_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT - echo "major_version=$MAJOR_VERSION" >> $GITHUB_OUTPUT - echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT - - - name: Create and push tag - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - # Check if tag already exists - if git rev-parse "v${{ steps.get_version.outputs.new_version }}" >/dev/null 2>&1; then - echo "Tag v${{ steps.get_version.outputs.new_version }} already exists. Skipping tag creation." - exit 0 - fi - - # Create and push version tag - echo "Creating tag v${{ steps.get_version.outputs.new_version }}" - git tag -a "v${{ steps.get_version.outputs.new_version }}" -m "Release v${{ steps.get_version.outputs.new_version }} (bump: ${{ steps.get_version.outputs.bump_type }})" - git push origin "v${{ steps.get_version.outputs.new_version }}" - - # Update major version tag - echo "Updating major version tag ${{ steps.get_version.outputs.major_version }}" - git tag -fa "${{ steps.get_version.outputs.major_version }}" -m "Update major version tag" - git push origin "${{ steps.get_version.outputs.major_version }}" --force