From 4ef7280117442227a44a56f74b757fcea10e2092 Mon Sep 17 00:00:00 2001 From: Bjarten Date: Fri, 18 Oct 2024 17:17:37 +0900 Subject: [PATCH 1/5] fix: release workflow --- .github/workflows/release.yml | 14 ++++++-------- pyproject.toml | 6 +++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2de67e..5ff0a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,17 @@ -name: Semantic Release +name: Create New Release on: - push: - branches: - - main - workflow_dispatch: + workflow_dispatch: # This ensures the workflow is only triggered manually jobs: release: + name: Create Release runs-on: ubuntu-latest - concurrency: release permissions: - id-token: write contents: write + issues: write + pull-requests: write + actions: write steps: - name: Checkout code @@ -21,7 +20,6 @@ jobs: fetch-depth: 0 - name: Python Semantic Release - id: release uses: python-semantic-release/python-semantic-release@v9.12.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8a95a41..7e9b9e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "early-stopping-pytorch" +dynamic = ["version"] description = "A PyTorch utility package for Early Stopping" readme = "README.md" authors = [ @@ -15,8 +16,11 @@ dependencies = [ "torch>=1.9.0" ] +[tool.setuptools.dynamic] +version = {attr = "early_stopping_pytorch.__version__"} + [tool.semantic_release] -version_variable = "early_stopping_pytorch/__init__.py:__version__" +version_variable = ["early_stopping_pytorch/__init__.py:__version__"] branch = "main" upload_to_pypi = false build_command = "pip install build && python -m build" From 2354995fbd1e482f9a5391a8cdde16b80a447990 Mon Sep 17 00:00:00 2001 From: Bjarten Date: Sun, 10 Nov 2024 10:10:16 +0100 Subject: [PATCH 2/5] ci: add python version to release workflow --- .github/workflows/release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ff0a08..aee85bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Create New Release on: - workflow_dispatch: # This ensures the workflow is only triggered manually + workflow_dispatch: # Manual trigger only jobs: release: @@ -19,6 +19,11 @@ jobs: with: fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + - name: Python Semantic Release uses: python-semantic-release/python-semantic-release@v9.12.0 with: From adc485c8e72c9880c28f51b406b3eaa6fe3743c8 Mon Sep 17 00:00:00 2001 From: Bjarten Date: Sun, 10 Nov 2024 10:11:01 +0100 Subject: [PATCH 3/5] ci: update publish.yml, remove token --- .github/workflows/publish.yml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e0c0800..b2f596f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,11 +3,17 @@ name: Publish Python Package on: push: tags: - - 'v*.*.*' # Automatically publish when a new version tag is pushed + - 'v*.*.*' jobs: publish: + name: Upload release to PyPI runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/early-stopping-pytorch + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - name: Checkout code @@ -18,26 +24,13 @@ jobs: with: python-version: '3.12' - - name: Cache pip - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements-dev.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build twine + pip install build - - name: Build the package - run: | - python -m build + - name: Build package + run: python -m build - - name: Publish to PyPI - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python -m twine upload --repository pypi dist/* + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From c52b28626c924554d1a96c8856ee8c21c761ec23 Mon Sep 17 00:00:00 2001 From: Bjarten Date: Sun, 10 Nov 2024 10:22:52 +0100 Subject: [PATCH 4/5] docs: update readme --- README.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/README.md b/README.md index 0896068..0ecceb4 100644 --- a/README.md +++ b/README.md @@ -36,25 +36,5 @@ You can now import and use the package in your Python code: ```python from early_stopping_pytorch import EarlyStopping ``` - ---- - -### Summary of Commands - -1. Clone the repository: - `git clone https://github.com/your_username/early-stopping-pytorch.git` - -2. Set up the environment: - `./setup_dev_env.sh` - -3. Activate the environment: - `source dev-venv/bin/activate` - -4. Install the package in editable mode: - `pip install -e .` - -5. Optional: Build the package for distribution: - `./build.sh` - ## References The ```EarlyStopping``` class in ```early_stopping_pytorch/early_stopping.py``` is inspired by the [ignite EarlyStopping class](https://github.com/pytorch/ignite/blob/master/ignite/handlers/early_stopping.py). From 4fb72a12928d855a9c4efef69b78fe1d3e550a4c Mon Sep 17 00:00:00 2001 From: Bjarten Date: Sun, 10 Nov 2024 10:27:51 +0100 Subject: [PATCH 5/5] chore: revert release workflow --- .github/workflows/release.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aee85bf..5ff0a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Create New Release on: - workflow_dispatch: # Manual trigger only + workflow_dispatch: # This ensures the workflow is only triggered manually jobs: release: @@ -19,11 +19,6 @@ jobs: with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Python Semantic Release uses: python-semantic-release/python-semantic-release@v9.12.0 with: