Skip to content

Commit

Permalink
refactor: move package version number to a separate file so that sema…
Browse files Browse the repository at this point in the history
…ntic version can bump this.
  • Loading branch information
lpm0073 committed Nov 13, 2023
1 parent f6a90f1 commit b7befd3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
with:
persist-credentials: false

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '16'

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
Expand Down Expand Up @@ -50,6 +55,18 @@ jobs:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com

- name: Update __about__
if: steps.semantic.outputs.new_release_published == 'true'
run: |
npx semantic-release exec -- cmd /c "echo __version__ = '${{ steps.semantic.outputs.new_release_version }}' > __version__.py"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ steps.semantic.outputs.new_release_version }}"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: echo "new release was published"
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
args: [--ignore=D100]
additional_dependencies: [
'flake8-blind-except',
'flake8-bugbear',
Expand Down
7 changes: 0 additions & 7 deletions __about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
Python Secure Logger
"""

# Increment this version number to trigger a new release. See
# CHANGELOG.md for information on the versioning scheme.
__version__ = "0.1.6"

# The app name will be used to define the name of the default plugin root and
# plugin directory. To avoid conflicts between multiple locally-installed
# versions, if it is defined the version suffix will also be appended to the app
# name.
__app__ = "secure_logger"

# Package version, as installed by pip, does not include the version suffix.
__package_version__ = __version__
2 changes: 2 additions & 0 deletions secure_logger/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = "0.1.6"
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ def load_about() -> Dict[str, str]:
return about


def load_version() -> Dict[str, str]:
"""Stringify the __about__ mobule."""
version: Dict[str, str] = {}
with io.open(os.path.join(HERE, "__version__.py"), "rt", encoding="utf-8") as f:
exec(f.read(), version) # pylint: disable=exec-used
return version


README = open(os.path.join(os.path.dirname(__file__), "README.md")).read()
CHANGELOG = open(os.path.join(os.path.dirname(__file__), "CHANGELOG.md")).read()
ABOUT = load_about()
VERSION = load_version()

setup(
name="secure-logger",
version=ABOUT["__package_version__"],
version=VERSION["__version__"],
description="A decorator to generate redacted and nicely formatted log entries",
long_description=load_readme(),
author="Lawrence McDaniel",
Expand Down

0 comments on commit b7befd3

Please sign in to comment.