1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +01:00
bitwarden-desktop/scripts/cask-update.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2018-02-20 05:35:43 +01:00
#!/usr/bin/env bash
2018-02-20 04:52:12 +01:00
set -e
2018-02-20 16:15:44 +01:00
# Dependencies:
# 1. brew install jq
# 2. fork of homebrew-cask repo setup.
# see https://github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md#getting-set-up-to-contribute
2018-04-20 02:28:35 +02:00
#
# To run:
# sh ./cask-update.sh
#
# then submit PR from fork repo
2018-02-20 04:50:16 +01:00
2018-02-20 16:15:44 +01:00
FORK_GITHUB_USER="kspearrin"
2018-02-20 04:50:16 +01:00
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2018-02-20 16:15:44 +01:00
PWD_DIR="$(pwd)"
2018-02-20 04:50:16 +01:00
ROOT_DIR="$DIR/.."
DIST_DIR="$ROOT_DIR/dist"
CASK_DIR="$ROOT_DIR/stores/homebrew-cask"
DIST_CASK_DIR="$DIST_DIR/homebrew-cask"
2018-02-20 16:15:44 +01:00
GIT_CASKS_DIR=""$(brew --repository)"/Library/Taps/caskroom/homebrew-cask/Casks"
2018-02-20 04:50:16 +01:00
2018-02-20 05:33:43 +01:00
if [ -d "$DIST_CASK_DIR" ]
2018-02-20 04:50:16 +01:00
then
rm -rf $DIST_CASK_DIR
fi
2018-02-20 05:33:43 +01:00
cp -r $CASK_DIR $DIST_DIR
2018-02-20 04:50:16 +01:00
SRC_PACKAGE="$ROOT_DIR/src/package.json";
2018-02-20 05:33:43 +01:00
SRC_PACAKGE_VERSION=$(jq -r '.version' $SRC_PACKAGE)
2018-02-20 04:50:16 +01:00
2018-02-20 05:33:43 +01:00
ZIP="$DIST_DIR/Bitwarden-$SRC_PACAKGE_VERSION-mac.zip"
CHECKSUM=($(shasum -a 256 $ZIP))
CHECKPOINT=$(brew cask _appcast_checkpoint --calculate "https://github.com/bitwarden/desktop/releases.atom")
2018-02-20 04:50:16 +01:00
RB="$DIST_CASK_DIR/bitwarden.rb"
2018-02-20 05:33:43 +01:00
RB_NEW="$DIST_CASK_DIR/bitwarden.rb.new"
2018-02-20 04:50:16 +01:00
2018-02-20 05:33:43 +01:00
sed -e 's/__version__/'"$SRC_PACAKGE_VERSION"'/g; s/__checksum__/'"$CHECKSUM"'/g; s/__checkpoint__/'"$CHECKPOINT"'/g' $RB > $RB_NEW
mv -f $RB_NEW $RB
2018-02-20 16:15:44 +01:00
cd $GIT_CASKS_DIR
git checkout master
git pull
git reset --hard origin/master
git push $FORK_GITHUB_USER master
git push -d $FORK_GITHUB_USER bitwarden || true
git branch -D bitwarden || true
git checkout -b bitwarden
GIT_CASKS_RB="$GIT_CASKS_DIR/bitwarden.rb"
cp $RB $GIT_CASKS_RB
git add $GIT_CASKS_RB
git commit -m "Update Bitwarden.app to v$SRC_PACAKGE_VERSION"
git push $FORK_GITHUB_USER bitwarden
cd $PWD_DIR