| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,2 +1,3 @@ | |||
| 1 | 1 | test/fixtures/* eol=lf | |
| 2 | - init-tests-after-clone.sh | ||
| 2 | + *.sh eol=lf | ||
| 3 | + /Makefile eol=lf | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,8 @@ | |||
| 1 | 1 | *.py[co] | |
| 2 | 2 | *.swp | |
| 3 | 3 | *~ | |
| 4 | + .env/ | ||
| 5 | + env/ | ||
| 4 | 6 | .venv/ | |
| 5 | 7 | venv/ | |
| 6 | 8 | /*.egg-info | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,16 +7,10 @@ clean: | |||
| 7 | 7 | rm -rf build/ dist/ .eggs/ .tox/ | |
| 8 | 8 | ||
| 9 | 9 | release: clean | |
| 10 | - # Check if latest tag is the current head we're releasing | ||
| 11 | - echo "Latest tag = $$(git tag | sort -nr | head -n1)" | ||
| 12 | - echo "HEAD SHA = $$(git rev-parse head)" | ||
| 13 | - echo "Latest tag SHA = $$(git tag | sort -nr | head -n1 | xargs git rev-parse)" | ||
| 14 | - @test "$$(git rev-parse head)" = "$$(git tag | sort -nr | head -n1 | xargs git rev-parse)" | ||
| 10 | + ./check-version.sh | ||
| 15 | 11 | make force_release | |
| 16 | 12 | ||
| 17 | 13 | force_release: clean | |
| 18 | - # IF we're in a virtual environment, add build tools | ||
| 19 | - test -z "$$VIRTUAL_ENV" || pip install -U build twine | ||
| 20 | - python3 -m build --sdist --wheel || echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead" | ||
| 14 | + ./build-release.sh | ||
| 21 | 15 | twine upload dist/* | |
| 22 | 16 | git push --tags origin main | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + #!/bin/bash | ||
| 2 | + # | ||
| 3 | + # This script builds a release. If run in a venv, it auto-installs its tools. | ||
| 4 | + # You may want to run "make release" instead of running this script directly. | ||
| 5 | + | ||
| 6 | + set -eEu | ||
| 7 | + | ||
| 8 | + function release_with() { | ||
| 9 | + $1 -m build --sdist --wheel | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + if test -n "${VIRTUAL_ENV:-}"; then | ||
| 13 | + deps=(build twine) # Install twine along with build, as we need it later. | ||
| 14 | + echo "Virtual environment detected. Adding packages: ${deps[*]}" | ||
| 15 | + pip install --quiet --upgrade "${deps[@]}" | ||
| 16 | + echo 'Starting the build.' | ||
| 17 | + release_with python | ||
| 18 | + else | ||
| 19 | + function suggest_venv() { | ||
| 20 | + venv_cmd='python -m venv env && source env/bin/activate' | ||
| 21 | + printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd" | ||
| 22 | + } | ||
| 23 | + trap suggest_venv ERR # This keeps the original exit (error) code. | ||
| 24 | + echo 'Starting the build.' | ||
| 25 | + release_with python3 # Outside a venv, use python3. | ||
| 26 | + fi | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + #!/bin/bash | ||
| 2 | + # | ||
| 3 | + # This script checks if we are in a consistent state to build a new release. | ||
| 4 | + # See the release instructions in README.md for the steps to make this pass. | ||
| 5 | + # You may want to run "make release" instead of running this script directly. | ||
| 6 | + | ||
| 7 | + set -eEfuo pipefail | ||
| 8 | + trap 'echo "$0: Check failed. Stopping." >&2' ERR | ||
| 9 | + | ||
| 10 | + readonly version_path='VERSION' | ||
| 11 | + readonly changes_path='doc/source/changes.rst' | ||
| 12 | + | ||
| 13 | + echo 'Checking current directory.' | ||
| 14 | + test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)" # Ugly, but portable. | ||
| 15 | + | ||
| 16 | + echo "Checking that $version_path and $changes_path exist and have no uncommitted changes." | ||
| 17 | + test -f "$version_path" | ||
| 18 | + test -f "$changes_path" | ||
| 19 | + git status -s -- "$version_path" "$changes_path" | ||
| 20 | + test -z "$(git status -s -- "$version_path" "$changes_path")" | ||
| 21 | + | ||
| 22 | + # This section can be commented out, if absolutely necessary. | ||
| 23 | + echo 'Checking that ALL changes are committed.' | ||
| 24 | + git status -s --ignore-submodules | ||
| 25 | + test -z "$(git status -s --ignore-submodules)" | ||
| 26 | + | ||
| 27 | + version_version="$(cat "$version_path")" | ||
| 28 | + changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")" | ||
| 29 | + config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)" | ||
| 30 | + latest_tag="$(git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)" | ||
| 31 | + head_sha="$(git rev-parse HEAD)" | ||
| 32 | + latest_tag_sha="$(git rev-parse "$latest_tag")" | ||
| 33 | + | ||
| 34 | + # Display a table of all the current version, tag, and HEAD commit information. | ||
| 35 | + echo $'\nThe VERSION must be the same in all locations, and so must the HEAD and tag SHA' | ||
| 36 | + printf '%-14s = %s\n' 'VERSION file' "$version_version" \ | ||
| 37 | + 'changes.rst' "$changes_version" \ | ||
| 38 | + 'Latest tag' "$latest_tag" \ | ||
| 39 | + 'HEAD SHA' "$head_sha" \ | ||
| 40 | + 'Latest tag SHA' "$latest_tag_sha" | ||
| 41 | + | ||
| 42 | + # Check that the latest tag and current version match the HEAD we're releasing. | ||
| 43 | + test "$version_version" = "$changes_version" | ||
| 44 | + test "$latest_tag" = "$version_version" | ||
| 45 | + test "$head_sha" = "$latest_tag_sha" | ||
| 46 | + echo 'OK, everything looks good.' | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments