forked from chrismaille/marshmallow-pynamodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_changelog.sh
executable file
·73 lines (60 loc) · 1.69 KB
/
update_changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Inspect Unreleased Changelog
UNRELEASE_DATA=$(auto-changelog -u --stdout)
has_features=false
breaking_changes=false
if [[ $(echo ${UNRELEASE_DATA} | grep "#### New Features") != "" ]]
then
echo "Unreleased commits has new features..."
has_features=true
fi
if [[ $(echo ${UNRELEASE_DATA} | grep "BREAKING") != "" ]]
then
echo "Unreleased commits has breaking changes..."
breaking_changes=true
fi
# Determine Version level
if [[ ${breaking_changes} == true ]]
then
version_level="major"
elif [[ ${has_features} == true ]]
then
version_level="minor"
else
version_level="patch"
fi
PACKAGE_VERSION=$(poetry version | grep -o -P "(?<=marshmallow-pynamo-db )\S+")
echo "Current version: ${PACKAGE_VERSION}"
# Determine Bump Rule
current_branch=$(git branch | grep -o -P "(?<=\* )\S+")
if [[ ${current_branch} == "master" ]]
then
version_rule=${version_level}
else
if [[ ${PACKAGE_VERSION} == *"alpha"* ]]; then
version_rule="prerelease"
else
version_rule="pre${version_level}"
fi
fi
echo "Bump rule: ${version_rule}"
# Update Version
poetry version "${version_rule}"
PACKAGE_NEW_VERSION=$(poetry version | grep -o -P "(?<=marshmallow-pynamo-db )\S+")
echo "New version: ${PACKAGE_NEW_VERSION}"
# Tag new Version
if [[ ${current_branch} == "master" ]]
then
git tag ${PACKAGE_NEW_VERSION}
fi
# Update Changelog
auto-changelog
# Commit alterations
echo "Commiting alterations..."
git config --global user.email ${GIT_EMAIL}
git config --global user.name ${GIT_NAME}
git fetch --all
git add CHANGELOG.md
git add pyproject.toml
git commit -m "[skip-ci] auto-bump version ${PACKAGE_NEW_VERSION}"
git push "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git" "${current_branch}" --tags