From 75459ce0ff6af420d3d0e8d45e875ba795101e35 Mon Sep 17 00:00:00 2001 From: Edmond Chuc Date: Mon, 19 Feb 2024 10:36:49 +1000 Subject: [PATCH 1/2] Add release workflow --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ pylode/version.py | 5 ++- pyproject.toml | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..732250f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release to PyPI + +on: + release: + types: + - published + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout the repo + uses: actions/checkout@v4 + with: + # Required by WyriHaximus/github-action-get-previous-tag + fetch-depth: 0 + + - name: Get latest tag + id: latest-tag + uses: WyriHaximus/github-action-get-previous-tag@v1 + with: + fallback: "0.1.0" + + - name: Tag starts with v + id: tag-starts-with-v + if: ${{ startsWith(steps.latest-tag.outputs.tag, 'v') }} + uses: mad9000/actions-find-and-replace-string@2 + with: + source: ${{ steps.latest-tag.outputs.tag }} + find: "v" + replace: "" + + - name: Tag value + id: version + uses: haya14busa/action-cond@v1 + with: + cond: ${{ startsWith(steps.latest-tag.outputs.tag, 'v') }} + if_true: ${{ steps.tag-starts-with-v.outputs.value }} + if_false: ${{ steps.latest-tag.outputs.tag }} + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Python Poetry + uses: snok/install-poetry@v1 + + - name: Install project + run: | + poetry install + + - name: Publish to PyPI + run: | + poetry version ${{ steps.version.outputs.value }} + poetry build + poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/pylode/version.py b/pylode/version.py index 9deb907..a62d16c 100644 --- a/pylode/version.py +++ b/pylode/version.py @@ -1 +1,4 @@ -__version__ = "3.0.6a" +import pkg_resources + +version = pkg_resources.get_distribution("pylode").version +__version__ = version diff --git a/pyproject.toml b/pyproject.toml index 488ddf4..a9f7573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pylode" -version = "3.0.6a" +version = "3.1.0a" description = "An OWL ontology documentation tool using Python, based on LODE." authors = ["Nicholas Car "] readme = "README.rst" From 75f1e4ce5e69e726dc067f2a8fe67eec45c7b686 Mon Sep 17 00:00:00 2001 From: Edmond Chuc Date: Mon, 19 Feb 2024 10:38:14 +1000 Subject: [PATCH 2/2] Set workflow python env version --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 732250f..5ffd909 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: types: - published +env: + PYTHON_VERSION: "3.12" + jobs: publish: runs-on: ubuntu-latest