Last active
September 24, 2024 14:34
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# --------------------------------------------------------------- | |
# Copyright © 2022, 2024 Jason J.A. Stephenson <[email protected]> | |
# | |
# 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 '.' ' ' | sed 's/0\([0-9]\)/\1/')) | |
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" | |
UPGRADE_LOG="INSERT INTO config.upgrade_log (version, applied_to) VALUES ('$VERSION', :eg_version);" | |
if [[ -z $(grep -F "${UPGRADE_LOG}" Open-ILS/src/sql/Pg/002.schema.config.sql) ]]; then | |
sed -e "/^INSERT INTO config\\.upgrade_log/a\\ | |
${UPGRADE_LOG}" -i Open-ILS/src/sql/Pg/002.schema.config.sql | |
fi | |
# 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