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"]