diff --git a/makefiles/Makefile.python.in b/makefiles/Makefile.python.in index 836105d..ac1e5fe 100644 --- a/makefiles/Makefile.python.in +++ b/makefiles/Makefile.python.in @@ -46,23 +46,18 @@ show-venv:: | check-venv @echo "++ $@" @echo "$(VIRTUAL_ENV)" -install-poetry:: +set-pyproject-vers:: check-venv @echo "++ $@" - # will install poetry in this venv - pip install --quiet --upgrade poetry + uv version $(VERSION) -set-pyproject-vers:: check-venv install-poetry - @echo "++ $@" - poetry version $(VERSION) - -install-deps:: check-venv install-poetry +install-deps:: check-venv @echo "++ $@" # will install deps in this venv - poetry install --no-ansi + uv sync --frozen --dev show-installed-deps:: @echo "++ $@" - poetry show + uv tree --locked --all-groups check: test lint type-check @echo "++ $@" @@ -80,12 +75,10 @@ test-integration:: check-venv install-deps package:: check-venv set-pyproject-vers install-deps test-all @echo "++ $@" - poetry build --no-ansi - poetry version 0.0.0 &>/dev/null + uv build publish:: check-venv package @echo "++ $@" - poetry config repositories.testpypi https://test.pypi.org/legacy/ . $(ROOT_DIR)/plox-common/scripts/publish/python.sh && publish extra-docker-args: diff --git a/scripts/common.sh b/scripts/common.sh index 63146fa..71f3155 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -27,6 +27,15 @@ print_func_banner(){ local funcname="${1}" printf "============================ Inside: %s ============================\n" "${funcname}" >&2; } +is_default_branch(){ + print_func_banner "${FUNCNAME[0]}" + if [[ "${BRANCH_NAME}" == "${DEAFULT_BRANCH}" ]]; then + echo "y" + else + echo "n" + fi +} + ### # Check whether the current commit/branch is part of a pull request. ### diff --git a/scripts/misc/get-pypi-pub-target b/scripts/misc/get-pypi-pub-target deleted file mode 100755 index a887a55..0000000 --- a/scripts/misc/get-pypi-pub-target +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -# exit early if not in github actions CI -if [[ "${GITHUB_ACTIONS:-}" == "" ]]; then - echo "-r testpypi" - exit 0 -fi - -if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then - branch="${GITHUB_REF##*/}" - if [[ "${branch}" == "main" || "${branch}" == "master" ]]; then - # post-PR merge, publish to official - exit 0 - else - echo "-r testpypi" - fi -elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - echo "-r testpypi" -else - echo "Invalid branch" - exit 1 -fi - -exit 0 diff --git a/scripts/publish/python.sh b/scripts/publish/python.sh index 230d41f..2a1294e 100755 --- a/scripts/publish/python.sh +++ b/scripts/publish/python.sh @@ -8,16 +8,24 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) publish(){ - if [[ "${GITHUB_ACTIONS:-}" == "" || "$(is_part_of_active_pr)" == "n" ]]; then - poetry publish ${PYPI_ALIAS} -vv + # allow local publishing to testpypi + if [[ "${GITHUB_ACTIONS:-}" == "" ]]; then + uv publish --index testpypi -vv + return 0 + fi + + if [[ "$(is_default_branch)" == "y" ]]; then + uv publish --index pypi -vv return + else + print_info "${BRANCH_NAME} != default (${DEFAULT_BRANCH}), not publishing to main" fi if [[ "$(is_label_present publish-test-build)" == "y" ]]; then - poetry publish ${PYPI_ALIAS} -vv + uv publish --index testpypi -vv else - echo "Detected part of PR but did not detect 'publish-test-build' PR label" - echo "To publish a test version of this packge, add the 'publish-test-build' label" - echo "and re-run the publish check." + print_info "Detected part of PR but did not detect 'publish-test-build' PR label" + print_info "To publish a test version of this packge, add the 'publish-test-build' label" + print_info "and re-run the publish check." fi }