Skip to content

Instantly share code, notes, and snippets.

@Dyrcona
Created June 17, 2022 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dyrcona/933dd1a2e9035fdc48162dbcfcb51a2d to your computer and use it in GitHub Desktop.
Save Dyrcona/933dd1a2e9035fdc48162dbcfcb51a2d to your computer and use it in GitHub Desktop.
A bash script to stamp versions in Evergreen files for a new release.
#!/bin/bash
# ---------------------------------------------------------------
# Copyright © 2022 Jason J.A. Stephenson <jason@sigio.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ---------------------------------------------------------------
VERSION=$(echo ${1} | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$')
if [[ ! -d ".git" || ! -d "Open-ILS" ]]; then
echo "We don't appear to be in an Evergreen-ILS git repository."
exit 1
fi
if [[ -z "$VERSION" ]]; then
echo "Specify the version in X.Y.Z format as a CLI argument."
exit 1
fi
DASH_VERSION=$(echo $VERSION | tr '.' '-')
PERL_VERSION=$(printf "%d.%02d%02d" $(echo $VERSION | tr '.' ' '))
echo "Stamping OpenILS.pm with $PERL_VERSION"
sed -e "s/2\\.4/$PERL_VERSION/" -i Open-ILS/src/perlmods/lib/OpenILS.pm
echo "Stamping Application.pm with $DASH_VERSION"
sed -e s/HEAD/$DASH_VERSION/ -i Open-ILS/src/perlmods/lib/OpenILS/Application.pm
echo "Stamping configure.ac with $VERSION"
sed -e "/^AC_INIT/s/trunk/$VERSION/" -i configure.ac
echo "Stamping 002.schema.config.sql with $VERSION"
sed -e "/^INSERT INTO config\\.upgrade_log/a\\
INSERT INTO config.upgrade_log (version, applied_to) VALUES ('$VERSION', :eg_version);" -i Open-ILS/src/sql/Pg/002.schema.config.sql
# If second CLI argument is '--' the remaining arguments are for make-db-upgrade
if [[ "$2" == "--" ]]; then
shift 2
make-db-upgrade -v $VERSION $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment