diff --git a/.github/workflows/dockerhub-image-build.yml b/.github/workflows/dockerhub-image-build.yml index 8e226f1..0195ce5 100644 --- a/.github/workflows/dockerhub-image-build.yml +++ b/.github/workflows/dockerhub-image-build.yml @@ -16,8 +16,6 @@ name: Publish Docker image on: push: branches: [ "main" ] - release: - types: [published] jobs: push_to_registry: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3058564..05c0a4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ on: properties: milestone_number: type: string + workflow_dispatch: jobs: release: @@ -41,33 +42,32 @@ jobs: if: ${{ steps.release-label.outputs.level != null }} with: semver_only: true + + - name: Get Last Merged PR + id: get_merged_pr + uses: actions-ecosystem/action-get-merged-pull-request@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} - # Determine the release type (major, minor, patch) based on commit messages - - name: Determine Release Type + # Determine the release type (major, minor, patch) based on Last Merged PR Title + - name: Determine Release Type from PR Title id: determine_release run: | - PREV_VERSION=$(git describe --abbrev=0 --tags) - echo "Previous Version: $PREV_VERSION" - - COMMIT_MESSAGES=$(git log $PREV_VERSION^..HEAD --format=%B) - echo "Commit Messages: $COMMIT_MESSAGES" - - # Determine release type based on commit messages and labels - RELEASE_TYPE="patch" # Default to patch - - if echo "$COMMIT_MESSAGES" | grep -q -e "BREAKING CHANGE:"; then + PR_TITLE="${{ steps.get_merged_pr.outputs.title }}" + echo "PR Title: $PR_TITLE" + + RELEASE_TYPE="patch" # Default release type + if echo "$PR_TITLE" | grep -q "^BREAKING CHANGE:"; then RELEASE_TYPE="major" - elif echo "$COMMIT_MESSAGES" | grep -q -e "feat!:"; then + elif echo "$PR_TITLE" | grep -q "^feat!:"; then RELEASE_TYPE="major" - elif echo "$COMMIT_MESSAGES" | grep -q -e "feat:"; then + elif echo "$PR_TITLE" | grep -q "^feat:"; then RELEASE_TYPE="minor" - elif echo "$COMMIT_MESSAGES" | grep -q -e "feat:" && (echo "$COMMIT_MESSAGES" | grep -q -e "fix:" || echo "$COMMIT_MESSAGES" | grep -q -e "enhancement:" || echo "$COMMIT_MESSAGES" | grep -q -e "docs:" || echo "$COMMIT_MESSAGES" | grep -q -e "refactor:" || echo "$COMMIT_MESSAGES" | grep -q -e "chore:"); then - RELEASE_TYPE="minor" - elif echo "$COMMIT_MESSAGES" | grep -q -e "fix:" -e "enhancement:" -e "docs:" -e "refactor:" -e "chore:" -e "build:" -e "ci:" -e "perf:" -e "style:" -e "test:" -e "chore(deps):" -e "chore(deps-dev):"; then + else RELEASE_TYPE="patch" fi - - echo "Release Type: $RELEASE_TYPE" + + echo "Determined Release Type: $RELEASE_TYPE" echo "::set-output name=release_type::$RELEASE_TYPE" # Bump the version based on the determined release type