Skip to content

docs: add automated changelog documentation #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Update Changelog

on:
pull_request:
types: [closed]
branches:
- main

jobs:
update-changelog:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Get PR title and body
id: pr-info
run: |
echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "${{ github.event.pull_request.body }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Update Changelog
run: |
# Get today's date
DATE=$(date +%Y-%m-%d)

# Read current version from latest entry
CURRENT_VERSION=$(grep -m 1 "## \[v" CHANGELOG.md | sed 's/## \[v\(.*\)\].*/\1/')

# Increment patch version
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
NEW_VERSION="${major}.${minor}.$((patch + 1))"

# Create new changelog entry
NEW_ENTRY="## [v${NEW_VERSION}] - ${DATE}\n\n"

# Determine change type from PR title
PR_TITLE="${{ steps.pr-info.outputs.title }}"
if [[ "$PR_TITLE" == *"feat:"* || "$PR_TITLE" == *"feature:"* ]]; then
CHANGE_TYPE="Added"
elif [[ "$PR_TITLE" == *"fix:"* ]]; then
CHANGE_TYPE="Fixed"
elif [[ "$PR_TITLE" == *"docs:"* ]]; then
CHANGE_TYPE="Documentation"
elif [[ "$PR_TITLE" == *"refactor:"* ]]; then
CHANGE_TYPE="Changed"
elif [[ "$PR_TITLE" == *"security:"* ]]; then
CHANGE_TYPE="Security"
else
CHANGE_TYPE="Changed"
fi

NEW_ENTRY+="### ${CHANGE_TYPE}\n"
NEW_ENTRY+="- ${PR_TITLE#*: }\n"

# Add PR body details if they exist
if [ ! -z "${{ steps.pr-info.outputs.body }}" ]; then
while IFS= read -r line; do
if [[ "$line" =~ ^-[[:space:]].*$ ]]; then
NEW_ENTRY+="$line\n"
fi
done <<< "${{ steps.pr-info.outputs.body }}"
fi

# Add version link at the end
NEW_ENTRY+="\n[v${NEW_VERSION}]: https://github.com/PeterVinter/Manage_linux_docker_containers/releases/tag/v${NEW_VERSION}\n"

# Create temporary file with new content
echo -e "$NEW_ENTRY" > temp_entry
sed -i '7r temp_entry' CHANGELOG.md
rm temp_entry

# Configure Git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

# Create branch, commit and push
git checkout -b bot/update-changelog-v${NEW_VERSION}
git add CHANGELOG.md
git commit -m "docs: update changelog for v${NEW_VERSION}"
git push origin bot/update-changelog-v${NEW_VERSION}

# Create PR
gh pr create \
--title "docs: update changelog for v${NEW_VERSION}" \
--body "Automated changelog update for version ${NEW_VERSION}" \
--base main \
--head bot/update-changelog-v${NEW_VERSION}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 7 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,13 @@ We use GitHub Projects to track the development of features and improvements. Yo

For detailed GitHub CLI commands and workflows, see our [GitHub CLI Workflow Guide](docs/github_cli_workflow.md).

#### Development Workflow

1. **Issue Tracking**
- All features and bugs are tracked as GitHub Issues
- Features are versioned following semantic versioning:
- v1.0.x: Bug fixes and minor improvements
- v1.1.0: New features and functionality
- v2.0.0: Breaking changes

2. **Project Board Columns**
- 📋 Backlog: Planned features and improvements
- 🎯 Priority: Selected for current development
- 🏗️ In Progress: Currently being worked on
- 👀 Review: Ready for code review
- ✅ Done: Completed and merged

3. **Issue Classification**
- Priority: 🔥 High, 🚀 Medium, 🌱 Low
- Effort: 🐘 Large, 🦊 Medium, 🐇 Small
- Target Version: Specified version for release
- Assignees: Developer working on the issue

4. **Contributing**
- Check the [Project Board](https://github.com/PeterVinter/Manage_linux_docker_containers/projects) for available tasks
- Read [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines
- Follow the issue template when creating new issues
- [Create a new issue](https://github.com/PeterVinter/Manage_linux_docker_containers/issues/new) to report bugs or suggest features
### Automated Changelog

This project uses an automated changelog workflow that:
- Updates CHANGELOG.md when PRs are merged to main
- Determines change type from PR title (feat, fix, docs, etc.)
- Increments version number automatically
- Creates a new PR with changelog updates

### Automated Releases

Expand Down
Loading