From f191652b241bb2d2a7e9ee6c07863237e7d72163 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Wed, 20 Nov 2024 19:44:03 -0800 Subject: [PATCH 1/4] Manage version with Incremental --- pyproject.toml | 4 +- requirements_release.in | 1 + requirements_release.txt | 83 +++++++++++++++++++++++++++++++++++++--- yarrharr/__init__.py | 4 +- yarrharr/_version.py | 11 ++++++ 5 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 yarrharr/_version.py diff --git a/pyproject.toml b/pyproject.toml index b897d79d..478c0810 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "incremental>=24.7.2"] build-backend = "hatchling.build" [project] @@ -48,7 +48,7 @@ packages = ["yarrharr"] artifacts = ["/yarrharr/static"] [tool.hatch.version] -path = "yarrharr/__init__.py" +source = "incremental" [tool.ruff] line-length = 150 diff --git a/requirements_release.in b/requirements_release.in index e47b6e99..7ce1d72c 100644 --- a/requirements_release.in +++ b/requirements_release.in @@ -1,2 +1,3 @@ build twine +hatch diff --git a/requirements_release.txt b/requirements_release.txt index 219aae0a..35c8f614 100644 --- a/requirements_release.txt +++ b/requirements_release.txt @@ -4,22 +4,55 @@ # # pip-compile --output-file=requirements_release.txt requirements_release.in # +anyio==4.6.2.post1 + # via httpx bleach==6.0.0 # via readme-renderer build==1.2.1 # via -r requirements_release.in certifi==2024.8.30 - # via requests + # via + # httpcore + # httpx + # requests cffi==1.15.1 # via cryptography charset-normalizer==3.2.0 # via requests +click==8.1.7 + # via + # hatch + # userpath cryptography==43.0.3 # via secretstorage +distlib==0.3.9 + # via virtualenv docutils==0.20.1 # via readme-renderer +editables==0.5 + # via hatchling +exceptiongroup==1.2.2 + # via anyio +filelock==3.16.1 + # via virtualenv +h11==0.14.0 + # via httpcore +hatch==1.9.7 + # via -r requirements_release.in +hatchling==1.21.1 + # via hatch +httpcore==1.0.7 + # via httpx +httpx==0.27.2 + # via hatch +hyperlink==21.0.0 + # via hatch idna==3.7 - # via requests + # via + # anyio + # httpx + # hyperlink + # requests importlib-metadata==6.8.0 # via # build @@ -32,7 +65,9 @@ jeepney==0.8.0 # keyring # secretstorage keyring==24.2.0 - # via twine + # via + # hatch + # twine markdown-it-py==3.0.0 # via rich mdurl==0.1.2 @@ -40,9 +75,24 @@ mdurl==0.1.2 more-itertools==10.0.0 # via jaraco-classes packaging==23.1 - # via build + # via + # build + # hatch + # hatchling +pathspec==0.12.1 + # via hatchling +pexpect==4.9.0 + # via hatch pkginfo==1.9.6 # via twine +platformdirs==4.3.6 + # via + # hatch + # virtualenv +pluggy==1.5.0 + # via hatchling +ptyprocess==0.7.0 + # via pexpect pycparser==2.21 # via cffi pygments==2.15.1 @@ -62,22 +112,45 @@ requests-toolbelt==1.0.0 rfc3986==2.0.0 # via twine rich==13.5.2 - # via twine + # via + # hatch + # twine secretstorage==3.3.3 # via keyring +shellingham==1.5.4 + # via hatch six==1.16.0 # via bleach +sniffio==1.3.1 + # via + # anyio + # httpx tomli==2.0.1 # via # build + # hatchling # pyproject-hooks +tomli-w==1.1.0 + # via hatch +tomlkit==0.13.2 + # via hatch +trove-classifiers==2024.10.21.16 + # via hatchling twine==5.1.1 # via -r requirements_release.in +typing-extensions==4.12.2 + # via anyio urllib3==2.2.2 # via # requests # twine +userpath==1.9.2 + # via hatch +virtualenv==20.25.3 + # via hatch webencodings==0.5.1 # via bleach zipp==3.19.2 # via importlib-metadata +zstandard==0.23.0 + # via hatch diff --git a/yarrharr/__init__.py b/yarrharr/__init__.py index 54d9316c..f83975bf 100644 --- a/yarrharr/__init__.py +++ b/yarrharr/__init__.py @@ -23,6 +23,8 @@ # such a combination shall include the source code for the parts of # OpenSSL used as well as that of the covered work. +from importlib.metadata import version + __author__ = "Tom Most" __author_email__ = "twm@freecog.net" -__version__ = "2024.11.0" +__version__ = version("yarrharr") diff --git a/yarrharr/_version.py b/yarrharr/_version.py new file mode 100644 index 00000000..a55a1f73 --- /dev/null +++ b/yarrharr/_version.py @@ -0,0 +1,11 @@ +""" +Provides yarrharr version information. +""" + +# This file is auto-generated! Do not edit! +# Use `incremental` to change this file. + +from incremental import Version + +__version__ = Version("yarrharr", 24, 11, 0) +__all__ = ["__version__"] From c79c6d1ba980cbd8c000884ef3958983a5640460 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Wed, 20 Nov 2024 19:45:50 -0800 Subject: [PATCH 2/4] Build the artifact in GHA --- .github/workflows/ci.yml | 19 +++++++++++++++---- bin/release.sh | 8 ++++++++ justfile | 9 +-------- 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100755 bin/release.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0a59758..8664ee0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ on: pull_request: branches: ["trunk"] +permissions: + contents: read + jobs: tox: name: "tox -e ${{ matrix.tox-env }}" @@ -32,8 +35,8 @@ jobs: - run: "python -m pip install tox" - # Temporary hack: create files normally created by Webpack that are - # expected to exist by the manifest.json view test. + # Temporary hack: create files normally created by bin/compile-static.py + # that are expected to exist by the manifest.json view test. - run: | mkdir yarrharr/static touch yarrharr/static/{icon,logotype,lettertype}-xyz.{ico,png,svg} @@ -42,8 +45,8 @@ jobs: - run: "python -m tox" - webpack: - name: "tox -e static" + build: + name: "build dist" runs-on: ubuntu-24.04 @@ -67,3 +70,11 @@ jobs: - run: "python -m tox -e static --notest" - run: "tox -e static" + + - run: "bin/release.sh" + + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/*.* + if-no-files-found: error diff --git a/bin/release.sh b/bin/release.sh new file mode 100755 index 00000000..ce770ab8 --- /dev/null +++ b/bin/release.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -exu -o pipefail +git diff --quiet HEAD || exit 1 +tox -e release --notest +version=$(.tox/release/bin/hatch version) +.tox/release/bin/python -m build +.tox/release/bin/python -m twine check "dist/yarrharr-${version}.tar.gz" "dist/yarrharr-${version}-py3-none-any.whl" +git tag "v${version}" diff --git a/justfile b/justfile index de729f74..486bc75d 100644 --- a/justfile +++ b/justfile @@ -9,14 +9,7 @@ _static: tox -e static release: _static - #!/usr/bin/env bash - set -exu -o pipefail - git diff --quiet HEAD || exit 1 - tox -e release --notest - version=$(grep -oP '(?<=__version__ = ")([^"]+)(?=")' yarrharr/__init__.py) - .tox/release/bin/python -m build - .tox/release/bin/python -m twine check "dist/yarrharr-${version}.tar.gz" "dist/yarrharr-${version}-py3-none-any.whl" - git tag "v${version}" + bin/release.sh devserver: _static tox -e run -- django-admin migrate From 1a8defec52233fd22b3b63b0d0c25703a4333846 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Wed, 20 Nov 2024 19:54:13 -0800 Subject: [PATCH 3/4] pkginfo 1.10.0 For https://github.com/pypa/twine/issues/1059 --- requirements.txt | 1 - requirements_release.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8ef16c2a..62c40c97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -75,7 +75,6 @@ treq==24.9.1 twisted[tls]==24.7.0 # via # treq - # twisted # yarrharr (pyproject.toml) typing-extensions==4.7.1 # via diff --git a/requirements_release.txt b/requirements_release.txt index 35c8f614..835d132c 100644 --- a/requirements_release.txt +++ b/requirements_release.txt @@ -83,7 +83,7 @@ pathspec==0.12.1 # via hatchling pexpect==4.9.0 # via hatch -pkginfo==1.9.6 +pkginfo==1.10.0 # via twine platformdirs==4.3.6 # via From 1e2acb0f965671e6979f231d45443bfd35aca375 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Tue, 3 Dec 2024 21:46:43 -0800 Subject: [PATCH 4/4] Create a GitHub release on tag --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8664ee0e..c0c7e051 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: branches: ["trunk"] + tags: ["v*"] pull_request: branches: ["trunk"] @@ -24,6 +25,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5.3.0 with: @@ -46,12 +49,12 @@ jobs: - run: "python -m tox" build: - name: "build dist" - runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: apt install run: | @@ -78,3 +81,34 @@ jobs: name: dist path: dist/*.* if-no-files-found: error + + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [build] + + runs-on: ubuntu-24.04 + + permissions: + contents: write + + steps: + + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - run: | + set -eux + tag="${TAG_REF##*/}" + version=${tag#v} + gh release create "$tag" \ + --repo twm/yarrharr \ + --verify-tag \ + --title "Yarrharr $version" \ + --generate-notes \ + "dist/yarrharr-${version}.tar.gz" \ + "dist/yarrharr-${version}"*.whl + env: + GH_TOKEN: ${{ github.token }} + TAG_REF: ${{ github.ref }}