From 4f10b9d7715e818e7dd1fb4bbeca95b99a513015 Mon Sep 17 00:00:00 2001 From: Alec Rosenbaum <alec.rosenbaum@close.com> Date: Mon, 24 Jun 2024 13:41:58 -0400 Subject: [PATCH 1/4] move version into __init__.py --- quotequail/__init__.py | 1 + setup.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/quotequail/__init__.py b/quotequail/__init__.py index 05dd241..d38805b 100644 --- a/quotequail/__init__.py +++ b/quotequail/__init__.py @@ -4,6 +4,7 @@ from . import _internal, _patterns +__version__ = "0.2.3" __all__ = ["quote", "quote_html", "unwrap", "unwrap_html"] diff --git a/setup.py b/setup.py index 478f89a..8ff40b7 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,14 @@ +import re + from setuptools import setup +VERSION_FILE = "quotequail/__init__.py" +with open(VERSION_FILE, encoding="utf8") as fd: + version = re.search(r'__version__ = ([\'"])(.*?)\1', fd.read()).group(2) + setup( name="quotequail", - version="0.2.3", + version=version, url="http://github.com/closeio/quotequail", license="MIT", author="Thomas Steinacher", From 6403ceaa9b6fc5f8c84ff9db086039436c603b59 Mon Sep 17 00:00:00 2001 From: Alec Rosenbaum <alec.rosenbaum@close.com> Date: Mon, 24 Jun 2024 13:46:19 -0400 Subject: [PATCH 2/4] add manually dispatched release action --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) 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..b95f3fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release To PyPI + +on: + workflow_dispatch: + inputs: + requested_release_tag: + description: 'The tag to use for this release (e.g., `v2.3.0`)' + required: true + +jobs: + build_and_upload: + runs-on: arc-amd64-runners + environment: production + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: 3.8 + + - run: | + pip install packaging + - name: Normalize the release version + run: | + echo "release_version=`echo '${{ github.event.inputs.requested_release_tag }}' | sed 's/^v//'`" >> $GITHUB_ENV + - name: Normalize the release tag + run: | + echo "release_tag=v${release_version}" >> $GITHUB_ENV + - name: Get the VERSION from setup.py + run: | + echo "package_version=`grep -Po '__version__ = "\K[^"]*' quotequail/__init__.py`" >> $GITHUB_ENV + - name: Get the latest version from PyPI + run: | + curl https://pypi.org/pypi/quotequail/json | python -c 'import json, sys; contents=sys.stdin.read(); parsed = json.loads(contents); print("pypi_version=" + parsed["info"]["version"])' >> $GITHUB_ENV + - name: Log all the things + run: | + echo 'Requested release tag `${{ github.event.inputs.requested_release_tag }}`' + echo 'Release version `${{ env.release_version }}`' + echo 'Release tag `${{ env.release_tag }}`' + echo 'version in package `${{ env.package_version }}`' + echo 'Version in PyPI `${{ env.pypi_version }}`' + - name: Verify that the version string we produced looks like a version string + run: | + echo "${{ env.release_version }}" | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}' + - name: Verify that the version tag we produced looks like a version tag + run: | + echo "${{ env.release_tag }}" | sed '/^v[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}' + - name: Verify that the release version matches the VERSION in the package source + run: | + [[ ${{ env.release_version }} == ${{ env.package_version }} ]] + - name: Verify that the `release_version` is larger/newer than the existing release in PyPI + run: | + python -c 'import sys; from packaging import version; code = 0 if version.parse("${{ env.package_version }}") > version.parse("${{ env.pypi_version }}") else 1; sys.exit(code)' + - name: Verify that the `release_version` is present in the CHANGELOG + run: | + grep ${{ env.release_version }} CHANGELOG.md + - name: Serialize normalized release values as outputs + run: | + echo "release_version=$release_version" + echo "release_tag=$release_tag" + echo "release_version=$release_version" >> $GITHUB_OUTPUT + echo "release_tag=$release_tag" >> $GITHUB_OUTPUT + - name: Build Source Distribution + run: | + python setup.py sdist + - name: Upload to PyPI + uses: closeio/gh-action-pypi-publish@a260c7e54e4251db69485e1e7ca271aec8c0ddf9 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} From 7fa0ce70fed8b39bb81569a38fe67327cfe299e3 Mon Sep 17 00:00:00 2001 From: Alec Rosenbaum <alec.rosenbaum@close.com> Date: Mon, 24 Jun 2024 13:51:33 -0400 Subject: [PATCH 3/4] add changelog + bump version --- CHANGELOG.md | 9 +++++++++ quotequail/__init__.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8ec5dbe --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changes + +## v0.2.4 + +* First version using auto-release process +* Added support for russian, portuguese, and swedish reply patterns +* Fixed bug where newlines just before "wrote:" weren't detected +* updated repo to apply more modern linting + code style + diff --git a/quotequail/__init__.py b/quotequail/__init__.py index d38805b..4ab2e30 100644 --- a/quotequail/__init__.py +++ b/quotequail/__init__.py @@ -4,7 +4,7 @@ from . import _internal, _patterns -__version__ = "0.2.3" +__version__ = "0.2.4" __all__ = ["quote", "quote_html", "unwrap", "unwrap_html"] From 466300e2dbdd3755229b5a02f776a2b8c1c7905d Mon Sep 17 00:00:00 2001 From: Alec Rosenbaum <alec.rosenbaum@close.com> Date: Mon, 24 Jun 2024 13:56:32 -0400 Subject: [PATCH 4/4] also create a tag on the released commit --- .github/workflows/release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b95f3fe..81f39d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,16 @@ jobs: echo "release_tag=$release_tag" echo "release_version=$release_version" >> $GITHUB_OUTPUT echo "release_tag=$release_tag" >> $GITHUB_OUTPUT + - name: Tag commit + uses: actions/github-script@v7.0.1 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ env.release_tag }}', + sha: context.sha + }) - name: Build Source Distribution run: | python setup.py sdist