forked from Aternus/geonames-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·42 lines (36 loc) · 874 Bytes
/
publish.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
#!/bin/bash
##
# Publish the Library to Packagist.org
###########################################################
GIT_ROOT=$(git rev-parse --show-toplevel)
VERSION=$1
##
# Functions
##
update_version() {
TARGET="composer.json"
cd ${GIT_ROOT} || exit
if [[ -n ${VERSION} && -e ${TARGET} ]]; then
echo "Updating version in ${TARGET} to ${VERSION}"
sed -E -i.bak "s|\"version\": \"[0-9]+\.[0-9]+\.[0-9]+\"|\"version\": \"${VERSION}\"|" ${TARGET}
fi
}
git_push() {
echo "Adding files to git, committing changes and pushing to remote..."
cd ${GIT_ROOT} || exit
git add .
git commit -m "version ${VERSION}"
git push
}
git_add_tag() {
echo "Adding a git tag for the new version and pushing to remote..."
cd ${GIT_ROOT} || exit
git tag -a "${VERSION}" -m "${VERSION}"
git push --prune --tags
}
##
# Run
##
update_version
git_push
git_add_tag