From 9d5ff4b5eda49165b8384395b2876f5c58bee657 Mon Sep 17 00:00:00 2001 From: lazyfp Date: Sat, 17 Oct 2026 11:18:50 +0200 Subject: [PATCH] Package the proxy for PyPI and add a publishing workflow Add pyproject.toml (hatchling) so the proxy can be installed from PyPI, and a release.yml that publishes on a v* tag via Trusted Publishing, gated on the full test suite. The distribution is "argyll": "argyle" and "proxy.py" are both taken on PyPI, and Argyll is the Scottish namesake of the argyle sock pattern the project puns on. The installed command is "argyle". The single source file is shipped as the module "argyll" (hatchling force-include), not "proxy", so installing it cannot shadow that common top-level name; the source file stays proxy.py. tests.yml gains a workflow_call trigger so release.yml can reuse it as the publish gate, and its push trigger is narrowed to branches so a tag no longer runs it twice. The tag-vs-version check already in tests.yml's release-version job still runs, via that reuse. release.yml pins its actions to commit SHAs, as the workflow that holds publish rights; tests.yml keeps its tag pins. Publishing also needs a pending publisher configured on PyPI (repo, release.yml, environment "pypi"); until then the publish job has nothing to authenticate to. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_018BQF9WQNaTBCJ6YB38RBU7 --- .github/workflows/release.yml | 66 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 2 ++ pyproject.toml | 48 +++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7e71630 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Publish to PyPI + +# Publishes to PyPI via Trusted Publishing (OIDC) when a version tag is pushed. +# No API token is needed -- configure a pending publisher on PyPI that matches +# this repo, this workflow (release.yml) and the "pypi" environment. +# +# A pushed v* tag is the only trigger. The whole test suite runs first and gates +# the build: tests.yml is reused as `test`, so a tag on a red commit publishes +# nothing -- which matters because a PyPI version can never be replaced. The +# tag-vs-version check lives in tests.yml's `release-version` job and runs here +# too, since the reused workflow sees the tag ref. +# +# Actions are pinned to commit SHAs, each checked against the tag in its upstream +# repo that the trailing comment names. A tag can be moved after the fact; a +# commit cannot. (tests.yml still uses tag pins; Dependabot keeps both current.) +on: + push: + tags: + - "v*" + +permissions: + contents: read + +jobs: + test: + name: Test + uses: ./.github/workflows/tests.yml + + build: + name: Build distribution + needs: [test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.x" + - name: Build sdist and wheel + run: | + python -m pip install --upgrade build + python -m build + - name: Check metadata + run: | + python -m pip install --upgrade twine + python -m twine check dist/* + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: dist + path: dist/ + + publish: + name: Publish to PyPI + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write # required for Trusted Publishing (OIDC) + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: dist + path: dist/ + - name: Publish + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e54b8f2..323fe4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,8 +10,10 @@ name: tests on: push: + branches: ['**'] # branches only; a v* tag is tested via release.yml's reuse of this workflow pull_request: workflow_dispatch: + workflow_call: # release.yml runs this whole suite as its gate before publishing permissions: contents: read diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c0b34da --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "argyll" +description = "A single-file, standard-library SOCKS5 CONNECT proxy built on asyncio." +readme = "README.md" +requires-python = ">=3.6" +license = "MIT" +license-files = ["LICENSE"] +authors = [{ name = "lazyfp" }] +keywords = ["socks5", "socks", "proxy", "asyncio", "networking", "tcp", "rfc1928", "ctf"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Framework :: AsyncIO", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Intended Audience :: Information Technology", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Internet :: Proxy Servers", + "Topic :: System :: Networking", + "Topic :: Security", +] +dynamic = ["version"] + +# The distribution is "argyll" (the Scottish namesake of the argyle sock +# pattern; "argyle" and "proxy.py" were both taken on PyPI). The installed +# command is "argyle", and the single source file ships as the module "argyll" +# rather than "proxy" so it cannot shadow the common top-level name. +[project.scripts] +argyle = "argyll:main" + +[project.urls] +Homepage = "https://github.com/BearlyStable/argyle" +Repository = "https://github.com/BearlyStable/argyle" +Issues = "https://github.com/BearlyStable/argyle/issues" + +[tool.hatch.version] +path = "proxy.py" + +[tool.hatch.build.targets.wheel] +force-include = { "proxy.py" = "argyll.py" } + +[tool.hatch.build.targets.sdist] +include = ["proxy.py", "tests/", "README.md", "LICENSE", "CHANGELOG.md"]