|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +function usage { |
| 4 | + echo -e "Usage:\n\n\tbash $0 X.Y.Z\n |
| 5 | +cffconvert will be required. If the command exists, it will be used. |
| 6 | +Otherwise, if you have docker installed, set USE_DOCKER=\"yes\" to use the docker image. |
| 7 | +Alternatively, you can set CFFCONVERT to specify the binary path." |
| 8 | +} |
| 9 | + |
| 10 | +if [ ! $# -eq 1 ]; then |
| 11 | + usage |
| 12 | + exit 1 |
| 13 | +fi |
| 14 | + |
| 15 | +VERSION=$1 |
| 16 | + |
| 17 | +if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 18 | + echo "ERROR: Wrong input format" |
| 19 | + usage |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +if [ -n "$CFFCONVERT" ]; then |
| 24 | + if ! command -v "$CFFCONVERT" &> /dev/null; then |
| 25 | + echo "ERROR: CFFCONVERT was set to '$CFFCONVERT' but command does not exist" |
| 26 | + usage |
| 27 | + exit 1 |
| 28 | + fi |
| 29 | +fi |
| 30 | + |
| 31 | +if [ -z "$CFFCONVERT" ]; then |
| 32 | + if command -v cffconvert &> /dev/null; then |
| 33 | + echo "cffconvert found" |
| 34 | + CFFCONVERT=cffconvert |
| 35 | + elif command -v docker &> /dev/null && [ "$USE_DOCKER" == "yes" ]; then |
| 36 | + CFFCONVERT="docker run --rm -v $PWD:/app citationcff/cffconvert" |
| 37 | + else |
| 38 | + echo "ERROR: cffconvert was not found, install it first, possibly using" |
| 39 | + echo -e "\n\tpython -m venv env\n\t. env/bin/activate\n\tpip install --upgrade pip setuptools cffconvert\n" |
| 40 | + usage |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +fi |
| 44 | + |
| 45 | +sed -i "s/^date-released: .*$/date-released: $(date --iso)/" CITATION.cff |
| 46 | +sed -i "s/^version: .*$/version: $VERSION/" CITATION.cff |
| 47 | +echo "CITATION.cff updated" |
| 48 | +$CFFCONVERT -f zenodo -o .zenodo.json |
| 49 | +echo ".zenodo.json updated" |
| 50 | +sed -i "s/^ \"version.*$/ \"version\": \"$VERSION\",/" package.json |
| 51 | +sed -i "s/^ \"version.*$/ \"version\": \"$VERSION\",/" package-lock.json |
| 52 | +echo "package.json and package-lock.json updated" |
| 53 | +sed -i "s/Version .*$/Version $VERSION/" src/components/LayoutLanding.vue |
| 54 | +sed -i "s/Version .*$/Version $VERSION/" src/components/Footer.vue |
| 55 | +echo "LayoutLanding.vue and Footer.vue updated" |
0 commit comments