Skip to content
Snippets Groups Projects
build 2.22 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/usr/bin/env bash
    
    
    MB_EDITION=${MB_EDITION:=oss}
    
    
    if [ "$MB_EDITION" != ee ] && [ "$MB_EDITION" != oss ]; then
        echo "MB_EDITION must be either 'ee' or 'oss'."
        exit 1
    fi
    
    
    # Generate the resources/version.properties file
    version() {
    
        VERSION_INFO=$(./bin/version)
    
    Tom Robinson's avatar
    Tom Robinson committed
        IFS=', ' read -a info <<< ${VERSION_INFO}
    
    Tom Robinson's avatar
    Tom Robinson committed
        echo "Tagging uberjar with version '$VERSION_INFO'..."
    
    Tom Robinson's avatar
    Tom Robinson committed
        # Ok, now generate the appropriate version.properties file.
        echo "tag=${info[0]}" > resources/version.properties
        echo "hash=${info[1]}" >> resources/version.properties
        echo "branch=${info[2]}" >> resources/version.properties
        echo "date=${info[3]}" >> resources/version.properties
    
    frontend-deps() {
        echo "Running 'yarn' to download javascript dependencies..." &&
        yarn
    
        echo "Running 'webpack' with NODE_ENV=production assemble and minify frontend assets..." &&
        NODE_ENV=production ./node_modules/.bin/webpack --bail
    
    frontend-fast() {
    
        echo "Running 'webpack' with NODE_ENV=development to assemble frontend assets..." &&
        NODE_ENV=development ./node_modules/.bin/webpack --bail --devtool eval
    
    translations() {
    
        echo "Running './bin/i18n/build-translation-resources' to build translation resources..."
        if ! ./bin/i18n/build-translation-resources; then
          echo "Building translation resources failed, please install 'gettext', or build without translations by running './bin/build no-translations'."
          exit 1
        fi
    }
    
    
    drivers() {
        echo "Building Metabase drivers..."
    
    uberjar() {
    
        echo "Running 'lein with-profile +$MB_EDITION uberjar'..."
        lein with-profile +$MB_EDITION uberjar
    
        version && translations && frontend && drivers && uberjar
    
    # Default to running all but let someone specify one or more sub-tasks to run instead if desired
    # e.g.
    # ./bin/build                  # do everything
    # ./bin/build version          # just update version.properties
    # ./bin/build version uberjar  # just update version.properties and build uberjar
    if [ "$1" ]; then
        for cmd in "$@"; do
            $cmd
        done
    else
        all
    fi