Add workflow and script for updating changelog

This commit is contained in:
Zach Borboa
2022-09-22 19:23:39 -07:00
parent e8b66975d0
commit 8363b24ad8
3 changed files with 50 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
name: Update Changelog
jobs:
release:
# Prevent this workflow from running elsewhere.
if: github.repository_owner == 'php-curl-class'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update list
run: python scripts/update_changelog.py
+2
View File
@@ -4,6 +4,8 @@ PHP Curl Class uses semantic versioning with version numbers written as `MAJOR.M
`MINOR` and `PATCH` version changes. It is recommended to review `MAJOR` changes prior to upgrade as there may be
backwards-incompatible changes that will affect existing usage.
<!-- CHANGELOG_PLACEHOLDER -->
## 9.6.1 - 2022-06-30
### Fixed
+34
View File
@@ -0,0 +1,34 @@
from datetime import datetime
from pathlib import Path
CURRENT_FILE = Path(__file__)
ROOT = CURRENT_FILE.parents[1]
def main():
# TODO: Fetch actual semantic version.
release_version = '9.6.2'
release_date = datetime.today().strftime('%Y-%m-%d')
release_title = '{} - {}'.format(release_version, release_date)
# TODO: Fetch actual list of changes.
release_changes = 'Some change'
release_content = (
'## {}\n'
'\n'
'{}'
).format(release_title, release_changes)
changelog_path = ROOT / 'CHANGELOG.md'
old_content = changelog_path.read_text()
new_content = old_content.replace(
'<!-- CHANGELOG_PLACEHOLDER -->',
'<!-- CHANGELOG_PLACEHOLDER -->\n\n{}'.format(release_content),
)
print(new_content[:500])
changelog_path.write_text(new_content)
if __name__ == '__main__':
main()