Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
testcenter-frontend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IQB
discontinued
testcenter-frontend
Commits
570802d6
Commit
570802d6
authored
4 years ago
by
rhenck
Browse files
Options
Downloads
Patches
Plain Diff
Add Script and Makefile targets to create tagged new version.
parent
a0441591
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+9
-0
9 additions, 0 deletions
Makefile
scripts/new_version.py
+98
-0
98 additions, 0 deletions
scripts/new_version.py
with
107 additions
and
0 deletions
Makefile
+
9
−
0
View file @
570802d6
...
@@ -30,3 +30,12 @@ build-image:
...
@@ -30,3 +30,12 @@ build-image:
push-image
:
push-image
:
docker push iqbberlin/testcenter-frontend:latest
docker push iqbberlin/testcenter-frontend:latest
tag-major
:
scripts/new_version.py major
tag-minor
:
scripts/new_version.py minor
tag-patch
:
scripts/new_version.py patch
This diff is collapsed.
Click to expand it.
scripts/new_version.py
0 → 100755
+
98
−
0
View file @
570802d6
#!/usr/bin/python3
"""
This script shall be used to create a new release.
It consists of several steps:
STEP 1 - Update version:
A parameter has to be passed which can be one of the following:
'
major
'
/
'
minor
'
/
'
patch
'
.
Depending on this parameter the version of the software will be updated in the
corresponding file. The file which holds this information can be set at the top
of the script with the VERSION_FILE variable and the regular expression to find
the string can be set as well.
STEP 2 - Run Tests:
Starting the software stack via docker and run the tests.
Thise tests may change additional files, which have to be commited as well.
STEP 3 - Git commit and tag
Several steps are taken to update the git repository. The shell commands are the following:
git add {VERSION_FILE}
git commit -m
"
Update version to {new_version}
"
git push
git tag {new_version}
git push origin {new_version}
"""
import
sys
import
time
import
re
import
subprocess
VERSION_FILE
=
'
package.json
'
VERSION_REGEX
=
'
(?<=version
"
:
"
)(.*)(?=
"
)
'
ADDITIONAL_FILES_TO_COMMIT
=
[]
def
_parse_version
()
->
str
:
match
=
pattern
.
search
(
file_content
)
if
match
:
return
match
.
group
()
else
:
sys
.
exit
(
'
Version pattern not found in file. Check your regex!
'
)
def
_update_version_in_file
(
new_version
):
new_file_content
=
pattern
.
sub
(
new_version
,
file_content
)
with
open
(
VERSION_FILE
,
'
w
'
)
as
f
:
f
.
write
(
new_file_content
)
def
_increment_version
(
old_version
):
version_part
=
sys
.
argv
[
1
]
old_version_as_list
=
old_version
.
split
(
'
.
'
)
if
version_part
==
'
major
'
:
new_version
=
f
'
{
int
(
old_version_as_list
[
0
])
+
1
}
.0.0
'
elif
version_part
==
'
minor
'
:
new_version
=
f
'
{
old_version_as_list
[
0
]
}
.
{
int
(
old_version_as_list
[
1
])
+
1
}
.0
'
else
:
new_version
=
f
'
{
old_version_as_list
[
0
]
}
.
{
old_version_as_list
[
1
]
}
.
{
int
(
old_version_as_list
[
2
])
+
1
}
'
return
new_version
def
_run_software
():
subprocess
.
run
(
'
make run-detached
'
,
shell
=
True
,
check
=
True
)
def
_stop_software
():
subprocess
.
run
(
'
make stop
'
,
shell
=
True
,
check
=
True
)
def
_run_tests
():
time
.
sleep
(
10
)
subprocess
.
run
(
'
make test-unit
'
,
shell
=
True
,
check
=
True
)
time
.
sleep
(
10
)
subprocess
.
run
(
'
make test-e2e
'
,
shell
=
True
,
check
=
True
)
def
_git_tag
():
print
(
f
"
Creating git tag for version
{
new_version
}
"
)
subprocess
.
run
(
f
"
git add
{
VERSION_FILE
}
"
,
shell
=
True
,
check
=
True
)
for
file
in
ADDITIONAL_FILES_TO_COMMIT
:
subprocess
.
run
(
f
"
git add
{
file
}
"
,
shell
=
True
,
check
=
True
)
subprocess
.
run
(
f
"
git commit -m
\"
Update version to
{
new_version
}
\"
"
,
shell
=
True
,
check
=
True
)
subprocess
.
run
(
"
git push origin master
"
,
shell
=
True
,
check
=
True
)
subprocess
.
run
(
f
"
git tag
{
new_version
}
"
,
shell
=
True
,
check
=
True
)
subprocess
.
run
(
f
"
git push origin
{
new_version
}
"
,
shell
=
True
,
check
=
True
)
if
len
(
sys
.
argv
)
<
2
:
sys
.
exit
(
'
No parameter given. Use
\'
major
\'
/
\'
minor
\'
/
\'
patch
\'
!
'
)
pattern
=
re
.
compile
(
VERSION_REGEX
)
with
open
(
VERSION_FILE
)
as
version_file
:
file_content
=
version_file
.
read
()
old_version
=
_parse_version
()
new_version
=
_increment_version
(
old_version
)
_update_version_in_file
(
new_version
)
_run_software
()
_run_tests
()
_stop_software
()
_git_tag
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment