From 518416840cd9ba5183318b374795eca67c2b11ac Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Fri, 12 May 2023 07:11:47 +1000 Subject: [PATCH 1/2] feat(make): add the emergency-release target to locally build and publish a new package release without Github Action workflows --- Makefile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d1d306f9..4e49fb7b 100644 --- a/Makefile +++ b/Makefile @@ -177,9 +177,9 @@ test: .PHONY: dist dist: dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-build-epoch.txt dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl: check test - SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format wheel + SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format wheel dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz: check test - SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format sdist + SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format sdist dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip: docs-html python -m zipfile -c dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip docs/_build/html/ dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip: docs-md @@ -204,6 +204,24 @@ docs/_build/markdown/Home.md: check test $(MAKE) -C docs/ markdown mv docs/_build/markdown/index.md docs/_build/markdown/Home.md +# In rare cases (e.g. when Github goes down) it might be necessary to build and publish +# a package release directly, instead of using the Github Actions workflows. The target +# assumes that all credentials required by `twine` are available through environment +# variables: https://twine.readthedocs.io/en/stable/#environment-variables +emergency-release: emergency-release-pypi +emergency-release-pypi: + if [ "$$(git branch --show-current)" != "main" ]; then \ + echo "Must be on the main branch to release" && exit 1; \ + fi + if [ "$$(git status --porcelain)" != "" ]; then \ + echo "Changes detected, please stash or commit them first" && exit 1; \ + fi + cz --no-raise 21 bump --changelog --yes + git push + git push --tags + $(MAKE) dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz + # python -m twine upload --verbose --skip-existing dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz + # Prune the packages currently installed in the virtual environment down to the required # packages only. Pruning works in a roundabout way, where we first generate the wheels for # all installed packages into the build/wheelhouse/ folder. Next we wipe all packages and From 92f09cc992539d140793237ad1c57ea7bde2482e Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Mon, 15 May 2023 09:49:49 +1000 Subject: [PATCH 2/2] fix: make sure we run the correct cz tool --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4e49fb7b..d1bd8938 100644 --- a/Makefile +++ b/Makefile @@ -216,7 +216,7 @@ emergency-release-pypi: if [ "$$(git status --porcelain)" != "" ]; then \ echo "Changes detected, please stash or commit them first" && exit 1; \ fi - cz --no-raise 21 bump --changelog --yes + python -m commitizen --no-raise 21 bump --changelog --yes git push git push --tags $(MAKE) dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz