-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_version.sh
executable file
·72 lines (53 loc) · 2.24 KB
/
new_version.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
72
#!/bin/bash
newVersion=$2
# Get the last branch
lastGitBranch=$1
# Checkout it
git checkout $lastGitBranch
rm -rf cli/js/*
wget -P cli/js/ "https://raw.githubusercontent.com/denoland/deno/v${newVersion}/cli/js/lib.deno.ns.d.ts"
wget -P cli/js/ "https://raw.githubusercontent.com/denoland/deno/v${newVersion}/cli/js/lib.deno.shared_globals.d.ts"
wget -P cli/js/ "https://raw.githubusercontent.com/denoland/deno/v${newVersion}/cli/js/lib.deno.window.d.ts"
wget -P cli/js/ "https://raw.githubusercontent.com/denoland/deno/v${newVersion}/cli/js/lib.deno.worker.d.ts"
# Create and checkout a new branch
git checkout -b $newVersion
# Add modified files to commit
git add cli/js
# Commit
git commit -m "deno version ${newVersion}"
## Save the stats
diffStat=`git --no-pager diff HEAD~1 --shortstat`
# Print diff
git --no-pager diff HEAD~1
# Print all branches (inspired from the oh-my-zsh shortcut: "glola")
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
# Ask for confirmation before pushing
echo -e "\nIs that OK ? (Yn)"
read confirmation
if [ -z $confirmation ] || [ $confirmation = "y" ] || [ $confirmation = "Y" ]
then
echo -e "Push branch..."
# Push the branch
git push origin $newVersion
fi
# Come back to master branch
git checkout master
# Update README.md
diffUrl="[${lastGitBranch}...${newVersion}](https://github.com/denodev/deno_api_diff/compare/${lastGitBranch}...${newVersion})"
patchUrl="[${lastGitBranch}...${newVersion}](https://github.com/denodev/deno_api_diff/compare/${lastGitBranch}...${newVersion}.diff)"
# Insert a row in the version table
## Insert a new line (a bit tricky but compatible with either OSX sed and GNU sed)
sed -i '' 's/----|----|----|----/----|----|----|----\
NEWLINE/g' README.md
## Edit the new line with the version info
sed -i "" "s@NEWLINE@${newVersion}|${diffUrl}|${patchUrl}|${diffStat}@" README.md
# Ask for confirmation before pushing master
echo -e "\nDo push master branch automatically? (Yn)"
read confirmation
if [ -z $confirmation ] || [ $confirmation = "y" ] || [ $confirmation = "Y" ]
then
git commit -a -m 'add deno version ${newVersion}'
echo -e "Push branch..."
# Push the branch
git push origin master
fi