-
Notifications
You must be signed in to change notification settings - Fork 216
/
create-release-tarball
executable file
·100 lines (92 loc) · 2.92 KB
/
create-release-tarball
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# ================================================================
# This script creates a file like "miller-6.0.0.tar.gz".
#
# * The developer should run this script to create that .tar.gz file
#
# * Then attach it as an asset to a release created at
# https://github.com/johnkerl/miller/releases.
#
# * Then the 'Source' link in ./miller.spec should already be correct.
#
# * Normally this script wouldn't be run directly; rather, from the Makefile's
# 'make release_tarball' which will first run 'make build' and 'make check'.
#
# Please also see
# https://miller.readthedocs.io/en/latest/build/#creating-a-new-release-for-developers
#
# Note that GitHub makes a 'Source code (tar.gz)' which could be used in place
# of the tarball which this script creates. However, this script makes some
# effort to remove directories which are not necessary for the install, which
# reduces tarball size.
#
# Testing:
# * Run this script
# * Move the miller-i.j.k.tar.gz file off somewhere else, like /tmp
# * cd to the directory where you put the tarbll
# * tar zxf miller-i.j.k.tar.gz
# * cd miller-i.j.k
# * ./configure --prefix /usr/local
# * make build check
# * make build check install # if you prefer
# ================================================================
set -euo pipefail
# Make sure ./mlr exists so we can ask it for its version string.
if [ ! -x "./mlr" ]; then
echo "$0: ./mlr is not executable. Please check 'make build' first." 1>&2
exit 1
fi
# Find the Miller version string, such as "6.0.0".
VERSION=$(./mlr --bare-version)
if [ "$VERSION" == "" ] ; then
echo "$0: could not obtain output from './mlr --bare-version'." 1>&2
exit 1
fi
# Try to find a version of tar which supports the --transform flag.
# Linux tar does; MacOS default tar does not, but 'brew install gnu-tar' will
# install gtar which does.
tar=/usr/bin/tar
if [ -x /usr/local/bin/gtar ]; then
tar=/usr/local/bin/gtar
elif [ -x /opt/homebrew/bin/gtar ]; then
tar=/opt/homebrew/bin/gtar
fi
if [ ! -x "$tar" ]; then
echo "$0: "$tar" is not executable. Please edit this script with the path." 1>&2
echo "to a version of tar which supports the --transform flag." 1>&2
exit 1
fi
# Make sure the current directory is writeable, so we can (perhaps) create a
# more informative error message than tar would.
if [ ! -w . ]; then
echo "$0: the current directory is not writeable; cannot create tarball." 1>&2
exit 1
fi
TGZ_NAME=miller-${VERSION}.tar.gz
# Create the release tarball.
echo "Writing $TGZ_NAME ..."
$tar \
--transform 's,^./,miller-'$VERSION'/,' \
--exclude data \
--exclude docs \
--exclude experiments \
--exclude todo.txt \
--exclude perf \
--exclude python \
--exclude vim \
-czf $TGZ_NAME \
./LICENSE.txt \
./README.md \
./README-RPM.md \
./configure \
./Makefile \
./create-release-tarball \
./go.mod \
./go.sum \
./cmd \
./pkg \
./regression_test.go \
./man \
./test \
./tools
echo "Wrote $TGZ_NAME"