From 988848789a216a78a15d376073d4aaaa9b18657e Mon Sep 17 00:00:00 2001 From: sroomberg Date: Tue, 14 Apr 2026 00:15:25 -0400 Subject: [PATCH 1/5] only publish with new tag pushed to master --- .github/workflows/publish.yml | 94 ++++++++++------------------------- 1 file changed, 26 insertions(+), 68 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c6923f3..f7649ab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,86 +1,49 @@ -name: Bump Version & Publish to PyPI +name: Publish to PyPI on: - pull_request: - types: [closed] - branches: [master] + push: + tags: + - 'v*' permissions: - contents: write + contents: read jobs: - publish: - if: github.event.pull_request.merged == true + check: runs-on: ubuntu-latest - + outputs: + on_master: ${{ steps.verify.outputs.on_master }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - name: Install dependencies - run: pip install build twine tomli tomli-w - - - name: Determine version bump type - id: bump + - name: Check if tag is on master + id: verify run: | - PR_TITLE="${{ github.event.pull_request.title }}" - PR_LABELS=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}') - - if echo "$PR_LABELS" | grep -q '"major"'; then - echo "part=major" >> "$GITHUB_OUTPUT" - elif echo "$PR_LABELS" | grep -q '"minor"'; then - echo "part=minor" >> "$GITHUB_OUTPUT" + if git merge-base --is-ancestor ${{ github.sha }} origin/master; then + echo "on_master=true" >> $GITHUB_OUTPUT else - echo "part=patch" >> "$GITHUB_OUTPUT" + echo "on_master=false" >> $GITHUB_OUTPUT fi - - name: Bump version - id: version - run: | - python - <<'PYEOF' - import tomli, tomli_w, pathlib, os - - pyproject = pathlib.Path("pyproject.toml") - data = tomli.loads(pyproject.read_text()) - - current = data["project"]["version"] - major, minor, patch = (int(x) for x in current.split(".")) - - part = os.environ["BUMP_PART"] - if part == "major": - major, minor, patch = major + 1, 0, 0 - elif part == "minor": - minor, patch = minor + 1, 0 - else: - patch += 1 - - new_version = f"{major}.{minor}.{patch}" - data["project"]["version"] = new_version - pyproject.write_text(tomli_w.dumps(data)) + publish: + needs: check + if: needs.check.outputs.on_master == 'true' + runs-on: ubuntu-latest - with open(os.environ["GITHUB_OUTPUT"], "a") as f: - f.write(f"new_version={new_version}\n") + steps: + - name: Checkout repository + uses: actions/checkout@v4 - print(f"Bumped {current} -> {new_version}") - PYEOF - env: - BUMP_PART: ${{ steps.bump.outputs.part }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" - - name: Commit version bump - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add pyproject.toml - git commit -m "bump version to ${{ steps.version.outputs.new_version }}" - git push + - name: Install dependencies + run: pip install build twine - name: Build package run: python -m build @@ -90,8 +53,3 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: twine upload dist/* - - - name: Create git tag - run: | - git tag "v${{ steps.version.outputs.new_version }}" - git push origin "v${{ steps.version.outputs.new_version }}" From 356b7252fe1ad07533207ee7a6fe071e69ba2004 Mon Sep 17 00:00:00 2001 From: sroomberg Date: Tue, 14 Apr 2026 00:17:44 -0400 Subject: [PATCH 2/5] only publish with new tag pushed to master --- .github/workflows/publish.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f7649ab..b8e318e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,8 +2,8 @@ name: Publish to PyPI on: push: - tags: - - 'v*' + branches: + - master permissions: contents: read @@ -19,10 +19,11 @@ jobs: with: fetch-depth: 0 - - name: Check if tag is on master + - name: Check if commit has a version tag id: verify run: | - if git merge-base --is-ancestor ${{ github.sha }} origin/master; then + TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]' | head -n1) + if [ -n "$TAG" ]; then echo "on_master=true" >> $GITHUB_OUTPUT else echo "on_master=false" >> $GITHUB_OUTPUT From 2c4e04cf53eb748a282da41a2887c9b38a7ee239 Mon Sep 17 00:00:00 2001 From: sroomberg Date: Tue, 14 Apr 2026 00:21:11 -0400 Subject: [PATCH 3/5] fix version for typing_extensions --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 05fe1a4..7ef9a61 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ ] dependencies = [ "python-hcl2~=3.0", - "typing_extensions>=4.0; python_version < '3.12'", + "typing_extensions>=4.0", ] [project.urls] From 343b88b4d01334642c8e3ef32ecf9c49d244f10b Mon Sep 17 00:00:00 2001 From: sroomberg Date: Tue, 14 Apr 2026 00:23:08 -0400 Subject: [PATCH 4/5] remove typing_extensions --- .github/workflows/ci.yml | 2 +- examples/ami_builder.py | 2 -- packerpy/models.py | 1 - pyproject.toml | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38d4308..af9769c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/examples/ami_builder.py b/examples/ami_builder.py index 1878f04..ac0c0ab 100644 --- a/examples/ami_builder.py +++ b/examples/ami_builder.py @@ -1,7 +1,5 @@ import os -from typing_extensions import override - from packerpy.builder import PackerBuilder from packerpy.models import AmazonEbs, FileProvisioner, ShellProvisioner diff --git a/packerpy/models.py b/packerpy/models.py index 45219db..0c02fc8 100644 --- a/packerpy/models.py +++ b/packerpy/models.py @@ -15,7 +15,6 @@ from typing import Any import hcl2 -from typing_extensions import override from .exceptions import PackerBuildError, raise_ from .util import parse_list diff --git a/pyproject.toml b/pyproject.toml index 7ef9a61..808bcc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ version = "2.0.2" description = "Packer for python" readme = "README.md" license = "BSD-3-Clause" -requires-python = ">=3.10" +requires-python = ">=3.12" authors = [ { name = "sroomberg", email = "stevenroomberg@gmail.com" }, ] @@ -20,7 +20,6 @@ classifiers = [ ] dependencies = [ "python-hcl2~=3.0", - "typing_extensions>=4.0", ] [project.urls] From eca198950829e0d528b7b50166fea647c956dd49 Mon Sep 17 00:00:00 2001 From: sroomberg Date: Tue, 14 Apr 2026 00:25:31 -0400 Subject: [PATCH 5/5] add back typing_extensions --- .github/workflows/ci.yml | 2 +- examples/ami_builder.py | 2 ++ packerpy/models.py | 2 +- pyproject.toml | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af9769c..38d4308 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/examples/ami_builder.py b/examples/ami_builder.py index ac0c0ab..1878f04 100644 --- a/examples/ami_builder.py +++ b/examples/ami_builder.py @@ -1,5 +1,7 @@ import os +from typing_extensions import override + from packerpy.builder import PackerBuilder from packerpy.models import AmazonEbs, FileProvisioner, ShellProvisioner diff --git a/packerpy/models.py b/packerpy/models.py index 0c02fc8..1f5dfce 100644 --- a/packerpy/models.py +++ b/packerpy/models.py @@ -15,6 +15,7 @@ from typing import Any import hcl2 +from typing_extensions import override from .exceptions import PackerBuildError, raise_ from .util import parse_list @@ -133,7 +134,6 @@ class Plugin(PackerResource): def __init__(self, name: str, version: str, version_op: str, source: str) -> None: super().__init__(name=name) - self.name: str = name self.version: str = version self.version_op: str = version_op self.source: str = source diff --git a/pyproject.toml b/pyproject.toml index 808bcc1..da46faf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ version = "2.0.2" description = "Packer for python" readme = "README.md" license = "BSD-3-Clause" -requires-python = ">=3.12" +requires-python = ">=3.10" authors = [ { name = "sroomberg", email = "stevenroomberg@gmail.com" }, ] @@ -20,6 +20,7 @@ classifiers = [ ] dependencies = [ "python-hcl2~=3.0", + "typing_extensions>=4.0", # not required ] [project.urls]