-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrelease.sh
executable file
·47 lines (36 loc) · 1.2 KB
/
release.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
#!/usr/bin/env sh
VERSION=$1
VERSION_TAG="v$VERSION"
VERSION_CURRENT_TAG=$(git describe --tags --abbrev=0)
VERSION_CURRENT_TAG="${VERSION_CURRENT_TAG:1}"
if [ -z "$VERSION" ]
then
echo "Release version is not specified!"
echo "Last released: ${VERSION_CURRENT_TAG}"
exit 1
fi
GIT_STAT=$(git diff --stat)
if [ "$GIT_STAT" != '' ]; then
echo "Unable to release. Uncommitted changes detected!"
exit 1
fi
echo "Releasing $VERSION_TAG"
echo "Bumping version in files"
README_FILE="README.MD"
PROJECT_WRAPPER_SCRIPT="pkg/project/common/aemw"
# <https://stackoverflow.com/a/57766728>
if [ "$(uname)" = "Darwin" ]; then
sed -i '' 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$PROJECT_WRAPPER_SCRIPT"
# shellcheck disable=SC2016
sed -i '' 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$README_FILE"
else
sed -i 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$PROJECT_WRAPPER_SCRIPT"
# shellcheck disable=SC2016
sed -i 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$README_FILE"
fi
echo "Pushing version bump"
git commit -a -m "Release $VERSION_TAG"
git push
echo "Pushing release tag '$VERSION_TAG'"
git tag "$VERSION_TAG"
git push origin "$VERSION_TAG"