@mcf/lib-ui 0.0.1 → 2.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -9
- package/package.json +4 -6
- package/scripts/versioning/.travis.yml +8 -0
- package/scripts/versioning/.version +1 -0
- package/scripts/versioning/get-branch +28 -0
- package/scripts/versioning/get-latest +53 -0
- package/scripts/versioning/get-next +90 -0
- package/scripts/versioning/init +40 -0
- package/scripts/versioning/iterate +76 -0
- package/scripts/versioning/readme.md +280 -0
- package/scripts/versioning/test +127 -0
- package/scripts/versioning/tests/Dockerfile +4 -0
- package/scripts/versioning/tests/docker-compose.yml +8 -0
- package/scripts/versioning/tests/scripts/get-branch.test +50 -0
- package/scripts/versioning/tests/scripts/get-latest.test +53 -0
- package/scripts/versioning/tests/scripts/get-next.test +50 -0
- package/scripts/versioning/tests/scripts/init.test +25 -0
- package/scripts/versioning/tests/scripts/iterate.test +65 -0
- package/scripts/versioning/utils/branch_setup +7 -0
- package/scripts/versioning/utils/branch_teardown +8 -0
- package/scripts/versioning/utils/pipeline_setup +79 -0
package/README.md
CHANGED
|
@@ -8,13 +8,13 @@ Install this package through NPM:
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
# for NPM
|
|
11
|
-
npm i
|
|
11
|
+
npm i @mcf/lib-ui tachyons
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Call it from your code with:
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
import {...} from '@
|
|
17
|
+
import {...} from '@mcf/lib-ui';
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Where `...` is the component name.
|
|
@@ -28,7 +28,7 @@ import 'tachyons/src/tachyons.css';
|
|
|
28
28
|
You eventually need to import the default style provided *once* somewhere in your project
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
|
-
import '@
|
|
31
|
+
import '@mcf/lib-ui/dist/main.css';
|
|
32
32
|
```
|
|
33
33
|
This step is optional. You can provide your own style using CSS variables. Using CSS variables make it easy to configure yourself the style of your components at the application level or at a component level.
|
|
34
34
|
|
|
@@ -69,11 +69,9 @@ List of CSS variables overridable (default only if you use the provided style):
|
|
|
69
69
|
- [RadioButtonGroup](./src/Component/RadioButtonGroup/README.md)
|
|
70
70
|
|
|
71
71
|
## Quick Links
|
|
72
|
-
NPM: https://www.npmjs.com/package/@
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Application Images: https://hub.docker.com/r/govtechsg/mcf-mcfui/
|
|
76
|
-
Demo: https://mcfui.gds-gov.tech
|
|
72
|
+
NPM: https://www.npmjs.com/package/@mcf/lib-ui
|
|
73
|
+
Dependency Images: https://gitlab.com/mycf.sg/lib-ui/container_registry/2214294
|
|
74
|
+
Application Images: https://gitlab.com/mycf.sg/lib-ui/container_registry/2214299
|
|
77
75
|
|
|
78
76
|
## Contributing
|
|
79
77
|
|
|
@@ -128,7 +126,6 @@ The Pipeline runs only in the `master` branch.
|
|
|
128
126
|
|
|
129
127
|
The following release tags are available for use in your commit message to denote a type of release:
|
|
130
128
|
|
|
131
|
-
- `[rebuild]`: rebuilds all containers regardless of whether we already have them
|
|
132
129
|
- `[release]`: performs a release by bumping the version in `./package.json` to the same as that of the latest Git tag
|
|
133
130
|
- `[major]`: performs a major version bump (X.y.z -> Y.0.0, Y = X + 1)
|
|
134
131
|
- `[minor]`: performs a major version bump (x.Y.z -> x.Z.0, Z = Y + 1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcf/lib-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.124",
|
|
4
4
|
"description": "User Interface (UI) components for use in the MCF project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/@types/Component/index.d.ts",
|
|
@@ -25,10 +25,7 @@
|
|
|
25
25
|
"tsc-check": "tsc --noEmit --skipLibCheck",
|
|
26
26
|
"tslint": "tslint -c tslint.json -p . -t stylish"
|
|
27
27
|
},
|
|
28
|
-
"repository":
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "ssh://git@gitlab.gds-gov.tech:30022/wsg/mcfui.git"
|
|
31
|
-
},
|
|
28
|
+
"repository": "gitlab:mycf.sg/lib-ui",
|
|
32
29
|
"author": "MCF",
|
|
33
30
|
"license": "ISC",
|
|
34
31
|
"dependencies": {
|
|
@@ -46,7 +43,8 @@
|
|
|
46
43
|
"@babel/preset-react": "7.14.5",
|
|
47
44
|
"@babel/preset-typescript": "7.15.0",
|
|
48
45
|
"@storybook/react": "5.1.3",
|
|
49
|
-
"@types/
|
|
46
|
+
"@types/cheerio": "0.22.31",
|
|
47
|
+
"@types/enzyme": "3.10.11",
|
|
50
48
|
"@types/enzyme-adapter-react-16": "1.0.6",
|
|
51
49
|
"@types/jest": "23.3.1",
|
|
52
50
|
"@types/lodash": "4.14.177",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
help () { printf "
|
|
3
|
+
**********
|
|
4
|
+
get-branch
|
|
5
|
+
**********
|
|
6
|
+
retrieves the currently checked-out branch
|
|
7
|
+
|
|
8
|
+
options:
|
|
9
|
+
\t-q --quiet : suppresses debug prints
|
|
10
|
+
\t-h --help : prints this text
|
|
11
|
+
|
|
12
|
+
usage:
|
|
13
|
+
\t./get-branch [...options]
|
|
14
|
+
|
|
15
|
+
examples:
|
|
16
|
+
\t./get-branch -q
|
|
17
|
+
";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
|
|
21
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
|
|
22
|
+
|
|
23
|
+
CURRENT_BRANCH=$(git branch | grep '*' | cut -c 3- | tr -d '\n');
|
|
24
|
+
|
|
25
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 1>&6 6>&-; fi;
|
|
26
|
+
|
|
27
|
+
printf "${CURRENT_BRANCH}\n";
|
|
28
|
+
exit 0;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
help () { printf "
|
|
3
|
+
*************
|
|
4
|
+
get-latest.sh
|
|
5
|
+
*************
|
|
6
|
+
retrieves the latest git tag that resembles a semver versioning (x.y.z) where x is
|
|
7
|
+
the major version, y is the minor version and z is the patch version. exits with code
|
|
8
|
+
1 if no version is found, exists with code 0 if version is found.
|
|
9
|
+
|
|
10
|
+
options:
|
|
11
|
+
\t-m --merged : get only tags that apply to the current branch
|
|
12
|
+
\t-q --quiet : suppresses debug prints
|
|
13
|
+
\t-h --help : prints this text
|
|
14
|
+
|
|
15
|
+
usage:
|
|
16
|
+
\t./get-latest.sh <dash_suffix> [...options]
|
|
17
|
+
\t\t<dash_suffix> : String
|
|
18
|
+
|
|
19
|
+
examples:
|
|
20
|
+
\t./get-latest.sh dev
|
|
21
|
+
\t\tgets the latest version suffixed with '-dev'
|
|
22
|
+
\t\tif there exists git tags 1.0.0-dev and 1.0.1-dev, this will return 1.0.1-dev
|
|
23
|
+
";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
|
|
27
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
|
|
28
|
+
|
|
29
|
+
VERSION_SELECTOR="^[0-9]+\.[0-9]+\.[0-9]+"
|
|
30
|
+
printf "\nVERSION_SELECTOR: ${VERSION_SELECTOR}\n";
|
|
31
|
+
[[ "$1" != "" ]] && [[ "$1" != "-q" ]] && VERSION_SELECTOR="${VERSION_SELECTOR}\-${1}";
|
|
32
|
+
if [[ $* == *-m* ]] || [[ $* == *--merged* ]]; then
|
|
33
|
+
VERSION=$(git tag -l --merged | egrep "${VERSION_SELECTOR}$" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1);
|
|
34
|
+
else
|
|
35
|
+
VERSION=$(git tag -l | egrep "${VERSION_SELECTOR}$" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1);
|
|
36
|
+
fi;
|
|
37
|
+
if [[ $VERSION = "" ]]; then
|
|
38
|
+
printf "
|
|
39
|
+
ERROR: could not find a git tag that resembles a semver version (x.y.z).
|
|
40
|
+
\t> To add a 1.0.3 tag, run 'git tag 1.0.3'
|
|
41
|
+
\t> Exiting with status code 1.
|
|
42
|
+
|
|
43
|
+
";
|
|
44
|
+
exit 1;
|
|
45
|
+
else
|
|
46
|
+
printf "VERSION: ";
|
|
47
|
+
fi;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 1>&6 6>&-; fi;
|
|
51
|
+
|
|
52
|
+
printf "$VERSION\n";
|
|
53
|
+
exit 0;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
help () { printf "
|
|
3
|
+
***********
|
|
4
|
+
get-next.sh
|
|
5
|
+
***********
|
|
6
|
+
gets the next semver versioning of the current folder based on the version
|
|
7
|
+
in the git tag list. version should be in format x.y.z where x is the major
|
|
8
|
+
version, y is the minor version and z is the patch version.
|
|
9
|
+
|
|
10
|
+
options:
|
|
11
|
+
\t-m --merged : retrieve only from tags that have been merged
|
|
12
|
+
\t-q --quiet : suppresses debug prints
|
|
13
|
+
\t-h --help : prints this text
|
|
14
|
+
|
|
15
|
+
usage:
|
|
16
|
+
\t./get-next.sh <version_type> [...options]
|
|
17
|
+
\t<version_type>:
|
|
18
|
+
\t\tmajor: {major|maj|m1}
|
|
19
|
+
\t\tminor: {minor|min|m2}
|
|
20
|
+
\t\tpatch: {patch|ptc|p} (DEFAULT)
|
|
21
|
+
|
|
22
|
+
examples:
|
|
23
|
+
\t./get-next.sh maj : bumps the major version (1.0.0 > 2.0.0)
|
|
24
|
+
\t./get-next.sh min : bumps the minor version (1.0.0 > 1.1.0)
|
|
25
|
+
\t./get-next.sh patch : bumps the patch version (1.0.0 > 1.0.1)
|
|
26
|
+
\t./get-next.sh -q : bumps the patch version (1.0.0 > 1.0.1) w/o output
|
|
27
|
+
|
|
28
|
+
";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get_current_version () {
|
|
32
|
+
if [[ $* == *-m* ]] || [[ $* == *--merged* ]]; then MERGE=' -m'; else MERGE=''; fi;
|
|
33
|
+
GET_LATEST_COMMAND="$(dirname $0)/get-latest -q${MERGE}";
|
|
34
|
+
CURRENT_VERSION=$($GET_LATEST_COMMAND);
|
|
35
|
+
if [[ $? != 0 ]]; then
|
|
36
|
+
printf "
|
|
37
|
+
ERROR: could not find a git tag that resembles a semver version (x.y.z).
|
|
38
|
+
\t> To add a 1.0.3 tag, run 'git tag 1.0.3'
|
|
39
|
+
\t> Exiting with status code 1.
|
|
40
|
+
|
|
41
|
+
";
|
|
42
|
+
exit 1;
|
|
43
|
+
fi;
|
|
44
|
+
LATEST_MAJOR_VERSION=$(printf "$CURRENT_VERSION" | cut -d. -f1);
|
|
45
|
+
LATEST_MINOR_VERSION=$(printf "$CURRENT_VERSION" | cut -d. -f2);
|
|
46
|
+
LATEST_PATCH_VERSION=$(printf "$CURRENT_VERSION" | cut -d. -f3);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get_next_version () {
|
|
50
|
+
VERSION_TYPE_TO_UPDATE=$1;
|
|
51
|
+
NEXT_MAJOR_VERSION=$LATEST_MAJOR_VERSION;
|
|
52
|
+
NEXT_MINOR_VERSION=$LATEST_MINOR_VERSION;
|
|
53
|
+
NEXT_PATCH_VERSION=$LATEST_PATCH_VERSION;
|
|
54
|
+
case "$VERSION_TYPE_TO_UPDATE" in
|
|
55
|
+
"major"|"maj"|"m1")
|
|
56
|
+
((NEXT_MAJOR_VERSION++));
|
|
57
|
+
NEXT_VERSION="${NEXT_MAJOR_VERSION}.0.0";
|
|
58
|
+
;;
|
|
59
|
+
"minor"|"min"|"m2")
|
|
60
|
+
((NEXT_MINOR_VERSION++));
|
|
61
|
+
NEXT_VERSION="${NEXT_MAJOR_VERSION}.${NEXT_MINOR_VERSION}.0";
|
|
62
|
+
;;
|
|
63
|
+
"patch"|"ptc"|"p"|*)
|
|
64
|
+
((NEXT_PATCH_VERSION++));
|
|
65
|
+
NEXT_VERSION="${NEXT_MAJOR_VERSION}.${NEXT_MINOR_VERSION}.${NEXT_PATCH_VERSION}";
|
|
66
|
+
;;
|
|
67
|
+
esac
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
|
|
71
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
|
|
72
|
+
|
|
73
|
+
get_current_version;
|
|
74
|
+
printf "CURRENT_VERSION: ${CURRENT_VERSION}\n";
|
|
75
|
+
printf "MAJOR: ${LATEST_MAJOR_VERSION}\n";
|
|
76
|
+
printf "MINOR: ${LATEST_MINOR_VERSION}\n";
|
|
77
|
+
printf "PATCH: ${LATEST_PATCH_VERSION}\n";
|
|
78
|
+
|
|
79
|
+
get_next_version $1;
|
|
80
|
+
printf "NEXT_VERSION: ${NEXT_VERSION}\n";
|
|
81
|
+
printf "MAJOR: ${NEXT_MAJOR_VERSION}\n";
|
|
82
|
+
printf "MINOR: ${NEXT_MINOR_VERSION}\n";
|
|
83
|
+
printf "PATCH: ${NEXT_PATCH_VERSION}\n";
|
|
84
|
+
|
|
85
|
+
printf "VERSION UPGRADE: ${CURRENT_VERSION} > ";
|
|
86
|
+
|
|
87
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 1>&6 6>&-; fi;
|
|
88
|
+
|
|
89
|
+
printf "${NEXT_VERSION}\n";
|
|
90
|
+
exit 0;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
help() { printf "
|
|
3
|
+
*******
|
|
4
|
+
init.sh
|
|
5
|
+
*******
|
|
6
|
+
checks for a semver versioning tag in current git repo. if absent, initializes
|
|
7
|
+
it at 0.0.0. if present, doesn't do anything.
|
|
8
|
+
|
|
9
|
+
options:
|
|
10
|
+
\t-q --quiet : suppresses debug prints
|
|
11
|
+
\t-h --help : prints this text
|
|
12
|
+
|
|
13
|
+
usage/example:
|
|
14
|
+
\t./init.sh -q : runs this script in quiet mode
|
|
15
|
+
|
|
16
|
+
";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
|
|
20
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
|
|
21
|
+
|
|
22
|
+
INITIAL_VERSION="0.0.0";
|
|
23
|
+
GET_LATEST_COMMAND="$(dirname $0)/get-latest -q";
|
|
24
|
+
CURRENT_VERSION=$($GET_LATEST_COMMAND);
|
|
25
|
+
if [[ $? = 1 ]]; then
|
|
26
|
+
git tag ${INITIAL_VERSION};
|
|
27
|
+
printf "
|
|
28
|
+
!: semver versioning not found from list of git tags...
|
|
29
|
+
\t> initialized repository versioning with 0.0.0.
|
|
30
|
+
|
|
31
|
+
";
|
|
32
|
+
else
|
|
33
|
+
printf "
|
|
34
|
+
latest semver version ${CURRENT_VERSION} found in git tags...
|
|
35
|
+
skipping initialization.
|
|
36
|
+
|
|
37
|
+
";
|
|
38
|
+
fi;
|
|
39
|
+
|
|
40
|
+
exit 0;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
help() { printf "
|
|
3
|
+
*******
|
|
4
|
+
iterate
|
|
5
|
+
*******
|
|
6
|
+
this script gets the latest merged version available in the current branch, ups
|
|
7
|
+
the version number depending on the argument passed in. exits with 0 on successful
|
|
8
|
+
updating, exist with 1 if tag could not be applied for any reason.
|
|
9
|
+
|
|
10
|
+
versioning has to be in semver for this to work. eg. x.y.z where x is the major
|
|
11
|
+
version, y is the minor version and z is the patch version.
|
|
12
|
+
|
|
13
|
+
options:
|
|
14
|
+
\t-m --merged : retrieve only from tags that have been merged
|
|
15
|
+
\t-i --init : initializes tagging if no version tags could be found
|
|
16
|
+
\t-q --quiet : suppresses debug prints
|
|
17
|
+
\t-h --help : prints this text
|
|
18
|
+
|
|
19
|
+
usage:
|
|
20
|
+
\t./iterate [<version_target>]
|
|
21
|
+
\t\t<version_target>:
|
|
22
|
+
\t\t\t{ major|maj|1 } : ups the major version
|
|
23
|
+
\t\t\t{ minor|min|2 } : ups the minor version
|
|
24
|
+
\t\t\t{ patch|p|3 } : ups the patch version
|
|
25
|
+
|
|
26
|
+
";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
|
|
30
|
+
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
|
|
31
|
+
if [[ $* == *-i* ]] || [[ $* == *--init* ]]; then INIT=1; else INIT=0; fi;
|
|
32
|
+
if [[ $* == *-m* ]] || [[ $* == *--merged* ]]; then MERGE=' -m'; else MERGE=''; fi;
|
|
33
|
+
|
|
34
|
+
GET_LATEST_COMMAND="$(dirname $0)/get-latest -q${MERGE}";
|
|
35
|
+
CURRENT_VERSION=$($GET_LATEST_COMMAND);
|
|
36
|
+
if [[ $? != 0 ]] && [[ $CURRENT_VERSION = "" ]]; then
|
|
37
|
+
if [[ $INIT = 0 ]]; then
|
|
38
|
+
printf "
|
|
39
|
+
ERROR: Versioning could not be found.
|
|
40
|
+
\tTo initialize it at 0.0.0, pass in parameter -i or --init
|
|
41
|
+
\tExiting with status code 1.
|
|
42
|
+
";
|
|
43
|
+
exit 1;
|
|
44
|
+
else
|
|
45
|
+
INIT_COMMAND="$(dirname $0)/init -q";
|
|
46
|
+
INIT_RETURN=$($INIT_COMMAND)
|
|
47
|
+
if [[ $? != 0 ]]; then
|
|
48
|
+
printf "
|
|
49
|
+
ERROR: Unknown error happened while initializing version.
|
|
50
|
+
\tYou could add the tag yourself with 'git tag 0.0.0'
|
|
51
|
+
\tExiting with status code 1.
|
|
52
|
+
";
|
|
53
|
+
exit 1;
|
|
54
|
+
fi;
|
|
55
|
+
fi;
|
|
56
|
+
fi;
|
|
57
|
+
|
|
58
|
+
case $1 in
|
|
59
|
+
"major"|"maj"|"1")
|
|
60
|
+
GET_NEXT_COMMAND="$(dirname $0)/get-next major -q";
|
|
61
|
+
;;
|
|
62
|
+
"minor"|"min"|"2")
|
|
63
|
+
GET_NEXT_COMMAND="$(dirname $0)/get-next minor -q";
|
|
64
|
+
;;
|
|
65
|
+
"patch"|"p"|"3"|*)
|
|
66
|
+
GET_NEXT_COMMAND="$(dirname $0)/get-next patch -q";
|
|
67
|
+
;;
|
|
68
|
+
esac;
|
|
69
|
+
|
|
70
|
+
NEXT_VERSION=$($GET_NEXT_COMMAND);
|
|
71
|
+
|
|
72
|
+
CURRENT_BRANCH_COMMAND="$(dirname $0)/get-branch -q";
|
|
73
|
+
CURRENT_BRANCH=$($CURRENT_BRANCH_COMMAND);
|
|
74
|
+
git tag $NEXT_VERSION $CURRENT_BRANCH;
|
|
75
|
+
|
|
76
|
+
exit 0;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Version Tagging Scripts
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/zephinzer/version-tagging-scripts)
|
|
4
|
+
|
|
5
|
+
This package provides scripts that helps with managing semver versioning systems using
|
|
6
|
+
git tagging.
|
|
7
|
+
|
|
8
|
+
Semver versioning is:
|
|
9
|
+
```
|
|
10
|
+
X . Y . Z
|
|
11
|
+
| | |-> patch version (bug fixes)
|
|
12
|
+
| |-> minor version (backward-compatible changes/additions)
|
|
13
|
+
|-> major version (backward-compatibility breaking changes)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Read more on semver at: [http://semver.org/](http://semver.org/)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Recommended Installation
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Use this as a `git` submodule. Install it by running the following in the root of your
|
|
25
|
+
project:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
git submodule add https://github.com/zephinzer/version-tagging-scripts <./path/to/put/it/in>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Usage
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
By default, all scripts will print the debug output. They also come with a `-q` or
|
|
38
|
+
`--quiet` flag that can silence the debug output which you should use once you've tested
|
|
39
|
+
them out.
|
|
40
|
+
|
|
41
|
+
Details of all scripts can also be found via the `-h` or `--help` script.
|
|
42
|
+
|
|
43
|
+
> **IMPORTANT** Call the scripts using `./script` instead of `bash ./script`, this allows
|
|
44
|
+
the script to find itself relative to where you're calling it from and things will **fail**
|
|
45
|
+
should you not do so. The necessary hashbangs have been added and they are labelled with
|
|
46
|
+
`#!/bin/sh`.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## `./iterate`
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
The `./iterate` script should be enough for most continuous integration pipelines.
|
|
53
|
+
|
|
54
|
+
Run it anywhere in your pipeline that you need to up the version number.
|
|
55
|
+
|
|
56
|
+
To up the `patch` version, use:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
./path/you/put/it/iterate -q -i
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To up the `minor` version, use:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
./path/you/put/it/iterate minor -q -i
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
To up the `major` version, use:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
./path/you/put/it/iterate major -q -i
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## `./get-branch`
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
This script outputs the current branch you are on.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## `./get-latest`
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
This script outputs the latest version you are on.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## `./get-next`
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
This script outputs the next version you should be migrating to.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## `./init`
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
This script checks for the presence of a `git` tag that resembles `x.y.z` where
|
|
96
|
+
`x` is the major version, `y` is the minor version, and `z` is the patch version.
|
|
97
|
+
Should it fail to find such a git tag, it will initialize by adding a global
|
|
98
|
+
`0.0.0` tag to your repository.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# CI Software Integration Help
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## GitLab
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
Install it in your dev machine with:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
git submodule add https://github.com/zephinzer/version-tagging-scripts <./path/you/wanna/add/submodule/to>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
A new file `.gitmodules` should appear. Verify that it looks like
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
[submodule './path/you/added/submodule/to']
|
|
119
|
+
path = ./path/you/added/submodule/to
|
|
120
|
+
url = https://github.com/zephinzer/version-tagging-scripts
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
We use this script with GitLab by installing this repository as a `git` submodule.
|
|
124
|
+
In a `build` phase in your `scripts` property, add the following:
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
...
|
|
128
|
+
stage: build
|
|
129
|
+
...
|
|
130
|
+
artifacts:
|
|
131
|
+
path:
|
|
132
|
+
- ./path/you/added/submodule/to
|
|
133
|
+
...
|
|
134
|
+
scripts:
|
|
135
|
+
- git submodule deinit -f .
|
|
136
|
+
- git submodule init
|
|
137
|
+
- git submodule update --init
|
|
138
|
+
- git submodule sync
|
|
139
|
+
- ...
|
|
140
|
+
...
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Note that using the `ssh://` version for this repo when adding the submodule **WILL NOT WORK**
|
|
144
|
+
and will corrupt whichever runner it runs on.
|
|
145
|
+
|
|
146
|
+
Incase you corrupt a runner, you'll need to access the directory containing your
|
|
147
|
+
project builds and manually run `deinit` and change the `.gitmodules` file to direct it
|
|
148
|
+
to the HTTPS version of this repository. Main symptom of a corrupt runner will be during
|
|
149
|
+
the fetch/clone phase of a job, you'll see some lines that look like:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Fetching changes...
|
|
153
|
+
fatal: [../]+.git/modules/[./path/you/added/submodule/to] is not a git repository
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or something to that effect. No tests have been run, `before_script` has not run either.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# Play With It
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
The `./utils` directory contains some tools to get you started on how this works.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
## Setup Branches
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
Run the following to set up a traditional CI pipeline consisting of
|
|
171
|
+
`dev`, `ci`, `qa`, `uat`, `staging` and `production` branches/environments:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
#> ./utils/branch_setup
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
You should find yourself on the `_dev` branch. They will be prefixed with an underscore
|
|
178
|
+
incase you forget that they are just test example environments.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
## Setup Pipeline
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
Run the following to add commits to the relevant branches:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
#> ./utils/pipeline_setup
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This will add commits to the environments that simulate an actual pipeline with
|
|
191
|
+
`_production` having only 1 commit and `_dev` having all 6 commits (1 for each
|
|
192
|
+
environment/branch).
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
## Play With It
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
Run `./iterate -q -i` on the `_dev` branch (which you should be on). This will initialize
|
|
199
|
+
the versioning in _dev. Check out the versions available with:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
#> git tag -l --merged
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
There should be `0.0.0` and `0.0.1`. Great.
|
|
206
|
+
|
|
207
|
+
Now checkout the `_ci` branch and check the branch for tags with:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
#> git tag -l --merged
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
There should be no tags. Now do a rebase from the `_dev` branch into your `_ci` branch:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
#> git rebase _dev
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Run the tag checking command again:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
#> git tag -l --merged
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
You should now see `0.0.0` and `0.0.1` because the tags associated with the `HEAD`
|
|
226
|
+
commit in the `_dev` branch should have been played to `_ci` and `_ci` now has the
|
|
227
|
+
commits from `_dev`. Verify this yourself with `git log -n 1`. Both should match.
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## Enough Games
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
Run the following to revert all test/example branches:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
#> ./utils/branch_teardown
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# Inspiration
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
We needed a standardised way to add versioning to our packages. The primary way we use it internally is in a GitLab environment.
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# Testing
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
We use Docker to test the code so that we can check if certain expected features are available.
|
|
254
|
+
|
|
255
|
+
Run the tests using:
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
#> ./test
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
# Supported Versions
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
## Git
|
|
268
|
+
|
|
269
|
+
- Git 1.8.5
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
# Contributing
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
Feel it's lacking something? Feel free to submit a Pull Request. Got it to work with
|
|
277
|
+
another CI software? Feel free to add to this readme's CI Software Integration Help
|
|
278
|
+
section.
|
|
279
|
+
|
|
280
|
+
Cheers!
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
printf_top () {
|
|
3
|
+
printf "\e[4m \e[0m\n";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
printf_bottom () {
|
|
7
|
+
printf "⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻\n";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
printf_fail () {
|
|
11
|
+
printf "\033[0;31mFAILED\033[0m\n";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
printf_success () {
|
|
15
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# on ./test [-s/--start] flag
|
|
19
|
+
if [[ $* == *-s* ]] || [[ $* == *--start* ]]; then
|
|
20
|
+
|
|
21
|
+
# runs in CONTAINER
|
|
22
|
+
|
|
23
|
+
printf_top;
|
|
24
|
+
printf "PATH: $PATH\n";
|
|
25
|
+
printf "GIT: $(git --version)\n";
|
|
26
|
+
printf "USER: $(whoami)\n";
|
|
27
|
+
printf "TIMESTAMP: $(date +"%a, %d %h %Y %I:%M %p")\n"
|
|
28
|
+
printf_bottom;
|
|
29
|
+
|
|
30
|
+
TEST_RESULTS_DIRECTORY="$(dirname $0)/tests/results";
|
|
31
|
+
printf "Creating test results directory... ";
|
|
32
|
+
mkdir -p $TEST_RESULTS_DIRECTORY;
|
|
33
|
+
if [[ $? != 0 ]]; then printf_fail; else printf_success; fi;
|
|
34
|
+
printf "\t> PWD: $(pwd)\n";
|
|
35
|
+
printf "\t> REL_PATH: $TEST_RESULTS_DIRECTORY\n";
|
|
36
|
+
rm -rf $TEST_RESULTS_DIRECTORY/*.test
|
|
37
|
+
ls tests/scripts | xargs -n 1 -I@ sh -c "$(dirname $0)/test --run @";
|
|
38
|
+
|
|
39
|
+
# on ./test [-r/--run] flag
|
|
40
|
+
elif [[ $* == *-r* ]] || [[ $* == *--run* ]]; then
|
|
41
|
+
|
|
42
|
+
# runs in CONTAINER
|
|
43
|
+
|
|
44
|
+
chmod +x $(dirname $0)/tests/scripts/$2;
|
|
45
|
+
printf_top;
|
|
46
|
+
printf "TEST MODULE : $2\n";
|
|
47
|
+
printf "CURRENT DIR : $(pwd)\n"
|
|
48
|
+
printf "CURRENT PATH : ${PATH}\n"
|
|
49
|
+
printf_bottom;
|
|
50
|
+
sh $(dirname $0)/tests/scripts/$2;
|
|
51
|
+
printf "$?" > $(dirname $0)/tests/results/$2;
|
|
52
|
+
|
|
53
|
+
# on ./test [-e/--evaluate] flag
|
|
54
|
+
elif [[ $* == *-e* ]] || [[ $* == *--evaluate* ]]; then
|
|
55
|
+
|
|
56
|
+
# runs on HOST
|
|
57
|
+
|
|
58
|
+
TEST_CASE=$2;
|
|
59
|
+
printf "Evaluating $TEST_CASE... ";
|
|
60
|
+
|
|
61
|
+
STATUS_CODE=$(cat $TEST_CASE);
|
|
62
|
+
if [[ $STATUS_CODE = 0 ]]; then printf "\033[0;32m"; else printf "\033[0;31m"; fi;
|
|
63
|
+
printf "Exited with status code $STATUS_CODE\033[0m.\n";
|
|
64
|
+
|
|
65
|
+
exit $(cat $TEST_CASE);
|
|
66
|
+
|
|
67
|
+
# on ./test
|
|
68
|
+
else
|
|
69
|
+
|
|
70
|
+
# runs on HOST
|
|
71
|
+
|
|
72
|
+
printf_top;
|
|
73
|
+
|
|
74
|
+
# get current version of scripts, exit if .version cannot be found
|
|
75
|
+
SCRIPTS_VERSION=$(cat $(dirname $0)/.version);
|
|
76
|
+
[[ $? != 0 ]] && CORRECT_DIRECTORY=0 || CORRECT_DIRECTORY=1;
|
|
77
|
+
if [[ $CORRECT_DIRECTORY = 0 ]]; then
|
|
78
|
+
printf "Error reading version specification. Are you in the right directory?\n";
|
|
79
|
+
printf "You are in $(pwd).\n";
|
|
80
|
+
printf_bottom;
|
|
81
|
+
exit 1;
|
|
82
|
+
fi;
|
|
83
|
+
printf "VERSION: $SCRIPTS_VERSION\n";
|
|
84
|
+
|
|
85
|
+
# check if Docker is available, exit if not
|
|
86
|
+
DOCKER_VERSION=$(docker --version);
|
|
87
|
+
[[ $? != 0 ]] && DOCKER_EXISTS=0 || DOCKER_EXISTS=1;
|
|
88
|
+
if [[ $DOCKER_EXISTS = 0 ]]; then
|
|
89
|
+
printf "We use Docker to ensure compliance with our software environments but we";
|
|
90
|
+
printf "coudln't find a Docker daemon to work with. Go to https://www.docker.com";
|
|
91
|
+
printf "to download it.\n\n";
|
|
92
|
+
printf "Quicklinks:\n";
|
|
93
|
+
printf "\tMAC: https://store.docker.com/editions/community/docker-ce-desktop-mac\n";
|
|
94
|
+
printf "\tWIN: https://store.docker.com/editions/community/docker-ce-desktop-windows\n"
|
|
95
|
+
printf_bottom;
|
|
96
|
+
exit 1;
|
|
97
|
+
fi;
|
|
98
|
+
printf "DOCKER VERSION: $DOCKER_VERSION\n";
|
|
99
|
+
|
|
100
|
+
# get some diagnostic info on which version we're on
|
|
101
|
+
COMMIT_SHA=$(git log -n 1 --pretty="%H");
|
|
102
|
+
[[ $(git status | grep 'Untracked') = "" ]] && UNTRACKED_EXISTS=0 || UNTRACKED_EXISTS=1;
|
|
103
|
+
[[ $(git status | grep 'modified:') = "" ]] && MODIFIED_EXISTS=0 || MODIFIED_EXISTS=1;
|
|
104
|
+
if [[ $UNTRACKED_EXISTS = 1 ]] | [[ $MODIFIED_EXISTS = 1 ]]; then
|
|
105
|
+
COMMIT_SHA="$COMMIT_SHA * modified";
|
|
106
|
+
fi;
|
|
107
|
+
printf "COMMIT SHA: $COMMIT_SHA\n";
|
|
108
|
+
CURRENT_BRANCH=$(git branch | grep "*" | cut -d' ' -f2);
|
|
109
|
+
printf "ON BRANCH: $CURRENT_BRANCH\n";
|
|
110
|
+
printf_bottom;
|
|
111
|
+
|
|
112
|
+
# run tests
|
|
113
|
+
docker-compose -f ./tests/docker-compose.yml up --build;
|
|
114
|
+
|
|
115
|
+
# print results
|
|
116
|
+
printf_top;
|
|
117
|
+
ls tests/results | xargs -n 1 -I@ sh -c "$(dirname $0)/test --evaluate tests/results/@";
|
|
118
|
+
COLLATED_TESTS_RESULT=$?;
|
|
119
|
+
if [[ $COLLATED_TESTS_RESULT = 0 ]]; then printf "\033[0;32m"; else printf "\033[0;31m"; fi;
|
|
120
|
+
printf "\nExiting with status code $COLLATED_TESTS_RESULT.\033[0m\n";
|
|
121
|
+
|
|
122
|
+
printf_bottom;
|
|
123
|
+
|
|
124
|
+
# exit with test results code
|
|
125
|
+
exit $COLLATED_TESTS_RESULT;
|
|
126
|
+
|
|
127
|
+
fi;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
ERRORS=0;
|
|
3
|
+
|
|
4
|
+
printf_fail () {
|
|
5
|
+
((ERRORS++));
|
|
6
|
+
printf "\033[0;31mFAILED\033[0m\n";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
printf_success () {
|
|
10
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
./utils/branch_setup > /dev/null;
|
|
14
|
+
|
|
15
|
+
git checkout _production > /dev/null;
|
|
16
|
+
PRODUCTION_BRANCH=$(./get-branch);
|
|
17
|
+
printf "_production : ";
|
|
18
|
+
[[ $PRODUCTION_BRANCH = "_production" ]] && printf_success || printf_fail;
|
|
19
|
+
|
|
20
|
+
git checkout _staging > /dev/null;
|
|
21
|
+
STAGING_BRANCH=$(./get-branch);
|
|
22
|
+
printf "_staging : ";
|
|
23
|
+
[[ $STAGING_BRANCH = "_staging" ]] && printf_success || printf_fail;
|
|
24
|
+
|
|
25
|
+
git checkout _uat > /dev/null;
|
|
26
|
+
UAT_BRANCH=$(./get-branch);
|
|
27
|
+
printf "_uat : ";
|
|
28
|
+
[[ $UAT_BRANCH = "_uat" ]] && printf_success || printf_fail;
|
|
29
|
+
|
|
30
|
+
git checkout _qa > /dev/null;
|
|
31
|
+
QA_BRANCH=$(./get-branch);
|
|
32
|
+
printf "_qa : ";
|
|
33
|
+
[[ $QA_BRANCH = "_qa" ]] && printf_success || printf_fail;
|
|
34
|
+
|
|
35
|
+
git checkout _ci > /dev/null;
|
|
36
|
+
CI_BRANCH=$(./get-branch);
|
|
37
|
+
printf "_ci : ";
|
|
38
|
+
[[ $CI_BRANCH = "_ci" ]] && printf_success || printf_fail;
|
|
39
|
+
|
|
40
|
+
git checkout _dev > /dev/null;
|
|
41
|
+
DEV_BRANCH=$(./get-branch);
|
|
42
|
+
printf "_dev : ";
|
|
43
|
+
[[ $DEV_BRANCH = "_dev" ]] && printf_success || printf_fail;
|
|
44
|
+
|
|
45
|
+
./utils/branch_teardown > /dev/null;
|
|
46
|
+
|
|
47
|
+
[[ $ERRORS > 0 ]] && FAILURE=1 || FAILURE=0;
|
|
48
|
+
|
|
49
|
+
printf "\nExiting with status code $FAILURE.\n\n";
|
|
50
|
+
exit $FAILURE;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# error count, anything more than 1 and we should exit with 1
|
|
3
|
+
ERRORS=0;
|
|
4
|
+
# each test case should alwys be larger than the next so we can automate checking
|
|
5
|
+
# note that tags will actually be created, so use numbers that users prolly won't use
|
|
6
|
+
TEST_CASES="
|
|
7
|
+
1000.0.0
|
|
8
|
+
1001.0.0
|
|
9
|
+
1010.0.0
|
|
10
|
+
1100.0.0
|
|
11
|
+
9000.0.0
|
|
12
|
+
10000.0.0
|
|
13
|
+
10000.1.0
|
|
14
|
+
10000.9.0
|
|
15
|
+
10000.10.0
|
|
16
|
+
10000.10.1
|
|
17
|
+
10000.10.10
|
|
18
|
+
10000.10.99
|
|
19
|
+
10000.99.99
|
|
20
|
+
10000.99.100
|
|
21
|
+
10000.100.99
|
|
22
|
+
"
|
|
23
|
+
|
|
24
|
+
test_if_largest () {
|
|
25
|
+
printf "\t$1 : ";
|
|
26
|
+
git tag $1;
|
|
27
|
+
TEST_CASE=$(./get-latest -q);
|
|
28
|
+
if [[ $TEST_CASE != $1 ]] | [[ $? != 0 ]]; then
|
|
29
|
+
printf "\033[0;31mFAILED\033[0m\n";
|
|
30
|
+
exit 1;
|
|
31
|
+
fi;
|
|
32
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
teardown () {
|
|
36
|
+
printf "\t$1... ";
|
|
37
|
+
git tag -d $1 > /dev/null;
|
|
38
|
+
if [[ $? != 0 ]]; then
|
|
39
|
+
printf "\033[0;31mERROR\033[0m\n";
|
|
40
|
+
exit 1;
|
|
41
|
+
fi;
|
|
42
|
+
printf "\033[0;32mOK\033[0m\n";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
printf "Processing...\n";
|
|
46
|
+
echo $TEST_CASES | xargs -n 1 | xargs -I@ sh -c "$(declare -f test_if_largest); test_if_largest @;";
|
|
47
|
+
[[ $? != 0 ]] && FAILURE=1 || FAILURE=0;
|
|
48
|
+
printf "...DONE.\nRemoving...\n";
|
|
49
|
+
echo $TEST_CASES | xargs -n 1 | xargs -I@ sh -c "$(declare -f teardown); teardown @;";
|
|
50
|
+
printf "...DONE.\n";
|
|
51
|
+
printf "\nExiting with status code $FAILURE.\n\n";
|
|
52
|
+
|
|
53
|
+
exit $FAILURE;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
ERRORS=0;
|
|
3
|
+
TAG='1234567.1234567.1234567';
|
|
4
|
+
EXPECTED_NEXT_PATCH='1234567.1234567.1234568';
|
|
5
|
+
EXPECTED_NEXT_MINOR='1234567.1234568.0';
|
|
6
|
+
EXPECTED_NEXT_MAJOR='1234568.0.0';
|
|
7
|
+
|
|
8
|
+
printf_fail () {
|
|
9
|
+
EXPECTED=$1;
|
|
10
|
+
ACTUAL=$2;
|
|
11
|
+
((ERRORS++));
|
|
12
|
+
printf "\033[0;31mFAILED (expected '${EXPECTED}' but got '${ACTUAL}')\033[0m\n";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
printf_success () {
|
|
16
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
git tag $TAG;
|
|
20
|
+
[[ $? != 0 ]] && ((ERRORS++));
|
|
21
|
+
printf "Added tag '$TAG'\n";
|
|
22
|
+
|
|
23
|
+
printf "Using 'patch'..."
|
|
24
|
+
if [[ $(./get-next patch -q) != $EXPECTED_NEXT_PATCH ]]; then printf_fail $EXPECTED_NEXT_PATCH $(./get-next patch -q); else printf_success; fi;
|
|
25
|
+
printf "Using 'ptc'..."
|
|
26
|
+
if [[ $(./get-next ptc -q) != $EXPECTED_NEXT_PATCH ]]; then printf_fail $EXPECTED_NEXT_PATCH $(./get-next ptc -q); else printf_success; fi;
|
|
27
|
+
printf "Using 'p'..."
|
|
28
|
+
if [[ $(./get-next p -q) != $EXPECTED_NEXT_PATCH ]]; then printf_fail $EXPECTED_NEXT_PATCH $(./get-next p -q); else printf_success; fi;
|
|
29
|
+
|
|
30
|
+
printf "Using 'minor'..."
|
|
31
|
+
if [[ $(./get-next minor -q) != $EXPECTED_NEXT_MINOR ]]; then printf_fail $EXPECTED_NEXT_MINOR $(./get-next minor -q); else printf_success; fi;
|
|
32
|
+
printf "Using 'min'..."
|
|
33
|
+
if [[ $(./get-next min -q) != $EXPECTED_NEXT_MINOR ]]; then printf_fail $EXPECTED_NEXT_MINOR $(./get-next min -q); else printf_success; fi;
|
|
34
|
+
printf "Using 'm2'..."
|
|
35
|
+
if [[ $(./get-next m2 -q) != $EXPECTED_NEXT_MINOR ]]; then printf_fail $EXPECTED_NEXT_MINOR $(./get-next m2 -q); else printf_success; fi;
|
|
36
|
+
|
|
37
|
+
printf "Using 'major'... "
|
|
38
|
+
if [[ $(./get-next major -q) != $EXPECTED_NEXT_MAJOR ]]; then printf_fail $EXPECTED_NEXT_MAJOR $(./get-next major -q); else printf_success; fi;
|
|
39
|
+
printf "Using 'maj'... "
|
|
40
|
+
if [[ $(./get-next maj -q) != $EXPECTED_NEXT_MAJOR ]]; then printf_fail $EXPECTED_NEXT_MAJOR $(./get-next maj -q); else printf_success; fi;
|
|
41
|
+
printf "Using 'm1'... "
|
|
42
|
+
if [[ $(./get-next m1 -q) != $EXPECTED_NEXT_MAJOR ]]; then printf_fail $EXPECTED_NEXT_MAJOR $(./get-next m1 -q); else printf_success; fi;
|
|
43
|
+
|
|
44
|
+
git tag -d $TAG;
|
|
45
|
+
[[ $? != 0 ]] && ((ERRORS++));
|
|
46
|
+
|
|
47
|
+
[[ $ERRORS > 0 ]] && FAILURE=1 || FAILURE=0;
|
|
48
|
+
|
|
49
|
+
printf "\nExiting with status code $FAILURE.\n\n";
|
|
50
|
+
exit $FAILURE;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
ERRORS=0;
|
|
3
|
+
INIT_VALUE="0.0.0";
|
|
4
|
+
|
|
5
|
+
printf_fail () {
|
|
6
|
+
((ERRORS++));
|
|
7
|
+
printf "\033[0;31mFAILED\033[0m\n";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
printf_success () {
|
|
11
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
git tag -l | xargs -n 1 -I@ sh -c "git tag -d @";
|
|
15
|
+
printf "Performing './init -q'... ";
|
|
16
|
+
./init -q;
|
|
17
|
+
if [[ $? != 0 ]]; then printf_fail; else printf_success; fi;
|
|
18
|
+
printf "Checking for tag 0.0.0... ";
|
|
19
|
+
if [[ $(git tag -l | grep $INIT_VALUE) != $INIT_VALUE ]]; then printf_fail; else printf_success; fi;
|
|
20
|
+
git tag -d $INIT_VALUE;
|
|
21
|
+
|
|
22
|
+
[[ $ERRORS > 0 ]] && FAILURE=1 || FAILURE=0;
|
|
23
|
+
|
|
24
|
+
printf "\nExiting with status code $FAILURE.\n\n";
|
|
25
|
+
exit $FAILURE;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
ERRORS=0;
|
|
3
|
+
INITIAL_VERSION="123456.123456.123456";
|
|
4
|
+
NEXT_PATCH_VERSION="123456.123456.123457";
|
|
5
|
+
NEXT_MINOR_VERSION="123456.123457.0";
|
|
6
|
+
NEXT_MAJOR_VERSION="123457.0.0";
|
|
7
|
+
|
|
8
|
+
iterate_with () {
|
|
9
|
+
git tag $INITIAL_VERSION;
|
|
10
|
+
./iterate $1 -q;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
teardown () {
|
|
14
|
+
git tag -d $INITIAL_VERSION >/dev/null;
|
|
15
|
+
git tag -d $1 >/dev/null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
run_test_and_cleanup_on () {
|
|
19
|
+
[[ $(git tag -l | grep $1) = "" ]] && printf_fail || printf_success;
|
|
20
|
+
teardown $1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
printf_fail () {
|
|
24
|
+
((ERRORS++));
|
|
25
|
+
printf "\033[0;31mFAILED\033[0m\n";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
printf_success () {
|
|
29
|
+
printf "\033[0;32mSUCCESSFUL\033[0m\n";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
printf "Using 'patch': ";
|
|
33
|
+
iterate_with patch;
|
|
34
|
+
run_test_and_cleanup_on $NEXT_PATCH_VERSION;
|
|
35
|
+
printf "Using 'p': ";
|
|
36
|
+
iterate_with p;
|
|
37
|
+
run_test_and_cleanup_on $NEXT_PATCH_VERSION;
|
|
38
|
+
printf "Using '3': ";
|
|
39
|
+
iterate_with 3;
|
|
40
|
+
run_test_and_cleanup_on $NEXT_PATCH_VERSION;
|
|
41
|
+
|
|
42
|
+
printf "Using 'minor': ";
|
|
43
|
+
iterate_with minor;
|
|
44
|
+
run_test_and_cleanup_on $NEXT_MINOR_VERSION;
|
|
45
|
+
printf "Using 'min': ";
|
|
46
|
+
iterate_with min;
|
|
47
|
+
run_test_and_cleanup_on $NEXT_MINOR_VERSION;
|
|
48
|
+
printf "Using '2': ";
|
|
49
|
+
iterate_with 2;
|
|
50
|
+
run_test_and_cleanup_on $NEXT_MINOR_VERSION;
|
|
51
|
+
|
|
52
|
+
printf "Using 'major': ";
|
|
53
|
+
iterate_with major;
|
|
54
|
+
run_test_and_cleanup_on $NEXT_MAJOR_VERSION;
|
|
55
|
+
printf "Using 'maj': ";
|
|
56
|
+
iterate_with maj;
|
|
57
|
+
run_test_and_cleanup_on $NEXT_MAJOR_VERSION;
|
|
58
|
+
printf "Using '1': ";
|
|
59
|
+
iterate_with 1;
|
|
60
|
+
run_test_and_cleanup_on $NEXT_MAJOR_VERSION;
|
|
61
|
+
|
|
62
|
+
[[ $ERRORS > 0 ]] && FAILURE=1 || FAILURE=0;
|
|
63
|
+
|
|
64
|
+
printf "\nExiting with status code $FAILURE.\n\n";
|
|
65
|
+
exit $FAILURE;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
[[ $(git branch | egrep '_dev$') != "" ]] && DEV_EXISTS=1 || DEV_EXISTS=0;
|
|
3
|
+
[[ $(git branch | egrep '_ci$') != "" ]] && CI_EXISTS=1 || CI_EXISTS=0;
|
|
4
|
+
[[ $(git branch | egrep '_qa$') != "" ]] && QA_EXISTS=1 || QA_EXISTS=0;
|
|
5
|
+
[[ $(git branch | egrep '_uat$') != "" ]] && UAT_EXISTS=1 || UAT_EXISTS=0;
|
|
6
|
+
[[ $(git branch | egrep '_staging$') != "" ]] && STAGING_EXISTS=1 || STAGING_EXISTS=0;
|
|
7
|
+
[[ $(git branch | egrep '_production$') != "" ]] && PRODUCTION_EXISTS=1 || PRODUCTION_EXISTS=0;
|
|
8
|
+
echo "$DEV_EXISTS $CI_EXISTS $QA_EXISTS $UAT_EXISTS $STAGING_EXISTS $PRODUCTION_EXISTS";
|
|
9
|
+
if [[ $DEV_EXISTS = 0 ]] |
|
|
10
|
+
[[ $CI_EXISTS = 0 ]] |
|
|
11
|
+
[[ $QA_EXISTS = 0 ]] |
|
|
12
|
+
[[ $UAT_EXISTS = 0 ]] |
|
|
13
|
+
[[ $STAGING_EXISTS = 0 ]] |
|
|
14
|
+
[[ $PRODUCTION_EXISTS = 0 ]]; then
|
|
15
|
+
printf 'The necessary environments (_dev, _ci, _qa, _uat, _staging, _production) could not be found. Run "branch_setup" before continuing"\n';
|
|
16
|
+
exit 1;
|
|
17
|
+
fi;
|
|
18
|
+
|
|
19
|
+
mkdir -p _data
|
|
20
|
+
|
|
21
|
+
git checkout _dev;
|
|
22
|
+
echo 'prod' > ./_data/prod.flag;
|
|
23
|
+
git add -f ./_data/prod.flag;
|
|
24
|
+
git commit -m 'prod';
|
|
25
|
+
git checkout _ci;
|
|
26
|
+
git rebase _dev;
|
|
27
|
+
git checkout _qa;
|
|
28
|
+
git rebase _ci;
|
|
29
|
+
git checkout _uat;
|
|
30
|
+
git rebase _qa;
|
|
31
|
+
git checkout _staging;
|
|
32
|
+
git rebase _uat;
|
|
33
|
+
git checkout _production;
|
|
34
|
+
git rebase _staging;
|
|
35
|
+
|
|
36
|
+
git checkout _dev;
|
|
37
|
+
echo 'staging' > ./_data/staging.flag;
|
|
38
|
+
git add -f ./_data/staging.flag;
|
|
39
|
+
git commit -m 'staging';
|
|
40
|
+
git checkout _ci;
|
|
41
|
+
git rebase _dev;
|
|
42
|
+
git checkout _qa;
|
|
43
|
+
git rebase _ci;
|
|
44
|
+
git checkout _uat;
|
|
45
|
+
git rebase _qa;
|
|
46
|
+
git checkout _staging;
|
|
47
|
+
git rebase _uat;
|
|
48
|
+
|
|
49
|
+
git checkout _dev;
|
|
50
|
+
echo 'uat' > ./_data/uat.flag;
|
|
51
|
+
git add -f ./_data/uat.flag;
|
|
52
|
+
git commit -m 'uat';
|
|
53
|
+
git checkout _ci;
|
|
54
|
+
git rebase _dev;
|
|
55
|
+
git checkout _qa;
|
|
56
|
+
git rebase _ci;
|
|
57
|
+
git checkout _uat;
|
|
58
|
+
git rebase _qa;
|
|
59
|
+
|
|
60
|
+
git checkout _dev;
|
|
61
|
+
echo 'qa' > ./_data/qa.flag;
|
|
62
|
+
git add -f ./_data/qa.flag;
|
|
63
|
+
git commit -m 'qa';
|
|
64
|
+
git checkout _ci;
|
|
65
|
+
git rebase _dev;
|
|
66
|
+
git checkout _qa;
|
|
67
|
+
git rebase _ci;
|
|
68
|
+
|
|
69
|
+
git checkout _dev;
|
|
70
|
+
echo 'ci' > ./_data/ci.flag;
|
|
71
|
+
git add -f ./_data/ci.flag;
|
|
72
|
+
git commit -m 'ci';
|
|
73
|
+
git checkout _ci;
|
|
74
|
+
git rebase _dev;
|
|
75
|
+
|
|
76
|
+
git checkout _dev;
|
|
77
|
+
echo 'dev' > ./_data/dev.flag;
|
|
78
|
+
git add -f ./_data/dev.flag;
|
|
79
|
+
git commit -m 'dev';
|