Skip to content

Commit 6044cc0

Browse files
committed
first commit
0 parents  commit 6044cc0

File tree

13 files changed

+1015
-0
lines changed

13 files changed

+1015
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore idea
2+
/.idea

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Björn Hempel <bjoern@hempel.li>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# BashVersionManager
2+
3+
The `bin/version-manager` tool helps you to _maintain_ the versions in the current path. It increments
4+
the patch, minor or major version and replaces them in the corresponding files.
5+
6+
## Create new `VERSION` file
7+
8+
The `VERSION` file is used as the source for the version number. A missing file can be created
9+
automatically.
10+
11+
```bash
12+
❯ bin/version-manager --current
13+
14+
[2022-01-16 16:51:41] (error) → Version file "~/ixno/bash-version-manager/VERSION" not found.
15+
16+
Do you want to create a version file "VERSION" with version "0.1.0"? y
17+
18+
[2022-01-16 16:51:43] (error) → Version file "~/ixno/bash-version-manager/VERSION" successfully created.
19+
```
20+
21+
## Optional: Create `.env` file
22+
23+
Currently, the variable `VERSION_APP` can be replaced in the `.env` file:
24+
25+
```bash
26+
❯ cat <<EOT >> .env
27+
# Version of this app
28+
VERSION_APP=$(cat VERSION)
29+
30+
# Version of this app
31+
VERSION_APP_LATEST=latest
32+
EOT
33+
```
34+
35+
## Show current version
36+
37+
If you want to see the current version, use the following command.
38+
39+
```bash
40+
❯ bin/version-manager --current
41+
42+
Current version: 0.1.0
43+
44+
Next major version: 1.0.0 (Use bin/version-manager --major)
45+
Next minor version: 0.2.0 (Use bin/version-manager --minor)
46+
Next patch version: 0.1.1 (Use bin/version-manager --patch)
47+
```
48+
49+
## Switch patch version
50+
51+
To change the patch version use the flag `--patch`.
52+
53+
```bash
54+
❯ bin/version-manager --patch
55+
56+
Current version: 0.1.0
57+
New version: 0.1.1
58+
59+
Do you want to set the new version "0.1.1" (y/n)? y
60+
61+
[2022-01-16 16:57:46] (info) → Set version "0.1.1" to "~/ixno/bash-version-manager/VERSION"
62+
[2022-01-16 16:57:46] (success) → Done.
63+
[2022-01-16 16:57:46] (info) → Set version "0.1.1" to "~/ixno/bash-version-manager/.env"
64+
[2022-01-16 16:57:46] (success) → Done.
65+
```
66+
67+
## Switch minor version
68+
69+
To change the minor version use the flag `--minor`.
70+
71+
```bash
72+
❯ bin/version-manager --minor
73+
74+
Current version: 0.1.0
75+
New version: 0.2.0
76+
77+
Do you want to set the new version "0.2.0" (y/n)? y
78+
79+
[2022-01-16 16:58:32] (info) → Set version "0.2.0" to "~/ixno/bash-version-manager/VERSION"
80+
[2022-01-16 16:58:32] (success) → Done.
81+
[2022-01-16 16:58:32] (info) → Set version "0.2.0" to "~/ixno/bash-version-manager/.env"
82+
[2022-01-16 16:58:32] (success) → Done.
83+
```
84+
85+
## Switch major version
86+
87+
To change the major version use the flag `--major`.
88+
89+
```bash
90+
❯ bin/version-manager --major
91+
92+
Current version: 0.1.0
93+
New version: 1.0.0
94+
95+
Do you want to set the new version "1.0.0" (y/n)? y
96+
97+
[2022-01-16 16:59:06] (info) → Set version "1.0.0" to "~/ixno/bash-version-manager/VERSION"
98+
[2022-01-16 16:59:06] (success) → Done.
99+
[2022-01-16 16:59:06] (info) → Set version "1.0.0" to "~/ixno/bash-version-manager/.env"
100+
[2022-01-16 16:59:06] (success) → Done.
101+
```
102+
103+
## Switch to given version
104+
105+
A custom version (e.g. `1.2.3`) for changing versions can be specified as a parameter.
106+
107+
```bash
108+
❯ bin/version-manager 1.2.3
109+
110+
Current version: 0.1.0
111+
New version: 1.2.3
112+
113+
Do you want to set the new version "1.2.3" (y/n)? y
114+
115+
[2022-01-16 18:11:41] (info) → Set version "1.2.3" to "/home/bjoern/Development/ixno/bash-version-manager/VERSION"
116+
[2022-01-16 18:11:41] (success) → Done.
117+
[2022-01-16 18:11:41] (info) → Set version "1.2.3" to "/home/bjoern/Development/ixno/bash-version-manager/.env"
118+
[2022-01-16 18:11:41] (success) → Done.
119+
```
120+
121+
## Use another working directory
122+
123+
Usually the tool uses the current working directory. This can be changed.
124+
125+
```bash
126+
❯ bin/version-manager --working-dir test --current
127+
128+
Current version: 0.2.1
129+
130+
Next major version: 1.0.0 (Use bin/version-manager --major)
131+
Next minor version: 0.3.0 (Use bin/version-manager --minor)
132+
Next patch version: 0.2.2 (Use bin/version-manager --patch)
133+
```
134+
135+
## Show help
136+
137+
Shows the parameters and arguments of the tool.
138+
139+
```bash
140+
❯ bin/version-manager --help
141+
142+
version-manager 0.1.0 (2022-01-16) - Björn Hempel <bjoern@hempel.li>
143+
144+
Usage: version-manager [...options] [version]
145+
146+
-c, --current Shows the current version.
147+
148+
-X, --major Will increase the major version (x.0.0).
149+
-m, --minor Will increase the minor version (0.x.0).
150+
-p, --patch Will increase the patch version (0.0.x).
151+
152+
-w, --working-dir Sets the current working-dir (default: "~/ixno/bash-version-manager")
153+
154+
-s, --show-hints Shows some hints.
155+
-h, --help Shows this help.
156+
-V, --version Shows the version number.
157+
```
158+
159+
## Show git hints
160+
161+
Shows some useful commands for committing to the Git repository.
162+
163+
```bash
164+
❯ bin/version-manager --show-hints
165+
166+
Now you can do the following:
167+
168+
169+
→ Edit your CHANGELOG.md file
170+
171+
❯ vi CHANGELOG.md
172+
173+
174+
→ Usually version changes are set in the main or master branch
175+
176+
❯ git checkout main && git pull
177+
178+
179+
→ Commit your changes to your repo
180+
181+
❯ git add CHANGELOG.md && git commit -m "Add version $(cat VERSION)" && git push
182+
183+
184+
→ Tag your version
185+
186+
❯ git tag -a "$(cat VERSION)" -m "Version $(cat VERSION)" && git push origin "$(cat VERSION)"
187+
```
188+
189+
## Execute tests
190+
191+
If you want to make changes, the test mode helps to check the current changes. Test mode uses the
192+
files in the test folder:
193+
194+
* `.env` (source file)
195+
* `.env.major` (comparison file with major change)
196+
* `.env.minor` (comparison file with minor change)
197+
* `.env.patch` (comparison file with patch change)
198+
* `VERSION` (source file)
199+
* `VERSION.major` (comparison file with major change)
200+
* `VERSION.minor` (comparison file with minor change)
201+
* `VERSION.patch` (comparison file with patch change)
202+
203+
```bash
204+
❯ bin/version-manager --test
205+
206+
[2022-01-16 16:50:57] (info) → The sha1 keys match (major).
207+
[2022-01-16 16:50:57] (info) → The sha1 keys match (major).
208+
209+
[2022-01-16 16:50:57] (info) → The sha1 keys match (minor).
210+
[2022-01-16 16:50:57] (info) → The sha1 keys match (minor).
211+
212+
[2022-01-16 16:50:57] (info) → The sha1 keys match (patch).
213+
[2022-01-16 16:50:57] (info) → The sha1 keys match (patch).
214+
215+
[2022-01-16 16:50:57] (success) → All tests were completed successfully.
216+
```
217+
218+
## License
219+
220+
This tool is licensed under the MIT License - see the [LICENSE.md](/LICENSE.md) file for details

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

0 commit comments

Comments
 (0)