-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·53 lines (40 loc) · 1.06 KB
/
deploy.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
#!/bin/bash
SOURCE_BRANCH=$(git branch --show-current)
TARGET_BRANCH="release"
VERSION=$1
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
MINOR=$(echo "$VERSION" | cut -d '.' -f 1-2)
TAGS=("$MAJOR" "$MINOR" "$VERSION")
if [ -z $VERSION ];
then
echo "Version must be specified."
exit
fi
echo "Clearing all changes..."
git checkout .
echo "Saving dist files..."
git add -f dist/ \
&& git stash push dist/
echo "Checking out '$TARGET_BRANCH'..."
git checkout "$TARGET_BRANCH" \
|| exit 1
echo "Removing all extra files..."
git rm -rf . \
&& rm -rf node_modules
echo "Copying files from '${SOURCE_BRANCH}' to '${TARGET_BRANCH}'"
git checkout "${SOURCE_BRANCH}" action.yml package.json package-lock.json
echo "Restoring dist files..."
git stash pop
echo "Adding files..."
git add -vA
echo "Committing files..."
git commit -vm "Deploy $VERSION"
for tagVersion in ${TAGS[@]}; do
TAG="v${tagVersion}-dist"
echo "Adding tag: '${TAG}'"
git tag --force "$TAG"
done
echo "Pushing commit..."
git push origin -u "${TARGET_BRANCH}" \
&& git push --force --tags \
|| exit 1