blob: 124e58331579fdd9e1b383c01ce1ce9d8c92213f [file] [log] [blame]
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +01001#!/bin/bash
2
3
4GREEN='\033[0;32m'
5RED='\033[0;31m'
6WHITE='\033[0;37m'
7RESET='\033[0m'
8
9function validateVersion()
10{
11 echo ""
12 passedVersion=$1
13 echo -e "${WHITE}-- Validating tag '$passedVersion'...${RESET}"
14
15 # Todo: validate the version here using a regex; if fail, just exit
16 # ... expect 8.75.0, with no v in front of it
17
18 if [[ $passedVersion == '' ]]; then
19 echo -e "\n-- Invalid tag. Tags should be structured without v; e.g. 8.57.0"
20 exit
21 fi
22
23 echo -e "${WHITE}-- Tag valid.${RESET}"
24 echo ""
25}
26
27# Exit script if any command fails (e.g. phpunit)
28set -e
29
30
31# Require confirmation it's set up corrctly
32echo
33echo -e "${WHITE}-- This script is meant to be run after running upgrade.sh, BEFORE committing to Git.${RESET}"
34
35while true; do
36 echo -e "${GREEN}-- Is that the current state of your local project?${RESET}"
37 read -p "-- (y/n) " yn
38 case $yn in
39 [Yy]* ) break;;
40 [Nn]* ) exit;;
41 * ) echo "Please answer y or n.";;
42 esac
43done
44
45# Get the version and exit if not valid
46validateVersion $1
47
48# Create official v prefaced version
49version="v$1"
50
51# Run tests (and bail if they fail)
52phpunit
53echo -e "\n${WHITE}-- Tests succeeded.${RESET}"
54
55# Branch
56echo -e "\n${WHITE}-- Creating a Git branch '$version-changes'...${RESET}\n"
57git checkout -b $version-changes
58
59# Add and commit, with "v8.57.0 changes" as the commit name
60git add -A
61git commit -m "$version changes"
62
63echo
64echo -e "${WHITE}-- Git committed.${RESET}"
65
66# Push
67git push -u origin $version-changes