Skip to content

Commit

Permalink
Use trusted publishing and hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Jan 1, 2025
1 parent bfb2b83 commit 6b2f849
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 64 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish release to PyPI

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
pypi-publish:
name: Build and upload release to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pip install build
- run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install:
-rm -rf dist
python -m pip install build
python -m build
python -m pip install --upgrade $$(echo dist/*.whl)[tests]
python -m pip install --upgrade $$(echo dist/*.whl)[test]

.PHONY: test lint release docs

Expand Down
9 changes: 1 addition & 8 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ release:
@if ! type -P pandoc; then echo "Please install pandoc"; exit 1; fi
@if ! type -P sponge; then echo "Please install moreutils"; exit 1; fi
@if ! type -P gh; then echo "Please install gh"; exit 1; fi
@if ! type -P twine; then echo "Please install twine"; exit 1; fi
git pull
git clean -x --force $$(python setup.py --name)
git add setup.py
git clean -x --force yq
TAG_MSG=$$(mktemp); \
echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \
git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \
Expand All @@ -36,13 +34,8 @@ release:
git push --follow-tags
$(MAKE) install
gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
$(MAKE) release-pypi
$(MAKE) release-docs

release-pypi:
python -m build
twine upload dist/*.tar.gz dist/*.whl --verbose

release-docs:
$(MAKE) docs
-git branch -D gh-pages
Expand Down
68 changes: 65 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
[project]
name = "yq"
description = "Command-line YAML/XML processor - jq wrapper for YAML/XML documents"
readme = "README.rst"
requires-python = ">=3.8"
license = { text = "Apache Software License" }
authors = [{ name = "Andrey Kislyuk"}, {email = "[email protected]" }]
maintainers = [{ name = "Andrey Kislyuk"}, {email = "[email protected]" }]
dynamic = ["version"]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"PyYAML >= 5.3.1",
"xmltodict >= 0.11.0",
"tomlkit >= 0.11.6",
"argcomplete >= 1.8.1",
]

[project.optional-dependencies]
test = [
"ruff",
"coverage",
"build",
"wheel",
"mypy",
]

[project.urls]
"Homepage"= "https://github.com/kislyuk/yq"
"Documentation"= "https://xml-security.github.io/yq/"
"Source Code"= "https://github.com/kislyuk/yq"
"Issue Tracker"= "https://github.com/kislyuk/yq/issues"
"Change Log"= "https://github.com/kislyuk/yq/blob/main/Changes.rst"

[project.scripts]
yq = "yq:cli"
xq = "yq:xq_cli"
tomlq = "yq:tq_cli"

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "vcs"

[tool.black]
line-length = 120

Expand All @@ -8,6 +71,8 @@ skip_gitignore = true

[tool.ruff]
line-length = 120

[tool.ruff.lint]
per-file-ignores = {"yq/__init__.py" = ["F401"]}

[tool.mypy]
Expand All @@ -28,6 +93,3 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "yq.version"
ignore_missing_imports = true

[tool.setuptools_scm]
version_file = "yq/version.py"
51 changes: 0 additions & 51 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion yq/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class Parser(argparse.ArgumentParser):
def print_help(self):
def print_help(self, *args, **kwargs):
yq_help = argparse.ArgumentParser.format_help(self).splitlines()
print("\n".join(["usage: {} [options] <jq filter> [input file...]".format(self.prog)] + yq_help[2:] + [""]))
sys.stdout.flush()
Expand Down

0 comments on commit 6b2f849

Please sign in to comment.