From ef086a54707e090326e33cc9bbfedca753a8da96 Mon Sep 17 00:00:00 2001 From: msterhuj Date: Fri, 25 Oct 2024 23:22:43 +0200 Subject: [PATCH] ci: build package and push it to pypi Signed-off-by: msterhuj --- .github/workflows/pypi-push.yml | 26 ++++++++++++++++++++++++++ scripts/set_version.py | 1 + 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/pypi-push.yml diff --git a/.github/workflows/pypi-push.yml b/.github/workflows/pypi-push.yml new file mode 100644 index 0000000..6e95849 --- /dev/null +++ b/.github/workflows/pypi-push.yml @@ -0,0 +1,26 @@ +name: Push cli to PyPI +on: + release: + types: + - published + +jobs: + build: + name: "Build pip package" + runs-on: ubuntu-latest + + steps: + - name: "Checkout Action" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "Set version to pyproject.toml and __init__.py" + run: | + python scripts/set_version.py ${{ github.event.release.tag_name }} + + - name: "Build and publish to pypi" + uses: JRubics/poetry-publish@v2.0 + with: + pypi_token: ${{ secrets.PYPI_TOKEN }} + python_version: "3.12" \ No newline at end of file diff --git a/scripts/set_version.py b/scripts/set_version.py index c19ac92..84f469d 100644 --- a/scripts/set_version.py +++ b/scripts/set_version.py @@ -16,6 +16,7 @@ def replace(file, pattern, replace): version = "0.0.0" if len(argv) > 1: version = argv[1] + version = version.replace("v", "") if not re.match(r"^\d+\.\d+\.\d+$", version): print("Invalid version format. Please use MAJOR.MINOR.PATCH format")