diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 000000000..5e574c318 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,59 @@ +name: Populate Changelog +on: + pull_request: + types: [closed] + branches: + - develop + +jobs: + Changelog: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Clone RocketPy + uses: actions/checkout@main + with: + repository: RocketPy-Team/RocketPy + ref: develop + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Update Changelog + env: + PR_TITLE: ${{ github.event.pull_request.title }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }} + run: | + SECTION="### Added" + PREFIX="ENH" + + if [[ "$PR_LABELS" == *"Bug"* ]]; then + SECTION="### Fixed" + PREFIX="BUG" + elif [[ "$PR_LABELS" == *"Refactor"* ]]; then + SECTION="### Changed" + PREFIX="MNT" + elif [[ "$PR_LABELS" == *"Docs"* ]] && [[ "$PR_LABELS" == *"Git housekeeping"* ]]; then + SECTION="### Changed" + PREFIX="DOC" + elif [[ "$PR_LABELS" == *"Tests"* ]]; then + SECTION="### Changed" + PREFIX="TST" + elif [[ "$PR_LABELS" == *"Docs"* ]]; then + # Only documentation -> Added section + SECTION="### Added" + PREFIX="DOC" + fi + + ENTRY="- $PREFIX: $PR_TITLE [#$PR_NUMBER](https://github.com/RocketPy-Team/RocketPy/pull/$PR_NUMBER)" + SECTION_LINE=$(grep -n "^$SECTION$" CHANGELOG.md | head -1 | cut -d: -f1) + + sed -i "$((SECTION_LINE + 1))a\\$ENTRY" CHANGELOG.md + + - name: Push Changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add CHANGELOG.md + git commit -m "DOC: Update Changelog for PR #${{ github.event.pull_request.number }}" + git push diff --git a/CHANGELOG.md b/CHANGELOG.md index 6815a39f7..6b1f3a0eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). Attention: The newest changes should be on top --> ### Added + +- ENH: Auto Populate Changelog [#919](https://github.com/RocketPy-Team/RocketPy/pull/919) - ENH: Add background map auto download functionality to Monte Carlo plots [#896](https://github.com/RocketPy-Team/RocketPy/pull/896) - MNT: net thrust addition to 3 dof in flight class [#907] (https://github.com/RocketPy-Team/RocketPy/pull/907) - ENH: 3-dof lateral motion improvement [#883](https://github.com/RocketPy-Team/RocketPy/pull/883) diff --git a/docs/development/first_pr.rst b/docs/development/first_pr.rst index 5f3eb876c..c0b07e7f1 100644 --- a/docs/development/first_pr.rst +++ b/docs/development/first_pr.rst @@ -96,14 +96,13 @@ The CHANGELOG file ------------------ We keep track of the changes in the ``CHANGELOG.md`` file. -When you open a PR, you should add a new entry to the "Unreleased" section of the file. -This entry should simply be the title of your PR. +When you open a PR, you should see the "Unreleased" section of the file. +An entry will simply contain the title of your PR if merged. .. note:: - In the future we would like to automate the CHANGELOG update, but for now \ - it is a manual process, unfortunately. - + The CHANGELOG is auto-updated once a PR is merged based on the associated labels, \ + which are assigned by the maintainers. The review process ------------------ diff --git a/docs/development/style_guide.rst b/docs/development/style_guide.rst index 510a49560..15a80e5e4 100644 --- a/docs/development/style_guide.rst +++ b/docs/development/style_guide.rst @@ -162,15 +162,16 @@ Standard acronyms to start the commit message with are:: Pull Requests ^^^^^^^^^^^^^ -When opening a Pull Request, the name of the PR should be clear and concise. -Similarly to the commit messages, the PR name should start with an acronym indicating the type of PR -and then a brief description of the changes. +When opening a Pull Request, the title should be clear and concise. +It should contain only a brief desctiption of the changes without the acronym (e.g. ENH:, BUG:). +The maintainers will label your PR accordingly, which will add a prefix via a workflow to indicate +type of the PR in the CHANGELOG file. Here is an example of a good PR name: -- ``BUG: fix the Frequency Response plot of the Flight class`` +- ``fix the Frequency Response plot of the Flight class`` -The PR description explain the changes and motivation behind them. There is a template \ +The PR description explains the changes and motivation behind them. There is a template \ available when opening a PR that can be used to guide you through the process of both \ describing the changes and making sure all the necessary steps were taken. Of course, \ you can always modify the template or add more information if you think it is necessary.