Skip to content

Commit

Permalink
chore: don't send chat notification on post releases / release only o…
Browse files Browse the repository at this point in the history
…n "feat" or "fix" (DEV-3148) (#707)
  • Loading branch information
jnussbaum committed Dec 28, 2023
1 parent 4f6cd6d commit fd9b148
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
37 changes: 37 additions & 0 deletions .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 }}
@@ -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:
Expand All @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions src/dsp_tools/cli/entry_point.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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", "")
Expand Down

0 comments on commit fd9b148

Please sign in to comment.