Skip to content

Commit

Permalink
build: real packaging on pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Apr 15, 2023
1 parent dd14b96 commit 06f262f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 10 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include .editorconfig
include Makefile
include dev-requirements.txt
51 changes: 49 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help clean tools dist test_pypi pypi
.PHONY: help clean tools dist test_pypi pypi pipx

.DEFAULT_GOAL := help

Expand All @@ -19,10 +19,57 @@ dist: ## Build the distributions.
python -m twine check dist/*

test_pypi: ## Upload the distributions to PyPI's testing server.
python -m twine upload --verbose --repository testpypi dist/*
python -m twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/*

pypi: ## Upload the built distributions to PyPI.
python -m twine upload --verbose dist/*

pipx: ## Install locally as a command
pipx install --force -e .

test_release: clean check_release dist test_pypi ## Do all the steps for a test release

release: clean check_release dist pypi tag gh_release ## Do all the steps for a release

check_release: _check_manifest _check_tree _check_readme _check_version ## Check that we are ready for a release
@echo "Release checks passed"

_pip_install_e:
python -m pip install -q -e .

_check_manifest:
python -m check_manifest

_check_tree:
@if [[ -n $$(git status --porcelain) ]]; then \
echo 'There are modified files! Did you forget to check them in?'; \
exit 1; \
fi

_check_readme: _pip_install_e
@if grep -q Unreleased README.rst; then \
echo 'I see Unreleased in README.rst! Did you forget to edit it?'; \
exit 1; \
fi
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
if grep -q $$VER README.rst; then \
echo 'Current version is in the README.rst'; \
else \
echo "No entry in README.rst for version $$VER!"; \
exit 1; \
fi

_check_version: _pip_install_e
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
if [[ $$(git tags | grep -q -w $$VER && echo "x") == "x" ]]; then \
echo 'A git tag for this version exists! Did you forget to bump the version in src/watchgha/__init__.py?'; \
exit 1; \
fi

tag: _pip_install_e ## Make a git tag with the version number
@export VER="$$(python -c "import watchgha as me; print(me.__version__)")" && \
git tag -a -m "Version $$VER" $$VER
git push --all

gh_release: ## Publish a GitHub release
python -m scriv github-release --all
18 changes: 11 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ I suggest installing with `pipx`_:

.. code-block:: shell
$ pipx install git+https://github.com/nedbat/watchgha
$ pipx install watchgha
Now you have a command ``watch_gha_runs`` available. I use a `git alias`_
so that my current repo and branch are implied:
Expand Down Expand Up @@ -115,8 +115,10 @@ status::
Changelog
=========

Unreleased
----------
.. scriv-start-here
1.0.0 — 2023-04-15
------------------

- The ``--poll`` option sets the number of seconds to wait between refreshes.

Expand All @@ -130,35 +132,37 @@ Unreleased
- Long lines are no longer wrapped too short.


0.6.0 2023-03-22
0.6.0 2023-03-22
------------------

- Runs can be selected by a commit SHA by using ``--sha`` on the command line.

- Retry if GitHub returns "502 - Bad Gateway".


0.5.0 2023-03-15
0.5.0 2023-03-15
------------------

- Uses a ``GITHUB_TOKEN`` environment variable for authentication if it is
defined.


0.0.2 2023-03-14
0.0.2 2023-03-14
------------------

- Support more forms of repo URLs: ``git@github.com:``, without ``.git``, etc.

- Better error messages if the repo URL can't be parsed.


0.0.1 2023-03-13
0.0.1 2023-03-13
------------------

First version


.. scriv-end-here
Development
===========

Expand Down
6 changes: 6 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Packages to install for working on the project.

check-manifest
build
scriv
twine
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dynamic = ["version"]
[project.urls]
"Source code" = "https://github.com/nedbat/watchgha"
"Issue tracker" = "https://github.com/nedbat/watchgha/issues"
"Mastodon" = "https://hachyderm.io/@nedbat"
"Funding" = "https://github.com/sponsors/nedbat"

[project.scripts]
watch_gha_runs = "watchgha.watch_runs:main"
Expand All @@ -47,3 +49,10 @@ version.attr = "watchgha.__version__"
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.scriv]
# Changelog management: https://pypi.org/project/scriv/
format = "rst"
output_file = "README.rst"
insert_marker = "scriv-start-here"
end_marker = "scriv-end-here"
2 changes: 1 addition & 1 deletion src/watchgha/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0"
__version__ = "1.0.0"

0 comments on commit 06f262f

Please sign in to comment.