-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupdate.sh
101 lines (86 loc) · 3.36 KB
/
update.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
#!/usr/bin/env bash
# This file is part of pentadactyl-signed
#
# pentadactyl-signed is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# pentadactyl-signed is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2016, willsALMANJ
set -e
# Must run from directory containing script file
OS="$(uname)"
if [ $OS = "Linux" ] ; then
DIR="$( cd -P "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
elif [ $OS = "Darwin" ] ; then
FILEPATH=$(readlink "${BASH_SOURCE[0]}")
# Check exit status of readlink -- nonzero means BASH_SOURCE not a symlink
if [ $? != 0 ] ; then
FILEPATH="${BASH_SOURCE[0]}"
fi
DIR="$( cd -P "$(dirname "${FILEPATH}")" && pwd)"
fi
cd "$DIR"
# Set up variables
last_version="$(git tag | egrep '^[0-9]{4}[0-9]*$' | sort -n | tail -1)"
amo_secret="$(cat amo.secret)"
amo_key="$(cat amo.key)"
github_token="$(cat github.token)"
addon_id="$(cat addon_id.txt)"
github_user="$(cat github_user.txt)"
github_repo="$(cat github_repo.txt)"
# Update dactyl source
cd dactyl
# git reset --hard
# git checkout master
# git pull
# New version number
version=$(expr $last_version + 1)
version=7310
# Get max Firefox version
max_fx_version="$(python "${DIR}"/max_firefox_version.py)"
max_fx_version='56.*'
# Modify install.rdf to change id, update URL, and max Firefox version
sed -e 's/em:id="[email protected]"/em:id="'"$addon_id"'"/' \
-e 's#\(em:homepageURL.*\)#\1\n em:updateURL="https://raw.githubusercontent.com/'"$github_user"'/'"$github_repo"'/master/update.rdf"#' \
-e 's#\(em:name.*\)#em:name="PentadactylSigned"#' \
-e 's/em:maxVersion=".*"/em:maxVersion="'"$max_fx_version"'"/' \
-i pentadactyl/install.rdf
# Build xpi
mkdir -p downloads
rm -rf downloads/*
make -C pentadactyl xpi
cd downloads
mv pentadactyl*.xpi pentadactyl.xpi
# Set version string in install.rdf
unzip pentadactyl.xpi install.rdf
sed -i -e 's/em:version=".*"/em:version="'"$version"'"/' install.rdf
zip -u pentadactyl.xpi install.rdf
rm install.rdf
# Sign xpi with jpm
# Python wrapper makes sure the signed xpi file ends up at a known location
signed_xpi="pentadactyl-signed-$version.xpi"
python "${DIR}/amo_xpi_sign.py" -k "$amo_key" -s "$amo_secret" -x pentadactyl.xpi -o "$signed_xpi"
# Update update.rdf file
sed -e 's#<em:updateLink>.*</em:updateLink>#<em:updateLink>https://github.com/'"$github_user"'/'"$github_repo"'/releases/download/'"$version"'/'"$signed_xpi"'</em:updateLink>#' \
-e 's#em:version>.*</em#em:version>'"$version"'</em#' \
-e 's#em:maxVersion>.*</em#em:maxVersion>'"$max_fx_version"'</em#' \
-i "${DIR}/update.rdf"
# Push new update.rdf to GitHub
cd "${DIR}"
git commit -a -m "$version"
git push
git tag "$version"
git push --tags
# Upload xpi to GitHub as new release
python "${DIR}/github_release.py" --token "$github_token" --user "$github_user" \
--repo "$github_repo" --version "$version" --file "$signed_xpi" \
--content-type application/x-xpinstall