commit b46517d07b921397f37d269bb82fb62912df177d from: Thomas Adam date: Fri Apr 18 11:37:02 2025 UTC portable: add a release script This script automates the creation of the dist tarball, including verifying the tarball by unpacking and compiling it. Note that, the CHANGELOG should have been filled out already prior to running this script, so that it's included in the tarball; but that commit will need amending with the updated changes this script creates. Also assumes ed(1) is installed which is slightly more portable (and available) across different *nix systems, unlike sed(1)'s -i flag. commit - 91c1648f8258a8d72a8111818f85d79e2e48fbfe commit + b46517d07b921397f37d269bb82fb62912df177d blob - 064a9885695810667d441cb162bbbbf630a9716c blob + f4af80934c2c986449bee82f395f5f1f62624807 --- maintscripts/README.md +++ maintscripts/README.md @@ -5,4 +5,5 @@ This directory contains scripts to aid in the maintena * `sync-upstream.sh`: this script helps automate the syncing of upstream `GoT` with `-portable`. - +* `mk-release.sh`: this script helps automate the creation of a release + tarball for `-portable`. blob - /dev/null blob + c57183f91a6f0f47d85c524d77c17c6f1286f884 (mode 755) --- /dev/null +++ maintscripts/mk-portable-release.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Makes the release tarball for got-portable. +# +# Assumes that: +# +# * the CHANGELOG has been filed out. + +PORTABLE_BRANCH=portable + +die() +{ + echo "$@" >&2 + exit 1 +} + +# Wrap the nproc command found on Linux, to return the number of CPU cores. +# On non-Linux systems, the same value can be found via sysctl. For +# everything else, just return "1". +nproc() +{ + NPROCCMD="nproc" + + command "$NPROCCMD" >/dev/null 2>&1 || { + NPROCCMD="sysctl -n hw.ncpu" + } + + result="$(eval command $NPROCCMD)" + [ -z "$result" -o "$result" -le 0 ] && result="1" + + echo "$result" +} + +[ -z "$(git status --porcelain)" ] || die "Working tree is not clean" + +git checkout -q "$PORTABLE_BRANCH" +git pull -q + +source util/got-portable-ver.sh >/dev/null || die "Couldn't source file" + +echo "Checking status of GOT_RELEASE..." +( + [ "$GOT_RELEASE" = "no" ] || \ + die "GOT_RELEASE is not set to no: $GOT_RELEASE" + + echo "Setting status of GOT_RELEASE to yes..." + ed -s util/got-portable-ver.sh <<<$',s/GOT_RELEASE=no/GOT_RELEASE=yes/\nw' || \ + die "Couldn't update value of GOT_RELEASE" + echo "Next version of -portable will be: $GOT_PORTABLE_VER" +) + +echo "Making release tarball..." +( + echo "Running autogen.sh..." + ./autogen.sh >/dev/null 2>&1 || die "./autogen.sh failed" + + echo "Running ./configure..." + ./configure --enable-cvg >/dev/null 2>&1 || die "./configure failed" + + echo "Running make..." + make -j $(nproc) >/dev/null 2>&1 || die "make failed" + + echo "Running make dist..." + make dist >/dev/null 2>&1 || die "make dist failed" + + echo "Verifying tarball..." + + TEMPGV="/tmp/gv-$GOT_PORTABLE_VER" + TEMPGV_TARBALL="got-portable-${GOT_PORTABLE_VER}.tar.gz" + [ -d "$TEMPGV" ] || mkdir "$TEMPGV" && \ + cp ./"$TEMPGV_TARBALL" "$TEMPGV" + ( + cd "$TEMPGV" && \ + tar xzf ./"$TEMPGV_TARBALL" && \ + cd ./got-portable-$GOT_PORTABLE_VER || die "Couldn't cd" + + ./configure --enable-cvg >/dev/null 2>&1 || die "./configure failed" + make -j $(nproc) >/dev/null 2>&1 || die "make failed" + ) + echo "Done." +)