From 9f233bea255a44c5bb8470330c746ca6a951377e Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Thu, 20 Jul 2023 15:58:57 -0600 Subject: [PATCH 1/4] ci: Set up semantice-release Add a semantic-release configuration to `pyproject.toml`, with a custom `CHANGELOG.md` template. Also add a GitHub Actions workflow. --- .github/workflows/semantic-release.yml | 25 +++++++++++++++++++++ pyproject.toml | 30 +++++++++++++++++++++++++- templates/CHANGELOG.md.j2 | 29 +++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/semantic-release.yml create mode 100644 templates/CHANGELOG.md.j2 diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml new file mode 100644 index 0000000..211f0f9 --- /dev/null +++ b/.github/workflows/semantic-release.yml @@ -0,0 +1,25 @@ +name: Semantic Release + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_TOKEN }} + + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@master + with: + github_token: ${{ secrets.GH_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 110ad3c..47376da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ classifiers = [ "Topic :: Software Development :: Debuggers", "Topic :: Software Development :: Documentation", "Topic :: Software Development :: User Interfaces", - "Typing :: Typed" + "Typing :: Typed", ] @@ -66,3 +66,31 @@ python = ">=3.8" [tool.poetry.dev-dependencies] # At some point, convert from the various requirements.txt files to this # list of Poetry development dependencies. + + +[tool.semantic_release] +commit_message = """ +{version} + +Automatically generated by python-semantic-release.""" +version_variables = [ + "doc/source/conf.py:version", +] +version_toml = [ + "pyproject.toml:tool.poetry.version", +] + + +[tool.semantic_release.branches.master] +match = "master" + + +[tool.semantic_release.changelog] +exclude_commit_patterns = [ + "Merge pull request", +] + + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " diff --git a/templates/CHANGELOG.md.j2 b/templates/CHANGELOG.md.j2 new file mode 100644 index 0000000..b2578e3 --- /dev/null +++ b/templates/CHANGELOG.md.j2 @@ -0,0 +1,29 @@ +# CHANGELOG + + +{% if context.history.unreleased | length > 0 %} +## Unreleased +{% for type_, commits in context.history.unreleased | 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 %} +{% endif %} + +{% 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 "}} +{% 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 %}{% endfor %} From c683d7a9adf415f71816b190954cec4f4be3162d Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Thu, 20 Jul 2023 16:23:29 -0600 Subject: [PATCH 2/4] ci: Add conventional commits job --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccb45f5..3e77c2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,3 +51,11 @@ jobs: - name: Test uninstall run: | python3 -m pip uninstall -y reverse_argparse + + commits: + runs-on: ubuntu-latest + steps: + - name: Conventional Commits + uses: taskmedia/action-conventional-commits@v1.1.3 + with: + types: "build|chore|ci|docs|feat|fix|perf|style|refactor|test" From 1cfed2d0bd8833e633f684e717745ac65997d7ad Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Thu, 20 Jul 2023 16:24:29 -0600 Subject: [PATCH 3/4] ci: Rename workflow file --- .github/workflows/{ci.yml => continuous-integration.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci.yml => continuous-integration.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/continuous-integration.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/continuous-integration.yml From b7b369ec7ad3e8d58fbe0dd39b4acf2bc17bd568 Mon Sep 17 00:00:00 2001 From: "Jason M. Gates" Date: Thu, 20 Jul 2023 16:37:31 -0600 Subject: [PATCH 4/4] fix: Include version in __init__.py --- reverse_argparse/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reverse_argparse/__init__.py b/reverse_argparse/__init__.py index a15c4f1..9d7f43a 100644 --- a/reverse_argparse/__init__.py +++ b/reverse_argparse/__init__.py @@ -7,3 +7,4 @@ from .reverse_argparse import ReverseArgumentParser, quote_arg_if_necessary __all__ = ["ReverseArgumentParser", "quote_arg_if_necessary"] +__version__ = "1.0.0"