From bccc9a1b73ef24886586fdb31e4279df2b8b7eae Mon Sep 17 00:00:00 2001 From: Braelyn Boynton Date: Tue, 14 Jan 2025 15:42:29 -0800 Subject: [PATCH] move version check --- .github/workflows/deploy.yml | 32 ++++++++++++ .../workflows/version-check-on-release.yml | 51 ------------------- 2 files changed, 32 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/version-check-on-release.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0a23ed35..ede1197b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,38 @@ jobs: - name: Build the package run: python -m build + - name: Check version matches + run: | + import toml + import os + import sys + + # Read pyproject.toml + with open('pyproject.toml', 'r') as f: + pyproject = toml.load(f) + + # Get version from pyproject.toml + project_version = pyproject['project']['version'] + + # Get release tag (strip 'v' prefix if present) + github_ref = os.environ['GITHUB_REF'] + tag_version = github_ref.split('/')[-1] + if tag_version.startswith('v'): + tag_version = tag_version[1:] + + print(f"pyproject.toml version: {project_version}") + print(f"Release tag version: {tag_version}") + + # Compare versions + if project_version != tag_version: + print("Version mismatch!") + print(f"pyproject.toml version ({project_version}) does not match") + print(f"release tag version ({tag_version})") + sys.exit(1) + + print("Versions match!") + shell: python + - name: Upload to PyPI env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} diff --git a/.github/workflows/version-check-on-release.yml b/.github/workflows/version-check-on-release.yml deleted file mode 100644 index e952175d..00000000 --- a/.github/workflows/version-check-on-release.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Verify Package Version - -on: - release: - types: [created] - -jobs: - verify-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install toml package - run: pip install toml - - - name: Check version matches - run: | - import toml - import os - import sys - - # Read pyproject.toml - with open('pyproject.toml', 'r') as f: - pyproject = toml.load(f) - - # Get version from pyproject.toml - project_version = pyproject['project']['version'] - - # Get release tag (strip 'v' prefix if present) - github_ref = os.environ['GITHUB_REF'] - tag_version = github_ref.split('/')[-1] - if tag_version.startswith('v'): - tag_version = tag_version[1:] - - print(f"pyproject.toml version: {project_version}") - print(f"Release tag version: {tag_version}") - - # Compare versions - if project_version != tag_version: - print("Version mismatch!") - print(f"pyproject.toml version ({project_version}) does not match") - print(f"release tag version ({tag_version})") - sys.exit(1) - - print("Versions match!") - shell: python \ No newline at end of file