Generate Changelog #125
Workflow file for this run
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: Generate Changelog | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The version number to display in the changelog | |
required: true | |
origin-type: | |
type: choice | |
description: The type of origin to use | |
default: '1' | |
options: | |
- Date | |
- Commit | |
origin: | |
type: text | |
description: The commit ID or date that the changelog should start from | |
required: true | |
jobs: | |
Get-Changelog: | |
runs-on: ubuntu-latest | |
env: | |
CHANGELOG_DIR: docs/articles/changelogs | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Prepare changelog file | |
run: | | |
VERSION=${{inputs.version}} | |
VERSION_FN=${VERSION//./_} | |
rm -f "${CHANGELOG_DIR}/CHANGELOG_${VERSION_FN}.md" | |
echo -e $"# Version ${VERSION} Changelog " >> "${CHANGELOG_DIR}/CHANGELOG_$VERSION_FN.md" | |
echo -e $"<br>" >> "${CHANGELOG_DIR}/CHANGELOG_$VERSION_FN.md" | |
echo -e $"" >> "${CHANGELOG_DIR}/CHANGELOG_$VERSION_FN.md" | |
echo -e $"| Commit | Changes |" >> "${CHANGELOG_DIR}/CHANGELOG_${VERSION_FN}.md" | |
echo -e $"| ------ | ------- |" >> "${CHANGELOG_DIR}/CHANGELOG_${VERSION_FN}.md" | |
- name: Get Changes Since Date | |
if: "${{github.event.inputs.origin-type == 'Date'}}" | |
run: | | |
VERSION=${{inputs.version}} | |
VERSION_FN=${VERSION//./_} | |
CHANGES=$(git log --no-merges --pretty="| [[%h](https://github.com/Syncaidius/MoltenEngine/commits/%H)] | %s___%b |" --after=${{inputs.origin}}) | |
CHANGES=${CHANGES//$'['/$'___['} | |
CHANGES=${CHANGES//$'___'/'<br>'} | |
CHANGES=${CHANGES//$'[<br>['/'[['} | |
CHANGES=${CHANGES//$'| <br>['/'| ['} | |
CHANGES=${CHANGES//$'<br><br>'/'<br>'} | |
CHANGES=${CHANGES//$'\r\n'/$'<br>'} | |
CHANGES=${CHANGES//$'<br> |'/$' |\r\n'} | |
echo $CHANGES >> "${CHANGELOG_DIR}/CHANGELOG_${VERSION_FN}.md" | |
- name: Get Changes Since Commit | |
if: "${{github.event.inputs.origin-type == 'Commit'}}" | |
run: | | |
VERSION=${{inputs.version}} | |
VERSION_FN=${VERSION//./_} | |
CHANGES=$(git log --no-merges --pretty="| [[%h](https://github.com/Syncaidius/MoltenEngine/commits/%H)] | %s___%b |" ${{inputs.origin}}..HEAD) | |
CHANGES=${CHANGES//$'['/$'___['} | |
CHANGES=${CHANGES//$'___'/'<br>'} | |
CHANGES=${CHANGES//$'[<br>['/'[['} | |
CHANGES=${CHANGES//$'| <br>['/'| ['} | |
CHANGES=${CHANGES//$'<br><br>'/'<br>'} | |
CHANGES=${CHANGES//$'\r\n'/$'<br>'} | |
CHANGES=${CHANGES//$'<br> |'/$' |\r\n'} | |
echo $CHANGES >> "${CHANGELOG_DIR}/CHANGELOG_${VERSION_FN}.md" | |
- name: Commit | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Updated V${{inputs.version}} changelog |