Skip to content

Commit

Permalink
improve deploy workflow
Browse files Browse the repository at this point in the history
No need to install `osmg` again to get its version, we can directly
query PyPI.
  • Loading branch information
ioannis-vm committed Oct 9, 2023
1 parent 42509cd commit 7f5b56f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:
- name: Check the current version on PyPi
id: version_step_pypi
run: |
python -m pip install osmg --upgrade
latest=$(pip show osmg | grep 'Version:' | awk '{print $2}')
latest=$(python src/osmg/get_latest_pypi_version.py)
echo "Latest Version found on PyPi: $latest"
echo "PYPI_VERSION=$latest" >> $GITHUB_ENV
- name: Check the current version on setup.cfg
Expand All @@ -50,6 +49,7 @@ jobs:
echo "Version found in setup.cfg: $version"
echo "SETUPCFG_VERSION=$version" >> $GITHUB_ENV
- name: Prepare package
if: ${{ env.PYPI_VERSION != env.SETUPCFG_VERSION }}
run: |
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
Expand Down
20 changes: 20 additions & 0 deletions src/osmg/get_latest_pypi_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import requests


def get_latest_version(package_name):
url = f"https://pypi.org/pypi/{package_name}/json"

try:
response = requests.get(url)
package_info = response.json()
latest_version = package_info['info']['version']
return latest_version
except Exception as e:
print(f"An error occurred: {e}")
return None


if __name__ == '__main__':
package = 'osmg'
version = get_latest_version(package)
print(version)

0 comments on commit 7f5b56f

Please sign in to comment.