diff --git a/Makefile b/Makefile index 199a2b8c2..f31437325 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/create-release-tarball b/create-release-tarball new file mode 100755 index 000000000..f47db1554 --- /dev/null +++ b/create-release-tarball @@ -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" diff --git a/go/Makefile b/go/Makefile index e1705b416..9f94513bc 100644 --- a/go/Makefile +++ b/go/Makefile @@ -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 diff --git a/go/src/climain/mlrcli_parse.go b/go/src/climain/mlrcli_parse.go index db43870c7..c5ed8418f 100644 --- a/go/src/climain/mlrcli_parse.go +++ b/go/src/climain/mlrcli_parse.go @@ -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]) { diff --git a/go/src/version/version.go b/go/src/version/version.go index 966b51064..89199e98b 100644 --- a/go/src/version/version.go +++ b/go/src/version/version.go @@ -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" diff --git a/go/todo.txt b/go/todo.txt index 20f7690da..cc909c95c 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -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 diff --git a/man/Makefile b/man/Makefile index 6dcb432a4..c2d9d99f3 100644 --- a/man/Makefile +++ b/man/Makefile @@ -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