Skip to content

Commit

Permalink
Update build.sh and release.sh (#72)
Browse files Browse the repository at this point in the history
Closes #57 and changes release.sh to create only one commit
  • Loading branch information
zuphilip authored and dstillman committed Feb 27, 2018
1 parent a46e0d7 commit b3ed511
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

buildDir="build"
rm -rf "$buildDir"
mkdir "$buildDir"
Expand Down
45 changes: 35 additions & 10 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ cat "$changeLog" >> "$tempFile2"
rm "$tempFile"
mv "$tempFile2" "$changeLog"

git commit -m "Update change log" "$changeLog" 1>&2
git add "$changeLog"

##############
## Update install.rdf
##############
installRDF="$srcPath/install.rdf"

minVersion="`grep -o -P -e '(?<=<em:minVersion>)[^<]+' $installRDF`"
minVersion=`perl -ne 'print m/<em:minVersion>([^<]+)/;' $installRDF`
newMinVersion=""
read -p "Update minVersion? [$minVersion] " newMinVersion

maxVersion="`grep -o -P -e '(?<=<em:maxVersion>)[^<]+' $installRDF`"
maxVersion=`perl -ne 'print m/<em:maxVersion>([^<]+)/;' $installRDF`
newMaxVersion=""
read -p "Update maxVersion? [$maxVersion] " newMaxVersion

Expand All @@ -53,14 +53,13 @@ if [ -z "$newMaxVersion"]; then
newMaxVersion="$maxVersion"
fi

sed -i.bak "s/<em:version>[^<]*/<em:version>$version/; \
s/<em:minVersion>[^<]*/<em:minVersion>$newMinVersion/; \
s/<em:maxVersion>[^<]*/<em:maxVersion>$newMaxVersion/" \
"$installRDF"
# Some SED versions require an extension, but we don't need a backup
perl -pi -e "s/<em:version>[^<]*/<em:version>$version/;" \
-e "s/<em:minVersion>[^<]*/<em:minVersion>$newMinVersion/;" \
-e "s/<em:maxVersion>[^<]*/<em:maxVersion>$newMaxVersion/;" \
$installRDF
rm "$installRDF.bak"

git commit -m "Update versions in install.rdf" "$installRDF" 1>&2
git add "$installRDF"

##############
## Create tag
Expand All @@ -70,4 +69,30 @@ git tag "v$version"
##############
## Build XPI file
##############
./build.sh "$version"
./build.sh "$version"

# Cygwin has sha1sum, macOS has shasum, Linux has both
if [[ -n "`which sha1sum 2> /dev/null`" ]]; then
SHACMD="sha1sum"
else
SHACMD="shasum"
fi
SHA1=`$SHACMD build/scaffold-$version.xpi | cut -d' ' -f1`


##############
## Update docs/ for Github Pages
##############

perl -pi -e "s/<em:version>[^<]*/<em:version>$version/;" \
-e "s/<em:updateLink>[^<]*/<em:updateLink>https:\/\/github.com\/zotero\/scaffold\/releases\/download\/v$version\/scaffold-$version.xpi/;" \
-e "s/sha1:/sha1:$SHA1/g;" \
-e "s/<em:updateInfoURL>[^<]*/<em:updateInfoURL>https:\/\/github.com\/zotero\/scaffold\/releases\/tag\/v$version/;" \
docs/scaffold.rdf
git add "docs/scaffold.rdf"

##############
## Commit everything
##############

git commit -m "Release $version" 1>&2

0 comments on commit b3ed511

Please sign in to comment.