Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action that finds unreleased items to require the full path to the output files that are used by python-semantic-release's templates #14

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions .github/workflows/_reusable-package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,15 @@ on:
required: false
default: '["ubuntu", "windows", "macos"]'
type: string
previous-changelog-filename:
description: The name of the file to copy the contents of the changelog into
for use in the `python-semantic-release` templates. This file will be created
inside of the directory defined by the `[tool.semantic_release.changelog.template_dir]`
key in the `pyproject.toml` file.
previous-changelog-filepath:
description: The full path of the file to copy the contents of the changelog
into for use in the `python-semantic-release` templates.
required: false
type: string
default: .previous_changelog_for_template.md
previous-release-notes-filename:
description: The name of the file to copy the contents of the `## Unreleased`
section of the changelog into for use in the GitHub Release Notes. This
file will be created inside of the directory defined by the `[tool.semantic_release.changelog.template_dir]`
key in the `pyproject.toml` file.
previous-release-notes-filepath:
description: The full path of the file to copy the contents of the `## Unreleased`
section of the changelog into for use in the GitHub Release Notes.
required: false
type: string
default: .previous_release_notes_for_template.md
Expand Down Expand Up @@ -97,14 +93,14 @@ jobs:
uses: ./actions/find_unreleased_changelog_items
with:
release-level: ${{ inputs.release-level }}
previous-changelog-filename: ${{ inputs.previous-changelog-filename }}
previous-release-notes-filename: ${{ inputs.previous-release-notes-filename }}
previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }}
previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }}
- if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository
uses: tektronix/python-package-ci-cd/actions/[email protected]
with:
release-level: ${{ inputs.release-level }}
previous-changelog-filename: ${{ inputs.previous-changelog-filename }}
previous-release-notes-filename: ${{ inputs.previous-release-notes-filename }}
previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }}
previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }}
# Update the package version using the python-semantic-release package (https://github.com/python-semantic-release/python-semantic-release)
# This job requires a Personal Access Token (Classic) with
# the public_repo permission. It also needs a private/public
Expand All @@ -127,13 +123,13 @@ jobs:
- if: ${{ endsWith(github.repository, '/python-package-ci-cd') }} # Run the local action when this is run in the python-package-ci-cd repository
uses: ./actions/find_unreleased_changelog_items
with:
previous-changelog-filename: ${{ inputs.previous-changelog-filename }}
previous-release-notes-filename: ${{ inputs.previous-release-notes-filename }}
previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }}
previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }}
- if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository
uses: tektronix/python-package-ci-cd/actions/[email protected]
with:
previous-changelog-filename: ${{ inputs.previous-changelog-filename }}
previous-release-notes-filename: ${{ inputs.previous-release-notes-filename }}
previous-changelog-filepath: ${{ inputs.previous-changelog-filepath }}
previous-release-notes-filepath: ${{ inputs.previous-release-notes-filepath }}
- name: Python Semantic Release
uses: python-semantic-release/[email protected]
id: release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
- uses: ./actions/find_unreleased_changelog_items
with:
release-level: patch
previous-changelog-filename: .testing_previous_changelog_for_template.md
previous-release-notes-filename: .testing_previous_release_notes_for_template.md
previous-changelog-filepath: python_semantic_release_templates/.testing_previous_changelog_for_template.md
previous-release-notes-filepath: python_semantic_release_templates/.testing_previous_release_notes_for_template.md
- name: Get Job Summary
uses: austenstone/[email protected]
id: job-summary
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
- id: remove-tabs
- id: forbid-tabs
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: e2dde74d0702d15f4f43e4f4fb93e301b4bc1e30 # frozen: 0.29.1
rev: 5c70e3d884fdbe99af42f2714a444e39f321498d # frozen: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-actions
Expand Down
2 changes: 1 addition & 1 deletion actions/create_unique_testpypi_version/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ attrs==24.2.0 ; python_version >= "3.12" and python_version < "3.13"
beautifulsoup4==4.12.3 ; python_version >= "3.12" and python_version < "3.13"
certifi==2024.7.4 ; python_version >= "3.12" and python_version < "3.13"
charset-normalizer==3.3.2 ; python_version >= "3.12" and python_version < "3.13"
idna==3.7 ; python_version >= "3.12" and python_version < "3.13"
idna==3.8 ; python_version >= "3.12" and python_version < "3.13"
mailbits==0.2.1 ; python_version >= "3.12" and python_version < "3.13"
packaging==24.1 ; python_version >= "3.12" and python_version < "3.13"
poetry-core==1.9.0 ; python_version >= "3.12" and python_version < "3.13"
Expand Down
16 changes: 6 additions & 10 deletions actions/find_unreleased_changelog_items/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ inputs:
minor for backward compatible larger changes,
major for non-backward compatible changes.
required: false
previous-changelog-filename:
description: The name of the file to copy the contents of the changelog into for
use in the `python-semantic-release` templates. This file will be created inside
of the directory defined by the `[tool.semantic_release.changelog.template_dir]`
key in the `pyproject.toml` file.
previous-changelog-filepath:
description: The full path of the file to copy the contents of the changelog into
for use in the `python-semantic-release` templates.
required: false
default: .previous_changelog_for_template.md
previous-release-notes-filename:
description: The name of the file to copy the contents of the `## Unreleased`
section of the changelog into for use in the GitHub Release Notes. This file
will be created inside of the directory defined by the `[tool.semantic_release.changelog.template_dir]`
key in the `pyproject.toml` file.
previous-release-notes-filepath:
description: The full path of the file to copy the contents of the `## Unreleased`
section of the changelog into for use in the GitHub Release Notes.
required: false
default: .previous_release_notes_for_template.md
runs:
Expand Down
31 changes: 4 additions & 27 deletions actions/find_unreleased_changelog_items/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,9 @@
import re
import shutil

