Skip to content

Commit

Permalink
Merge pull request #88 from MolarVerse/hotfix/1.0.11
Browse files Browse the repository at this point in the history
Hotfix/1.0.11
  • Loading branch information
97gamjak authored Jun 1, 2024
2 parents 7f32b4b + 3cdd91b commit 6999330
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 23 deletions.
148 changes: 148 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/bash

message=$(cat .git/COMMIT_EDITMSG)
lowercase_message=${message,,}

# Check for patterns and handle errors
matched=false

# Features
if [[ "$lowercase_message" =~ ^feat(\(.+\))?: ]]; then
matched=true
group="Feature"
fi

# Bug Fixes
if [[ "$lowercase_message" =~ ^fix(\(.+\))?: ]]; then
matched=true
group="Fix"
fi

if [[ "$lowercase_message" =~ ^docs(\(.+\))?: ]]; then
matched=true
group="Docs"
elif [[ "$lowercase_message" =~ ^doc(\(.+\))?: ]]; then
matched=true
group="Docs"
fi

if [[ "$lowercase_message" =~ ^style(\(.+\))?: ]]; then
matched=true
group="Style"
fi

if [[ "$lowercase_message" =~ ^refactor(\(.+\))?: ]]; then
matched=true
group="Refactor"
elif [[ "$lowercase_message" =~ ^ref(\(.+\))?: ]]; then
matched=true
group="Refactor"
fi

if [[ "$lowercase_message" =~ ^perf(\(.+\))?: ]]; then
matched=true
group="Performance"
fi

if [[ "$lowercase_message" =~ ^test(\(.+\))?: ]]; then
matched=true
group="Test"
elif [[ "$lowercase_message" =~ ^tests(\(.+\))?: ]]; then
matched=true
group="Test"
fi

#chore
if [[ "$lowercase_message" =~ ^chore(\(.+\))?: ]]; then
matched=true
group="Chore"
fi

#merge
if [[ "$lowercase_message" =~ ^merge(\(.+\))?: ]]; then
matched=true
group="Merge"
fi

# Reverts
if [[ "$lowercase_message" =~ ^revert(\(.+\))?: ]]; then
matched=true
group="Revert"
fi

if [[ "$lowercase_message" =~ ^build(\(.+\))?: ]]; then
matched=true
group="Breaking"
fi

# Examples
if [[ "$lowercase_message" =~ ^example(\(.+\))?: ]]; then
matched=true
group="Example"
elif [[ "$lowercase_message" =~ ^examples(\(.+\))?: ]]; then
matched=true
group="Example"
fi

# Dependency Updates (informational)
if [[ "$lowercase_message" =~ ^deps(\(.+\))?: ]]; then
matched=true
group="Dependency"
fi

# ci
if [[ "$lowercase_message" =~ ^ci(\(.+\))?: ]]; then
matched=true
group="CI"
fi

# ... (similar checks for other patterns in the list)

# No match found
if ! $matched; then
echo "Error: Commit message header '$message' does not match any defined pattern!\n"

#list me all possible patterns per group in a nice formatted output
echo "Possible patterns are:"
echo " - Group: Pattern(s)"
echo " - --------------------------------------------"
echo " - Feature: feat:"
echo " - Fix: fix:"
echo " - Docs: docs:, doc:"
echo " - Style: style:"
echo " - Refactor: refactor:, ref:"
echo " - Performance: perf:"
echo " - Test: test:, tests:"
echo " - Chore: chore:"
echo " - Merge: merge:"
echo " - Revert: revert:"
echo " - Build: build:"
echo " - Example: example:, examples:"
echo " - Dependency: deps:"
echo " - CI: ci:"
# ... (similar output for other patterns in the list)
echo " - --------------------------------------------\n"

echo "Please use one of the patterns above in the commit message header."
echo "You can also add a scope in parentheses after the pattern (e.g. 'feat(scope): ...')."
exit 1
fi

# Matched a pattern, check for skip flag (optional)
if [[ ${skip+unset} ]]; then # Check if skip variable is set
if [[ "$lowercase_message" =~ $skip ]]; then
echo "Skipping commit '$message' (marked for skipping)"
exit 0 # Allow skipping with exit code 0 for a clean commit process
fi
fi

# Check for duplicate Signed-off-by lines (optional)
test "" = "$(grep '^Signed-off-by: ' "$1" | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 "Error: Duplicate Signed-off-by lines found in commit message!"
exit 1
}

# Commit passed checks (optional)
echo "Commit message '$message' ($group) looks good!"

# Script exits successfully (no need for explicit exit code)
57 changes: 34 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ jobs:
with:
fetch-depth: 0

- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: build git-changelog
run: |
python3 -m pip install git-changelog
- name: Get previous tag
id: previousTag
run: |
Expand All @@ -75,36 +84,38 @@ jobs:
echo "previousTag=$name" >> $GITHUB_ENV
echo "::set-output name=previousTag::$name"
- name: generate new changelog
run: |
name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
echo "git-changelog=$(git-changelog -F "$name.. -c angular")" >> $GITHUB_ENV
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--generate-notes
# - name: Create GitHub Changelog.md
# env:
# GITHUB_TOKEN: ${{ github.token }}
# run: >-
# gh release view
# '${{ github.ref_name }}'

# - name: Add .github/.pylint_cache to the commit
# run: |
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# git config --global user.name "github-actions[bot]"

# git add CHANGELOG.md
# git commit -m "Docs: Update CHANGELOG.md on release event"

# - name: Push changes
# if: github.event_name == 'push'
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: 'main'
--notes "${changelog}"
- name: Build CHANGELOG.md
run: |
git-changelog -o CHANGELOG.md -c angular
- name: Add CHANGELOG.md to commit
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add CHANGELOG.md
git commit -m "Docs: Update CHANGELOG.md on release event"
- name: Push changes
if: github.event_name == 'push'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'main'

pypi-release-update:
name: >-
Expand Down

0 comments on commit 6999330

Please sign in to comment.