Skip to content

Commit

Permalink
chore: consolidate version definitions and update release workflow (#30)
Browse files Browse the repository at this point in the history
This pull request consolidates version definitions and improves the
release workflow to streamline the versioning and publishing processes.
The changes are part of an effort to improve maintainability and ensure
the workflows are efficient and modular.

**Changes Made:**
- **Consolidated Version Management**: 
- Removed duplicate version definitions to maintain a single source of
truth. The version is now only defined in
`early_stopping_pytorch/__init__.py` to avoid conflicts.
- Removed the `version` field from `pyproject.toml`, as
`python-semantic-release` handles versioning automatically.
  
- **Updated Release Workflow**:
- Improved the `Create New Release` workflow by separating the release
process from the publishing process.
- The release process now handles version bumping, tagging, and creating
GitHub releases via `python-semantic-release`.
  
- **New Publish Workflow**:
- A dedicated workflow now handles publishing the package to PyPI when a
new version tag is pushed.
- This ensures a clear separation of responsibilities between creating
releases and publishing to PyPI, reducing complexity.
  • Loading branch information
Bjarten authored Oct 16, 2024
1 parent f9522dd commit e79817a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -22,7 +22,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
contents: write
issues: write
pull-requests: write
actions: write

steps:
- name: Checkout code
Expand All @@ -31,7 +32,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
python-version: '3.12'

- name: Install dependencies
run: |
Expand All @@ -48,7 +49,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event.inputs.dry-run }}" = "true" ]; then
semantic-release publish --dry-run
semantic-release publish --dry-run --verbose
else
semantic-release publish
semantic-release publish --verbose
fi
4 changes: 1 addition & 3 deletions early_stopping_pytorch/early_stopping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# pytorchtools.py
__version__ = "0.1.0"

# early_stopping.py
import numpy as np
import torch

Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ build-backend = "setuptools.build_meta"

[project]
name = "early-stopping-pytorch"
version = "0.1.0"
description = "A PyTorch utility package for Early Stopping"
readme = "README.md"
authors = [
{ name = "Bjarte Sunde", email = "BjarteSunde@outlook.com" }
]
license = { text = "MIT" } # Update if you use a different license
license = { text = "MIT" }
dependencies = [
"numpy>=1.21",
"torch>=1.9.0"
]

[tool.semantic_release]
version_variable = [
"early_stopping_pytorch/__init__.py:__version__",
"pyproject.toml:project.version"
]
version_variable = "early_stopping_pytorch/__init__.py:__version__"
branch = "main"
upload_to_pypi = false
build_command = "pip install build && python -m build"

[tool.semantic_release.git]
tag_format = "v{version}"

0 comments on commit e79817a

Please sign in to comment.