forked from upgrades-migrations/preupgrade-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdist
executable file
·45 lines (32 loc) · 1.16 KB
/
sdist
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
#!/bin/bash
# Creates development source tarball.
# * generates development version string from git
# * cretes git archive with particular name-version prefix
# * updates setup.py to contain the version string
# * writes out the name of the tarball
# NOTE:
# Production (released) tarballs should be taken from github:
# https://github.com/upgrades-migrations/%{name}/%{version}/%{name}-%{version}.tar.gz
# It is our responsibility to update setup.py before we create version tag.
set -e
# ensure that current working directory is OK
BASE_DIR="$(dirname "$(realpath "$0")")"
pushd "$BASE_DIR" > /dev/null
# get version from git
VERSION="$(git describe --tags | sed -r -e 's/-([0-9]+)-[0-9a-z]{8}/.post\1/')"
PREFIX="preupgrade-assistant-$VERSION"
# create base archive from git
mkdir -p dist
rm -rf dist/${PREFIX}
git archive --format=tar --prefix=${PREFIX}/ HEAD | { cd dist; tar -x; }
# enter dist directory
cd dist
# update setup.py
sed -i -r "s/^(package_version\s*=\s*).*/\\1'$VERSION'/" ${PREFIX}/setup.py
# compress archive
tar -czf ${PREFIX}.tar.gz ${PREFIX}
# clean
rm -rf ${PREFIX}
# provide useful output
echo "$BASE_DIR/dist/${PREFIX}.tar.gz"
popd > /dev/null