import tomli

PYPROJECT_FILE = pathlib.Path("./pyproject.toml")
CHANGELOG_FILE = pathlib.Path("./CHANGELOG.md")


def find_template_folder() -> pathlib.Path:
"""Find the template folder from the pyproject.toml file.

Returns:
The path to the template folder.
"""
with PYPROJECT_FILE.open("rb") as file_handle:
pyproject_data = tomli.load(file_handle)
try:
template_folder = pathlib.Path(
pyproject_data["tool"]["semantic_release"]["changelog"]["template_dir"]
)
except KeyError:
template_folder = pathlib.Path("./templates")
return template_folder


def main() -> None:
"""Check for entries in the Unreleased section of the CHANGELOG.md file.

Expand All @@ -50,15 +30,12 @@ def main() -> None:
"""
# Load in the GitHub Action inputs
# See https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
filename_for_previous_changelog = os.environ["INPUT_PREVIOUS-CHANGELOG-FILENAME"]
filename_for_previous_release_notes = os.environ["INPUT_PREVIOUS-RELEASE-NOTES-FILENAME"]
filepath_for_previous_changelog = os.environ["INPUT_PREVIOUS-CHANGELOG-FILEPATH"]
filepath_for_previous_release_notes = os.environ["INPUT_PREVIOUS-RELEASE-NOTES-FILEPATH"]
release_level = os.getenv("INPUT_RELEASE-LEVEL")
# Set the filepaths for the template files
template_folder = find_template_folder()
template_changelog_filepath = template_folder / pathlib.Path(filename_for_previous_changelog)
template_release_notes_filepath = template_folder / pathlib.Path(
filename_for_previous_release_notes
)
template_changelog_filepath = pathlib.Path(filepath_for_previous_changelog)
template_release_notes_filepath = pathlib.Path(filepath_for_previous_release_notes)

release_notes_content = ""
found_entries = False
Expand Down
14 changes: 7 additions & 7 deletions actions/find_unreleased_changelog_items/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ will be used to fill in the GitHub Release Notes.

## Inputs

