diff --git a/.github/workflows/build-test-and-sonar.yml b/.github/workflows/build-test-and-sonar.yml index d936325..4b8d933 100644 --- a/.github/workflows/build-test-and-sonar.yml +++ b/.github/workflows/build-test-and-sonar.yml @@ -152,20 +152,20 @@ jobs: name: power-grid-model-ds path: wheelhouse/ - # - name: Upload wheels - # if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true')) - # run: | - # pip install twine - # echo "Publish to PyPI..." - # twine upload --verbose wheelhouse/* - - # - name: Release - # if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true')) - # uses: softprops/action-gh-release@v2 - # with: - # files: | - # ./wheelhouse/* - # tag_name: v${{ needs.build-python.outputs.version }} - # prerelease: ${{github.ref != 'refs/heads/main'}} - # generate_release_notes: true - # target_commitish: ${{ github.sha }} + - name: Upload wheels + if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true')) + run: | + pip install twine + echo "Publish to PyPI..." + twine upload --verbose wheelhouse/* + + - name: Release + if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true')) + uses: softprops/action-gh-release@v2 + with: + files: | + ./wheelhouse/* + tag_name: v${{ needs.build-python.outputs.version }} + prerelease: ${{github.ref != 'refs/heads/main'}} + generate_release_notes: true + target_commitish: ${{ github.sha }} diff --git a/VERSION b/VERSION index 171538e..9f8e9b6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0 \ No newline at end of file +1.0 \ No newline at end of file diff --git a/set_pypi_version.py b/set_pypi_version.py index 61eb728..234fda7 100644 --- a/set_pypi_version.py +++ b/set_pypi_version.py @@ -7,6 +7,7 @@ import os +import re from pathlib import Path import requests @@ -44,9 +45,13 @@ def get_pypi_latest(): response = requests.get("https://pypi.org/pypi/power-grid-model-ds/json") if response.status_code == 404: return 0, 0, 0 - data = response.json() - version = str(data["info"]["version"]) - return (int(x) for x in version.split(".")) + version = str(response.json()["info"]["version"]) + + version_pattern = re.compile(r"^\d+\.\d+\.\d+") + match = version_pattern.match(version) + if not match: + raise ValueError(f"Invalid version format: {version}") + return (int(x) for x in match.group(0).split(".")) def get_new_version(major, minor, latest_major, latest_minor, latest_patch):