Skip to content

Commit

Permalink
fix: publish docker image on merge to main and determine release by d…
Browse files Browse the repository at this point in the history
…ev-main PR
  • Loading branch information
scott45 committed Dec 2, 2024
1 parent 45b8e7f commit 6f5f3ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/dockerhub-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ name: Publish Docker image
on:
push:
branches: [ "main" ]
release:
types: [published]

jobs:
push_to_registry:
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
properties:
milestone_number:
type: string
workflow_dispatch:

jobs:
release:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f5f3ad

Please sign in to comment.