From 0325dc0cd5dacee541f495652857fe43c9e1a3fe Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Mon, 24 Jul 2023 15:11:21 -0600 Subject: [PATCH] fix: Semantic release configuration * Add `__init__.py` to the files modified. * Fix the `__version__` in that file. * Remove trailing space in CHANGELOG template. * Add build command. * Make release commit match conventional standard. * Add release notes template. * Publish releases to PyPI and GitHub Releases. --- .github/workflows/semantic-release.yml | 14 +++++++++++++- CHANGELOG.md | 4 ++-- pyproject.toml | 4 +++- reverse_argparse/__init__.py | 2 +- templates/CHANGELOG.md.j2 | 4 ++-- templates/release_notes.md.j2 | 11 +++++++++++ 6 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 templates/release_notes.md.j2 diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml index 211f0f9..04ccb3c 100644 --- a/.github/workflows/semantic-release.yml +++ b/.github/workflows/semantic-release.yml @@ -11,7 +11,6 @@ jobs: concurrency: release permissions: id-token: write - contents: write steps: - uses: actions/checkout@v3 @@ -20,6 +19,19 @@ jobs: token: ${{ secrets.GH_TOKEN }} - name: Python Semantic Release + id: release uses: python-semantic-release/python-semantic-release@master with: github_token: ${{ secrets.GH_TOKEN }} + root_options: "-vv" + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + if: steps.release.outputs.released == 'true' + + - name: Publish to GitHub Releases + uses: python-semantic-release/upload-to-gh-release@main + if: steps.release.outputs.released == 'true' + with: + github_token: ${{ secrets.GH_TOKEN }} + root_options: "-vv" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9877dcc..956a558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ## v1.0.1 (2023-07-20) -### Continuous Integration +### Continuous Integration * ci: Rename workflow file ([`1cfed2d`](https://github.com/sandialabs/reverse_argparse/commit/1cfed2d0bd8833e633f684e717745ac65997d7ad)) * ci: Add conventional commits job ([`c683d7a`](https://github.com/sandialabs/reverse_argparse/commit/c683d7a9adf415f71816b190954cec4f4be3162d)) * ci: Set up semantice-release ([`9f233be`](https://github.com/sandialabs/reverse_argparse/commit/9f233bea255a44c5bb8470330c746ca6a951377e)) @@ -45,7 +45,7 @@ * chore: Add VS Code settings ([`cc4edb2`](https://github.com/sandialabs/reverse_argparse/commit/cc4edb2611ed25a8a90751c03c8f69c8221db642)) * chore: Add __pycache__ to .gitignore ([`48a8acd`](https://github.com/sandialabs/reverse_argparse/commit/48a8acd77bad6b83a735b0540b5b184920715da9)) -### Continuous Integration +### Continuous Integration * ci: Remove documentation jobs ([`81ab9c2`](https://github.com/sandialabs/reverse_argparse/commit/81ab9c230c3a19c8268b878c6e9364e3e1882266)) Let ReadTheDocs test the PR instead. diff --git a/pyproject.toml b/pyproject.toml index c0ccbac..235b1a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,12 +69,14 @@ python = ">=3.8" [tool.semantic_release] +build_command = "python3 -m pip install poetry && poetry build" commit_message = """ -{version} +chore: Release v{version} Automatically generated by python-semantic-release.""" version_variables = [ "doc/source/conf.py:version", + "reverse_argparse/__init__.py:__version__", ] version_toml = [ "pyproject.toml:tool.poetry.version", diff --git a/reverse_argparse/__init__.py b/reverse_argparse/__init__.py index 9d7f43a..5b9975b 100644 --- a/reverse_argparse/__init__.py +++ b/reverse_argparse/__init__.py @@ -7,4 +7,4 @@ from .reverse_argparse import ReverseArgumentParser, quote_arg_if_necessary __all__ = ["ReverseArgumentParser", "quote_arg_if_necessary"] -__version__ = "1.0.0" +__version__ = "1.0.1" diff --git a/templates/CHANGELOG.md.j2 b/templates/CHANGELOG.md.j2 index b2578e3..0896a6a 100644 --- a/templates/CHANGELOG.md.j2 +++ b/templates/CHANGELOG.md.j2 @@ -4,7 +4,7 @@ {% if context.history.unreleased | length > 0 %} ## Unreleased {% for type_, commits in context.history.unreleased | dictsort %} -### {{ type_ | capitalize if type_ != "ci" else "Continuous Integration "}} +### {{ type_ | capitalize if type_ != "ci" else "Continuous Integration" }} {% for commit in commits -%} {%- set summary = commit.message.rstrip().splitlines()[0] -%} {%- set details = commit.message.rstrip().splitlines()[2:] -%} @@ -18,7 +18,7 @@ {% for version, release in context.history.released.items() -%} ## {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }}) {% for type_, commits in release["elements"] | dictsort %} -### {{ type_ | capitalize if type_ != "ci" else "Continuous Integration "}} +### {{ type_ | capitalize if type_ != "ci" else "Continuous Integration" }} {% for commit in commits -%} {%- set summary = commit.message.rstrip().splitlines()[0] -%} {%- set details = commit.message.rstrip().splitlines()[2:] -%} diff --git a/templates/release_notes.md.j2 b/templates/release_notes.md.j2 new file mode 100644 index 0000000..d546bb0 --- /dev/null +++ b/templates/release_notes.md.j2 @@ -0,0 +1,11 @@ +# {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }}) +{% for type_, commits in release["elements"] | dictsort %} +## {{ type_ | capitalize if type_ != "ci" else "Continuous Integration" }} +{% for commit in commits -%} +{%- set summary = commit.message.rstrip().splitlines()[0] -%} +{%- set details = commit.message.rstrip().splitlines()[2:] -%} +* {{ summary }} ([`{{ commit.hexsha[:7] }}`]({{ commit.hexsha | commit_hash_url }})) +{% if details %} +{% for line in details %}{% if line.strip() %} {{ line }}{% endif %} +{% endfor %}{% endif %}{% endfor -%} +{% endfor %}