Skip to content

Commit 5184168

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 a38e15f commit 5184168

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
@@ -177,9 +177,9 @@ test:
177177
.PHONY: dist
178178
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
179179
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl: check test
180-
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format wheel
180+
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format wheel
181181
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz: check test
182-
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format sdist
182+
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) python -m flit build --setup-py --format sdist
183183
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip: docs-html
184184
python -m zipfile -c dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip docs/_build/html/
185185
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip: docs-md
@@ -204,6 +204,24 @@ docs/_build/markdown/Home.md: check test
204204
$(MAKE) -C docs/ markdown
205205
mv docs/_build/markdown/index.md docs/_build/markdown/Home.md
206206

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

0 commit comments

Comments
 (0)