Skip to content

Commit f8d7a18

Browse files
committed
feat(make): add the emergency-release target to locally build and publish a new package release without Github Action workflows
1 parent 0273b27 commit f8d7a18

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ test:
175175
.PHONY: dist
176176
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
177177
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl: check test
178-
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format wheel
178+
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format wheel
179179
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz: check test
180-
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format sdist
180+
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format sdist
181181
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip: docs-html
182182
python -m zipfile -c dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip docs/_build/html/
183183
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip: docs-md
@@ -202,6 +202,24 @@ docs/_build/markdown/Home.md: check test
202202
$(MAKE) -C docs/ markdown
203203
mv docs/_build/markdown/index.md docs/_build/markdown/Home.md
204204

205+
# In rare cases (e.g. when Github goes down) it might be necessary to build and publish
206+
# a package release directly, instead of using the Github Actions workflows. The target
207+
# assumes that all credentials required by `twine` are available through environment
208+
# variables: https://twine.readthedocs.io/en/stable/#environment-variables
209+
emergency-release: emergency-release-pypi
210+
emergency-release-pypi:
211+
if [ "$$(git branch --show-current)" != "main" ]; then \
212+
echo "Must be on the main branch to release" && exit 1; \
213+
fi
214+
if [ "$$(git status --porcelain)" != "" ]; then \
215+
echo "Changes detected, please stash or commit them first" && exit 1; \
216+
fi
217+
cz --no-raise 21 bump --changelog --yes
218+
git push
219+
git push --tags
220+
$(MAKE) dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
221+
# python -m twine upload --verbose --skip-existing dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
222+
205223
# Prune the packages currently installed in the virtual environment down to the required
206224
# packages only. Pruning works in a roundabout way, where we first generate the wheels for
207225
# all installed packages into the build/wheelhouse/ folder. Next we wipe all packages and

0 commit comments

Comments
 (0)