#!/bin/sh

PRIVATE_KEY=../../blockstorage_dev_private.pem
PUBLIC_KEY=./blockstorage_dev_public.pem

APP_VER=$(grep -m1 -a version package.json|sed -e "s/\"//g" -e "s/version: //g" -e "s/,//g" -e "s/ //g")
OUT_FILE=repertory-ui_${APP_VER}_linux_x86_64.AppImage

if npm run dist; then
  cd dist
  echo "Signing Installation [${OUT_FILE}]"
  sha256sum -b ${OUT_FILE} > ${OUT_FILE}.sha256
  openssl dgst -sha256 -sign "${PRIVATE_KEY}" -out "${OUT_FILE}.sig" "${OUT_FILE}"
  base64 "${OUT_FILE}.sig" > "${OUT_FILE}.sig.b64"
  cd -
fi
