-
Notifications
You must be signed in to change notification settings - Fork 5
/
basic_release.sh
executable file
·63 lines (52 loc) · 1.25 KB
/
basic_release.sh
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
63
#!/bin/sh
# Inputs
# $1 -- Directory to release
# $2 -- Version number
if [ -z "${1+x}" ] && [ -z "${2+x}" ]
then
echo "Usage: $0 <package_directory> <package_version>"
exit 1
fi
release_dir=$1
version=$2
cd $release_dir
# Check configuration file for variables
config="release_config.sh"
if [ -x "./$config" ]
then
. "./$config"
fi
# Generate news if requested
#if [ -z "${NEWS+x}" ]
#then
# Run news script
#fi
# GH_RELEASE_* Variables from config file
if [ -z "${GH_RELEASE_NOTES+x}" ]
then
gh_notes="--generate-notes"
else
gh_notes="-n $GH_RELEASE_NOTES"
fi
if [ -z "${GH_RELEASE_TITLE+x}" ]
then
gh_title="-t $version"
else
gh_notes="-t $GH_RELEASE_TITLE"
fi
# Build tar.gz for GitHub Release
tmp_release_dir="tmp_release"
mkdir "$tmp_release_dir"
project_path="$(pwd)"
project="${project_path##*/}"
tgz_name="$project-$version.tar.gz"
tar --exclude="./$tmp_release_dir" -zcf "./$tmp_release_dir/$tgz_name" .
# GitHub Release
git tag $version $(git rev-parse HEAD)
git push upstream $version
gh release create "$version" "./$tmp_release_dir/$tgz_name" "$gh_title" "$gh_notes"
rm -rf $tmp_release_dir
# PyPi Release
python -m build
twine upload dist/*$version*.tar.gz || echo "Warning: No new distribution build. Check for any untracked changes."
exit 0