Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/version-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Version Check
description: Fail if Cargo.toml version is not greater than crates.io and PyPI published versions
author: git-insights maintainers

inputs:
python-version:
description: Python version to use for running the check
required: false
default: "3.12"
working-directory:
description: Directory to run the version check from (where Cargo.toml is located)
required: false
default: "."

runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install Python dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
python -m pip install --upgrade pip
pip install "packaging>=24.0"

- name: Run version check script
shell: bash
working-directory: ${{ inputs.working-directory }}
run: python .github/scripts/version_check.py
22 changes: 21 additions & 1 deletion .github/scripts/version_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import tomllib
import urllib.request
import urllib.error
import json
from packaging.version import Version

Expand All @@ -16,5 +17,24 @@
if loc <= rem:
print(f"❌ {loc} <= {rem}, bump Cargo.toml")
sys.exit(1)

print(f"✅ {loc} > {rem}")
# make the same check on pypi
pypi_url = f"https://pypi.org/pypi/{name}/json"
try:
json_data = json.load(urllib.request.urlopen(pypi_url))
rem = Version(json_data["info"]["version"])
print(f"PyPI: {name}")
print(f"Local: {loc}")
print(f"Remote: {rem}")

if loc <= rem:
print(f"❌ {loc} <= {rem}, bump Cargo.toml")
sys.exit(1)

print(f"✅ {loc} > {rem}")
except urllib.error.HTTPError as e:
if e.code == 404:
print(f"✅ {name} not found on PyPI, good to publish")
else:
raise e
11 changes: 10 additions & 1 deletion .github/workflows/ci-build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ env:
UV_RESOLUTION_STRATEGY: highest

jobs:
version-check:
name: Version check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"

build-test-package:
name: build-test-package
runs-on: ${{ matrix.os }}
needs: version-check
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -88,4 +98,3 @@ jobs:
echo "The build-test-package job did not succeed."
exit 1
fi

11 changes: 4 additions & 7 deletions .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Set up Python 3.12
uses: actions/setup-python@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"
- name: Run ci-health scripts
run: |
pip install packaging
python .github/scripts/version_check.py
python .github/scripts/commit_emails_check.py

- name: Run commit emails check
run: python .github/scripts/commit_emails_check.py

unittest-develop:
name: unittest-develop
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Set up Python 3.12
uses: actions/setup-python@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"
- name: Run ci-health scripts
run: |
pip install packaging
python .github/scripts/version_check.py
python .github/scripts/commit_emails_check.py
- name: Run commit emails check
run: python .github/scripts/commit_emails_check.py

unittest-test:
name: unittest-test
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ci-tests-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ env:
UV_RESOLUTION_STRATEGY: highest

jobs:
version-check:
name: Version check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"

unittest-main:
name: unittest-main
needs: version-check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish-crates-io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check crate version on crates.io
run: |
python .github/scripts/version_check.py
python .github/scripts/commit_emails_check.py
- uses: ./.github/actions/version-check
with:
python-version: "3.12"
- name: Run commit emails check
run: python .github/scripts/commit_emails_check.py

unittests-release:
name: Unit Tests (Release)
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ env:
UV_RESOLUTION_STRATEGY: highest

jobs:
version-check:
name: Version check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"

build-test-package:
name: Build & test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: version-check
strategy:
fail-fast: false
matrix:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ env:
UV_RESOLUTION_STRATEGY: highest

jobs:
version-check:
name: Version check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/version-check
with:
python-version: "3.12"

build-test-package:
name: Build & test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: version-check
strategy:
fail-fast: false
matrix:
Expand Down