Skip to content

Commit

Permalink
Make awk for version capturing more specific (#1)
Browse files Browse the repository at this point in the history
* Make awk for version capturing more specific

* Update test `pyproject.toml`

* Use toml parser to extract version

* Use `load` to omit `read`

---------

Co-authored-by: ckaipf <[email protected]>
  • Loading branch information
walzph and ckaipf authored Jan 9, 2024
1 parent bd3feb3 commit a8bf9a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ runs:

- if: contains(fromJSON('["release"]'), github.event_name)
uses: actions/setup-python@v4
name: Set up Python 3.9
name: Set up Python 3.11
with:
python-version: "3.9"
python-version: "3.11"

- if: contains(fromJSON('["release"]'), github.event_name)
name: Ensure package version and tag are equal
Expand All @@ -65,7 +65,7 @@ runs:
PKG_VER="$(python setup.py --version)"
elif [ -f "pyproject.toml" ]
then
version=$(awk -F "=" '/version/ {print $2}' pyproject.toml | tr -d ' \t\n\r"')
version=$(python3.11 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
PKG_VER=$version
else
echo "Neither setup.py nor pyproject.toml were found." >&2; exit 1
Expand Down
5 changes: 5 additions & 0 deletions test/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[project]
version = "0.0.0"
[tool.ruff]
target-version = "py39"
[tool.pytest.ini_options]
minversion = "7.1"

0 comments on commit a8bf9a2

Please sign in to comment.