-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-release
executable file
·62 lines (54 loc) · 1.91 KB
/
build-release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
#
# Release script for a generic Python project using pyproject.toml
#
# Run this from the root directory of the project to be released.
# Generally used in conjunction with the instructions in r8format:
# https://github.com/mc68-net/r8format/blob/main/doc/release.md
#
# This is currently a hack that still needs a good bit of manual work
# and checking, but it helps.
#
set -Eeuo pipefail
trap 'echo 1>&2 "INTERNAL ERROR exitcode=$? line=$LINENO"' ERR
die() { local ec=$?; shift; echo 1>&2 "$(basename "$0"):" "$@"; exit $ec; }
warn() { echo 1>&2 "WARNING:" "$@"; }
####################################################################
# Command line parsing
allow_dev=false
upload=false
while [[ $# -gt 0 ]]; do case "$1" in
-d) shift; allow_dev=true;;
-u) shift; upload=true;;
-*) die 2 "Unknown option: $1";;
*) break;;
esac; done
[[ $# -gt 0 ]] && die 2 "This program does not accept arguments."
####################################################################
# Configuration validation
[[ -r pyproject.toml ]] || die 1 'pyproject.toml not found'
if grep '^version = ' pyproject.toml | grep -q dev; then
if $allow_dev; then
warn 'pyproject.toml version number includes "dev"'
else
die 1 'pyproject.toml version number includes "dev"'
fi
fi
# XXX test that doc/CHANGELOG.md includes version number above and
# current date
####################################################################
# Release process
reldir=.build/release
echo '• pactivate'
. ./pactivate -q
pip -q install build twine
rm -rf "$reldir"; mkdir -p "$reldir/dist"
echo "• pyproject-build (output to $reldir/build.log)"
pyproject-build --outdir "$reldir/dist/" >"$reldir/build.log"
echo '• twine check'
twine check --strict "$reldir/dist"/*
if $upload; then
echo '• twine upload'
twine upload "$reldir/dist"/*
fi
echo '• OK'