| Input variable | Necessity | Description | Default |
| --------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `release-level` | optional | The level of the impending release. Must be one of `major`, `minor`, or `patch`. Setting this input will trigger the action to output the summary of the incoming release level and the unreleased changes to the Workflow Summary. | |
| `previous-changelog-filename` | optional | The name of the file to copy the contents of the changelog into for use in the `python-semantic-release` templates. This file will be created inside of the directory defined by the `[tool.semantic_release.changelog.template_dir]` key in the `pyproject.toml` file. | `'.previous_changelog_for_template.md'` |
| `previous-release-notes-filename` | optional | The name of the file to copy the contents of the `## Unreleased` section of the changelog into for use in the GitHub Release Notes. This file will be created inside of the directory defined by the `[tool.semantic_release.changelog.template_dir]` key in the `pyproject.toml` file. | `'.previous_release_notes_for_template.md'` |
| Input variable | Necessity | Description | Default |
| --------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `release-level` | optional | The level of the impending release. Must be one of `major`, `minor`, or `patch`. Setting this input will trigger the action to output the summary of the incoming release level and the unreleased changes to the Workflow Summary. | |
| `previous-changelog-filepath` | optional | The full path of the file to copy the contents of the changelog into for use in the `python-semantic-release` templates. | `'.previous_changelog_for_template.md'` |
| `previous-release-notes-filepath` | optional | The full path of the file to copy the contents of the `## Unreleased` section of the changelog into for use in the GitHub Release Notes. | `'.previous_release_notes_for_template.md'` |

## Example

Expand All @@ -51,6 +51,6 @@ jobs:
- uses: tektronix/python-package-ci-cd/actions/find_unreleased_changelog_items@main # it is recommended to use the latest release tag instead of `main`
with:
release-level: ${{ inputs.release-level }} # optional
previous-changelog-filename: .previous_changelog_for_template.md # optional
previous-release-notes-filename: .previous_release_notes_for_template.md # optional
previous-changelog-filepath: .previous_changelog_for_template.md # optional
previous-release-notes-filepath: .previous_release_notes_for_template.md # optional
```
1 change: 0 additions & 1 deletion actions/find_unreleased_changelog_items/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
tomli==2.0.1 ; python_version >= "3.12" and python_version < "3.13"
2 changes: 1 addition & 1 deletion actions/update_development_dependencies/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dulwich==0.21.7 ; python_version >= "3.12" and python_version < "3.13"
fastjsonschema==2.20.0 ; python_version >= "3.12" and python_version < "3.13"
filelock==3.15.4 ; python_version >= "3.12" and python_version < "3.13"
identify==2.6.0 ; python_version >= "3.12" and python_version < "3.13"
idna==3.7 ; python_version >= "3.12" and python_version < "3.13"
idna==3.8 ; python_version >= "3.12" and python_version < "3.13"
installer==0.7.0 ; python_version >= "3.12" and python_version < "3.13"
jaraco-classes==3.4.0 ; python_version >= "3.12" and python_version < "3.13"
jeepney==0.8.0 ; python_version >= "3.12" and python_version < "3.13" and sys_platform == "linux"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ tox = "^4.18.0"
tox-gh-actions = "^3.2.0"

[tool.poetry.group.fci.dependencies] # dependencies for actions/find_unreleased_changelog_items
tomli = "^2.0.1"

[tool.poetry.group.tests.dependencies]
coverage = "^7.5.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ coverage[toml]==7.6.1 ; python_version >= "3.12" and python_version < "3.13"
dataproperty==1.0.1 ; python_version >= "3.12" and python_version < "3.13"
dnspython==2.6.1 ; python_version >= "3.12" and python_version < "3.13"
future-fstrings==1.2.0 ; python_version >= "3.12" and python_version < "3.13"
idna==3.7 ; python_version >= "3.12" and python_version < "3.13"
idna==3.8 ; python_version >= "3.12" and python_version < "3.13"
iniconfig==2.0.0 ; python_version >= "3.12" and python_version < "3.13"
jinja2==3.1.4 ; python_version >= "3.12" and python_version < "3.13"
linkchecker==10.4.0 ; python_version >= "3.12" and python_version < "3.13"
markupsafe==2.1.5 ; python_version >= "3.12" and python_version < "3.13"
mbstrdecoder==1.1.3 ; python_version >= "3.12" and python_version < "3.13"
networkx==3.3 ; python_version >= "3.12" and python_version < "3.13"
packaging==24.1 ; python_version >= "3.12" and python_version < "3.13"
pathvalidate==3.2.0 ; python_version >= "3.12" and python_version < "3.13"
pathvalidate==3.2.1 ; python_version >= "3.12" and python_version < "3.13"
pluggy==1.5.0 ; python_version >= "3.12" and python_version < "3.13"
pytablewriter==1.2.0 ; python_version >= "3.12" and python_version < "3.13"
pytest==8.3.2 ; python_version >= "3.12" and python_version < "3.13"
Expand Down
Loading