Bump unichat #344
This file contains 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
name: Basic Formatting and Updates | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
format_and_update: | |
runs-on: ubuntu-latest | |
env: | |
CHANGELOG_FILE: CHANGELOG.md | |
FETCH_LIMIT: 20 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.FETCH_LIMIT }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install black isort | |
- name: Formatting | |
run: | | |
black --line-length 120 . | |
isort . | |
- name: Generate Changelog | |
run: | | |
categories=("Features" "Improvements" "Bug Fixes" "Others") | |
patterns=("\[feature\(s\)\?\]" "\[improvement\(s\)\?\]" "\[bugfix\(es\)\?\]" "\[other\(s\)\?\]") | |
echo -n "" > ${{ env.CHANGELOG_FILE }} | |
for i in "${!categories[@]}"; do | |
entries=$(git log -${{env.FETCH_LIMIT}} --pretty=format:"%h %s" | grep -i "${patterns[$i]}" | sed -E "s/${patterns[$i]} //" | awk '{print "- ["$1"] "substr($0, index($0,$2))}') | |
if [ -n "$entries" ]; then | |
echo -e "> ${categories[$i]}:\n$entries\n" >> ${{ env.CHANGELOG_FILE }} | |
fi | |
done | |
echo -e "\n---" >> ${{ env.CHANGELOG_FILE }} | |
- name: Bump version | |
run: | | |
cd app-data | |
bash bump-version.sh | |
cd - | |
- name: Commit changes | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
git add -A | |
git commit -m "Formatting and updating the changelog." || echo "No changes to commit, continuing workflow" | |
- name: Push changes | |
if: ${{ success() }} | |
run: git push |