diff --git a/.github/workflows/publish-dev-release-to-pypi.yml b/.github/workflows/publish-dev-release-to-pypi.yml new file mode 100644 index 000000000..47d6d928d --- /dev/null +++ b/.github/workflows/publish-dev-release-to-pypi.yml @@ -0,0 +1,37 @@ +--- + +name: Publish dev-release to PyPI + +on: + pull_request: + types: + - closed + +env: + TOKEN: ${{ secrets.GH_TOKEN }} + +jobs: + publish-dev-release-to-pypi: + if: github.event.pull_request.merged == true && (contains(github.event.pull_request.title, 'fix') || contains(github.event.pull_request.title, 'feat')) + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: 3.12 + - name: Install dependencies + run: | + curl -sSL https://install.python-poetry.org | python3 - + poetry install + poetry self add poetry-exec-plugin + - name: bump version in pyproject.toml + run: poetry exec bump-version + - name: publish new version to PyPI + run: | + rm -rf dist/ build/ + poetry build + poetry publish -u=__token__ -p=${{ secrets.PYPI_DASCHBOT_TOKEN }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-release-to-pypi.yml similarity index 62% rename from .github/workflows/publish-to-pypi.yml rename to .github/workflows/publish-release-to-pypi.yml index 1107af021..efbeff844 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-release-to-pypi.yml @@ -1,25 +1,22 @@ --- -name: Publish to PyPI +name: Publish release to PyPI on: - push: - branches: - - main + release: + types: [released] env: TOKEN: ${{ secrets.GH_TOKEN }} - POETRY_HTTP_BASIC_PYPI_USERNAME: __token__ - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_DASCHBOT_TOKEN }} jobs: - publish-to-pypi: + publish-release-to-pypi: runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v3 with: - fetch-depth: 0 + fetch-depth: 1 - name: Set up Python 3.12 uses: actions/setup-python@v4 with: @@ -28,18 +25,15 @@ jobs: run: | curl -sSL https://install.python-poetry.org | python3 - poetry install - poetry self add poetry-exec-plugin - - name: bump version in pyproject.toml - run: poetry exec bump-version - name: publish new version to PyPI run: | rm -rf dist/ build/ - poetry build # generate distribution package - poetry publish # upload distribution package to PyPI + poetry build + poetry publish -u=__token__ -p=${{ secrets.PYPI_DASCHBOT_TOKEN }} notification: name: Google chat notification about release and published version - needs: [publish-to-pypi] + needs: [publish-release-to-pypi] runs-on: ubuntu-latest steps: - name: Send notification to google chat room "DSP releases" diff --git a/src/dsp_tools/cli/entry_point.py b/src/dsp_tools/cli/entry_point.py index 7609b9781..814462786 100644 --- a/src/dsp_tools/cli/entry_point.py +++ b/src/dsp_tools/cli/entry_point.py @@ -88,7 +88,7 @@ def _check_version() -> None: if latest > installed: msg = colored( f"You are using DSP-TOOLS version {installed}, but version {latest} is available. " - "Consider upgrading via 'pip3 install --upgrade --pre dsp-tools'.", + "Consider upgrading via 'pip3 install --upgrade dsp-tools'.", color="red", ) print(msg) @@ -122,10 +122,11 @@ def _get_version() -> str: _detail_version = result.stdout.decode("utf-8") # _detail_version has one of the following formats: # - 'dsp-tools==5.0.3\n' + # - 'dsp-tools==5.6.0.post9\n' # - 'dsp-tools @ git+https://github.com/dasch-swiss/dsp-tools.git@1f95f8d1b79bd5170a652c0d04e7ada417d76734\n' # - '-e git+ssh://git@github.com/dasch-swiss/dsp-tools.git@af9a35692b542676f2aa0a802ca7fc3b35f5713d#egg=dsp_tools\n' # - '' - if version_number := regex.search(r"\d+\.\d+\.\d+", _detail_version): + if version_number := regex.search(r"\d+\.\d+\.\d+(\.(post|dev|pre)\d+)?", _detail_version): return version_number.group(0) if regex.search(r"github.com", _detail_version): return _detail_version.replace("\n", "")