forked from iansinnott/date-fns-dash-docset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·63 lines (49 loc) · 1.39 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -eo pipefail
publish() {
if [[ ! -d "$1" ]]; then
echo "$1 is not a directory. Provide the local location of the Dash-User-Contributions repository as the first arg"
return 99;
fi
local version=$(node -e 'process.stdout.write(require("./dist/docset.json").version)')
echo "Tagging git..."
git add . && git commit -m "Update: v$version"
git tag "v$version" -m "v$version"
git push && git push --tags
echo "Publishing date-fns v$version..."
local source_dir=$PWD
local target_dir=$1
local git_user=$(git config --global user.username)
# Make sure my remote is up to date
echo
echo "Entering target dir: $target_dir"
cd $target_dir
echo
echo "Making sure the repo is up to date"
git checkout master
git pull
git push $git_user master
git checkout -b date-fns-$version
# Ensure the dir is present and empty
mkdir -p docsets/date-fns
rm -rf docsets/date-fns/*.*
# Copy files
echo
echo "Copying files to publish"
cp -R $source_dir/dist/*.* docsets/date-fns/
# Commit and PR the changes
echo
echo "Git versioning"
git add . && git commit -m "date-fns v$version"
git push -u $git_user date-fns-$version
if [[ ! -x $(which hub) ]]; then
hub pull-request -m "date-fns v$version"
else
echo "Hub not found. Hub is needed for automatic pull requests."
fi
# Restor dir
echo
echo "Restoring previous directory: $source_dir"
cd $source_dir
}
publish "$@"