'make release_tarball' target, Go analog of C 'make distcheck' (#742)

This commit is contained in:
John Kerl 2021-11-10 09:09:49 -05:00 committed by GitHub
parent fe9a70e225
commit 92bc0f3b00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 12 deletions

View file

@ -1,6 +1,3 @@
# TODO: 'cp go/mlr .' or 'copy go\mlr.exe .' with reliable platform detection
# and no confusing error messages.
build:
make -C go build
@echo "Miller executable is: ./mlr, or go\mlr.exe on Windows"
@ -35,5 +32,10 @@ precommit:
# Keystroke-saver
itso: build check install
# Please see comments in ./create-release-tarball as well as
# https://miller.readthedocs.io/en/latest/build/#creating-a-new-release-for-developers
release_tarball: build check
./create-release-tarball
# Go does its own dependency management, outside of make.
.PHONY: build precommit
.PHONY: build check install precommit

92
create-release-tarball Executable file
View file

@ -0,0 +1,92 @@
#!/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
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 "Wrtiting $TGZ_NAME ..."
$tar \
--transform 's,^./,miller-'$VERSION'/,' \
--exclude data \
--exclude docs \
--exclude experiments \
--exclude go/todo.txt \
--exclude perf \
--exclude python \
--exclude vim \
-czf $TGZ_NAME \
./LICENSE.txt \
./README.md \
./README-RPM.md \
./configure \
./Makefile \
./create-release-tarball \
./go \
./man
echo "Wrote $TGZ_NAME"

View file

@ -1,5 +1,5 @@
# Please edit Makefile.in rather than Makefile, which is overwritten by ../configure.
PREFIX=/usr
PREFIX=/usr/local
INSTALLDIR=$(PREFIX)/bin
# Attempt cp; will fail on Windows but ignore and continue

View file

@ -41,7 +41,10 @@ func ParseCommandLine(args []string) (
cli.CheckArgCount(args, argi, argc, 1)
argi += 2
} else if args[argi] == "--version" {
fmt.Printf("Miller %s\n", version.STRING)
fmt.Printf("mlr %s\n", version.STRING)
os.Exit(0)
} else if args[argi] == "--bare-version" {
fmt.Printf("%s\n", version.STRING)
os.Exit(0)
} else if help.ParseTerminalUsage(args[argi]) {

View file

@ -1,4 +1,4 @@
package version
// STRING is the current Miller major/minor/patch version as a single string.
var STRING string = "v6.0.0-dev"
var STRING string = "6.0.0-dev"

View file

@ -2,18 +2,21 @@
PUNCHDOWN LIST
* plan:
o release prep
k ./configure experiment
k miller.spec experiment
k 'make release_tarball'
o update build.mi#dev steps
o conda etc
- get a link for rmd
- ./configure experiment
- miller.spec experiment
- get a conda link for rmd
- distcheck: gtar --transform 's,^./,miller-6.0.0/,' --exclude ./.git -czf /tmp/miller-6.0.0.tgz .
> also exclude: data, docs, experiments, per, python, vim
> on macos, 'brew install gnu-tar' will install 'gtar'
o blockers:
- fractional-strptime
- cmp-matrices
- all-contribs
- license triple-checks
- ./configure --prefix
? alpha?
- csv irs lf/crlf ignores -- ? already is so?
- `mlr put` -> coverart

View file

@ -4,7 +4,7 @@
# This should be run after make in the ../c directory but before make in the ../docs directory,
# since ../go/mlr is used to autogenerate ./manpage.txt which is used in ../docs.
# See also https://miller.readthedocs.io/en/latest/build.html#creating-a-new-release-for-developers
PREFIX=/usr
PREFIX=/usr/local
INSTALLDIR=$(PREFIX)/share/man/man1
# This is normally done only on a development host. Through CI and