forked from glacambre/firenvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·126 lines (104 loc) · 4.05 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh -e
if ! [ -e ./package.json ] ; then
echo "Not in firenvim repository. Aborting."
exit 1
fi
if [ "$1" = "" ] ; then
echo "No new version specified. Aborting."
exit 1
fi
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
echo "Not on master. Aborting."
exit 1
fi
if ! git diff --quiet --exit-code ; then
echo "Git working directory unclean. Aborting."
exit 1
fi
if ! git diff --cached --quiet --exit-code ; then
echo "Git staged area unclean. Aborting."
exit 1
fi
git fetch origin master
if ! git diff --quiet --exit-code origin/master ; then
echo "Local master is different from origin master. Aborting"
exit 1
fi
newMajor="$(echo "$1" | cut -d. -f1)"
newMinor="$(echo "$1" | cut -d. -f2)"
newPatch="$(echo "$1" | cut -d. -f3)"
oldVersion="$(grep '"version": "\(.\+\)"' package.json | grep -o '[0-9.]\+')"
oldMajor="$(echo "$oldVersion" | cut -d. -f1)"
oldMinor="$(echo "$oldVersion" | cut -d. -f2)"
oldPatch="$(echo "$oldVersion" | cut -d. -f3)"
if [ "$oldMajor" = "$newMajor" ] ; then
if [ "$oldMinor" = "$newMinor" ] ; then
if [ "$((oldPatch + 1))" != "$newPatch" ] ; then
echo "New version has same minor and major but patch doesn't follow."
exit 1
fi
elif [ "$((oldMinor + 1))" -eq "$newMinor" ] ; then
if [ "$newPatch" != 0 ] ; then
echo "New version has new minor but patch isn't 0."
exit 1
fi
else
echo "New version has same major but minor doesn't follow."
exit 1
fi
elif [ "$((oldMajor + 1))" -eq "$newMajor" ] ; then
if [ "$newMinor" != 0 ] ; then
echo "New version has new major but minor isn't 0."
exit 1
fi
if [ "$newPatch" != 0 ] ; then
echo "New version has new major but patch isn't 0."
exit 1
fi
else
echo "New version doesn't follow previous one."
exit 1
fi
oldVersion="$oldMajor.$oldMinor.$oldPatch"
newVersion="$newMajor.$newMinor.$newPatch"
echo "Updating firenvim from v$oldVersion to v$newVersion."
# First, edit package info
sed -i "s/\"version\": \"$oldVersion\"/\"version\": \"$newVersion\"/" package.json
# Then, do manual update/editing
npm ci
# Make sure none of the files have changed, except for package-lock.json
if [ "$(git diff --name-only | grep -v "package\(-lock\)\?.json")" != "" ] ; then
echo "Some files have been modified. Aborting."
exit 1
fi
# npm run test takes care of building the extension in test mode
npm run test-firefox
npm run test-chrome
# now we need a release build
npm run build
# lint firefox add-on to make sure we'll be able to publish it
npm run lint
# Prepare commit message
COMMIT_TEMPLATE="/tmp/firenvim_release_message"
echo "package.json: bump version $oldVersion -> $newVersion" > "$COMMIT_TEMPLATE"
echo "" >> "$COMMIT_TEMPLATE"
git log --pretty=oneline --abbrev-commit --invert-grep --grep='dependabot' "v$oldVersion..HEAD" >> "$COMMIT_TEMPLATE"
# Everything went fine, we can commit our changes
git add package.json package-lock.json
git commit -t "$COMMIT_TEMPLATE"
git tag --delete "v$newVersion" 2>/dev/null || true
git tag "v$newVersion"
# Add finishing touches to chrome manifest
sed 's/"key":\s*"[^"]*",//' -i target/chrome/manifest.json
# Generate bundles that need to be uploaded to chrome/firefox stores
rm -f target/chrome.zip
zip --junk-paths target/chrome.zip target/chrome/*
git archive "v$newVersion" > target/firenvim-firefox-sources.tar
gzip target/firenvim-firefox-sources.tar
# Everything went fine, we can push
git push
git push --tags
gh release create "$newVersion" target/chrome.zip target/xpi/firefox-latest.xpi
firefox --private-window 'https://chrome.google.com/webstore/devconsole/g06704558984641971849/egpjdkipkomnmjhjmdamaniclmdlobbo/edit?hl=en'
sleep 1
firefox --private-window 'https://addons.mozilla.org/en-US/developers/addon/firenvim/versions/submit/'