Skip to content
Snippets Groups Projects
package 2.69 KiB
Newer Older
James Long's avatar
James Long committed
#!/bin/bash -e


ROOT=`dirname $0`
VERSION=""
BETA=""
RELEASE=""
RELEASE_NOTES=""
CI=${CI:-false}
James Long's avatar
James Long committed

cd "$ROOT/.."

POSITIONAL=()
while [[ $# -gt 0 ]]; do
  key="$1"

  case $key in
      --version)
      VERSION="$2"
      shift
      shift
      ;;
      --beta)
      RELEASE="beta"
      shift
      ;;
      --release)
      RELEASE="production"
      shift
      ;;
      *)
      POSITIONAL+=("$1")
      shift
      ;;
  esac
done
set -- "${POSITIONAL[@]}"

if [ -z "$VERSION" ] && [ -n "$RELEASE" ]; then
    echo "Version is required if making a release"
    exit 1
fi

if [ -n "$RELEASE" ]; then
    if [ -z "$CIRCLE_TAG" ]; then
        read -p "Make release: $RELEASE v$VERSION? [y/N] " -r
        if [ -z "$REPLY" ] || [ "$REPLY" != "y" ]; then
            exit 2
        fi
    fi

    if [ "$RELEASE" == "production" ]; then
        if [ -z "$CIRCLE_TAG" ]; then
            RELEASE_NOTES=`git tag -l --format="%(contents:subject)" "$VERSION"`
        else
            RELEASE_NOTES=`git tag -l --format="%(contents:subject)" "$CIRCLE_TAG"`
        fi
    fi

    PACKAGE_VERSION=`node -p -e "require('./packages/desktop-electron/package.json').version"`
    if [ "$VERSION" != "$PACKAGE_VERSION" ]; then
        echo "Version in desktop-electron/package.json does not match given version! ($PACKAGE_VERSION)"
        exit 4
    fi
fi

if [ "$OSTYPE" == "msys" ]; then
James Long's avatar
James Long committed
        read -s -p "Windows certificate password: " -r CSC_KEY_PASSWORD
        export CSC_KEY_PASSWORD
    elif [ -n "$CIRCLE_TAG" ]; then
        # We only want to run this on CircleCI as Github doesn't have the CSC_KEY_PASSWORD secret set.
James Long's avatar
James Long committed
        certutil -f -p ${CSC_KEY_PASSWORD} -importPfx ~/windows-shift-reset-llc.p12
    fi
fi

# We only need to run linting once (and this doesn't seem to work on
# Windows for some reason)
if [[ $CI != true && "$OSTYPE" == "darwin"* ]]; then
James Long's avatar
James Long committed
    yarn lint
fi

yarn patch-package

yarn workspace loot-core build:node

yarn workspace @actual-app/web build

yarn workspace Actual update-client
James Long's avatar
James Long committed

(
    cd packages/desktop-electron;
James Long's avatar
James Long committed

    export npm_config_better_sqlite3_binary_host="https://static.actualbudget.com/prebuild/better-sqlite3"

    if [ "$RELEASE" == "production" ]; then
        if [ -f ../../.secret-tokens ]; then
            source ../../.secret-tokens
        fi
        yarn build --publish always -c.releaseInfo.releaseNotes="$RELEASE_NOTES" --arm64 --x64
James Long's avatar
James Long committed

        echo "\nCreated release $VERSION with release notes \"$RELEASE_NOTES\""
    elif [ "$RELEASE" == "beta" ]; then
        yarn build --publish never --arm64 --x64
        
        echo "\nCreated beta release $VERSION"
James Long's avatar
James Long committed
    else
        SKIP_NOTARIZATION=true yarn build --publish never --x64
James Long's avatar
James Long committed
    fi
)