|
| 1 | +# Copyright (c) 2023, Oracle and/or its affiliates. |
| 2 | +# |
| 3 | +# The Universal Permissive License (UPL), Version 1.0 |
| 4 | +# |
| 5 | +# Subject to the condition set forth below, permission is hereby granted to any |
| 6 | +# person obtaining a copy of this software, associated documentation and/or data |
| 7 | +# (collectively the "Software"), free of charge and under any and all copyright |
| 8 | +# rights in the Software, and any and all patent rights owned or freely |
| 9 | +# licensable by each licensor hereunder covering either (i) the unmodified |
| 10 | +# Software as contributed to or provided by such licensor, or (ii) the Larger |
| 11 | +# Works (as defined below), to deal in both |
| 12 | +# |
| 13 | +# (a) the Software, and |
| 14 | +# (b) any piece of software and/or hardware listed in the |
| 15 | +# lrgrwrks.txt file if one is included with the Software (each a "Larger |
| 16 | +# Work" to which the Software is contributed by such licensors), |
| 17 | +# |
| 18 | +# without restriction, including without limitation the rights to copy, create |
| 19 | +# derivative works of, display, perform, and distribute the Software and make, |
| 20 | +# use, sell, offer for sale, import, export, have made, and have sold the |
| 21 | +# Software and the Larger Work(s), and to sublicense the foregoing rights on |
| 22 | +# either these or other terms. |
| 23 | +# |
| 24 | +# This license is subject to the following condition: The above copyright notice |
| 25 | +# and either this complete permission notice or at a minimum a reference to the |
| 26 | +# UPL must be included in all copies or substantial portions of the Software. |
| 27 | +# |
| 28 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 29 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 30 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 31 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 32 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 33 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 34 | +# SOFTWARE. |
| 35 | + |
| 36 | +VERSION=$(shell grep 'VERSION =' setup.py | sed s/\"//g | awk '{print($$3)}') |
| 37 | + |
| 38 | +PYTHON ?= python3 |
| 39 | +pyver_maj = $(shell $(PYTHON) --version | cut -d. -f1 | sed 's/Python //') |
| 40 | +pyver_min = $(shell $(PYTHON) --version | cut -d. -f2) |
| 41 | + |
| 42 | +.PHONY: development |
| 43 | +development: |
| 44 | + @if [ $(pyver_maj) -ne 3 ] || [ $(pyver_min) -lt 6 ]; then \ |
| 45 | + echo error: Your Python $(pyver_maj).$(pyver_min), from command \"$(PYTHON)\", is not supported; \ |
| 46 | + echo Yo requires Python 3.6 or newer.; \ |
| 47 | + echo If you have another installed, try using make PYTHON=/path/to/python; \ |
| 48 | + exit 1; \ |
| 49 | + fi |
| 50 | + $(PYTHON) -m pip install --user --upgrade tox pre-commit |
| 51 | + $(PYTHON) -m pre_commit install --install-hooks |
| 52 | + |
| 53 | +.PHONY: test |
| 54 | +test: |
| 55 | + @$(PYTHON) -m tox |
| 56 | + |
| 57 | +.PHONY: docs |
| 58 | +docs: |
| 59 | + @$(PYTHON) -m tox -e docs |
| 60 | + |
| 61 | +.PHONY: docs-publish |
| 62 | +docs-publish: docs |
| 63 | + rsync -avz .tox/docs_out/ ca-common:public_html/yo |
| 64 | + |
| 65 | +.PHONY: _release_sanity_check |
| 66 | +_release_sanity_check: |
| 67 | + @if [ ! $$(git symbolic-ref -q HEAD) = "refs/heads/master" ]; then \ |
| 68 | + echo error: You must be on master to release a new version.; \ |
| 69 | + exit 1; \ |
| 70 | + fi |
| 71 | + @if [ ! -z "$$(git status --porcelain)" ]; then \ |
| 72 | + echo error: Your git tree is unclean, please commit or stash it.; \ |
| 73 | + exit 1; \ |
| 74 | + fi |
| 75 | + @if [ "$$(git describe --tags --abbrev=0)" = "$(VERSION)" ]; then \ |
| 76 | + echo error: It looks like you have not bumped the version since last release.; \ |
| 77 | + exit 1; \ |
| 78 | + fi |
| 79 | + @if [ -z "$$(grep ^$(shell echo $(VERSION) | sed 's/\./\\./g') CHANGELOG.md)" ]; then \ |
| 80 | + echo error: It looks like you have not documented this release in CHANGELOG.md; \ |
| 81 | + exit 1; \ |
| 82 | + fi |
| 83 | + @if [ -f dist/yo-$(VERSION).tar.gz ]; then \ |
| 84 | + echo error: There is already a built tarball: dist/yo-$(VERSION).tar.gz; \ |
| 85 | + echo Either verify you have bumped the version, or delete the; \ |
| 86 | + echo distributions you have built for $(VERSION); \ |
| 87 | + exit 1; \ |
| 88 | + fi |
| 89 | + |
| 90 | + |
| 91 | +.PHONY: release |
| 92 | +release: _release_sanity_check test |
| 93 | + $(PYTHON) setup.py sdist |
| 94 | + $(PYTHON) setup.py bdist_wheel |
| 95 | + @echo "Built the following artifacts for yo $(VERSION):" |
| 96 | + @ls -l dist/yo-$(VERSION)* |
| 97 | + @echo "Point of no return: time to tag and upload this release" |
| 98 | + @echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ] |
| 99 | + @echo Confirmed |
| 100 | + twine upload -r oracle dist/yo-$(VERSION)* |
| 101 | + git push origin master |
| 102 | + git tag v$(VERSION) |
| 103 | + git push origin v$(VERSION) |
0 commit comments