Best way to have separate build processes for a staging environment and a production environment?

Hello all,

I’m new to Travis CI and I’m trying to wrap my head around creating an Electron build process for a staging environment and one for a production environment. The build processes are the same, but the environment variables are different. I would also like the option to trigger one but not the other at any given time. What’s the best way to do this?

Thanks in advance!

This sample .travis.yml config that I had in my GitHub repo’s may shed some light on your question. I’ll try and make some configs myself and share them with you later on this week.

The below example does use docker and wine as a side note.

matrix:
  include:
    - os: osx
      osx_image: xcode10.2
      language: node_js
      node_js: "12"
      env:
        - ELECTRON_CACHE=$HOME/.cache/electron
        - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder

    - os: linux
      services: docker
      language: generic

cache:
  directories:
    - node_modules
    - $HOME/.cache/electron
    - $HOME/.cache/electron-builder

script:
  - |
    if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      docker run --rm \
        --env-file <(env | grep -vE '\r|\n' | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
        -v ${PWD}:/project \
        -v ~/.cache/electron:/root/.cache/electron \
        -v ~/.cache/electron-builder:/root/.cache/electron-builder \
        electronuserland/builder:wine \
        /bin/bash -c "yarn --link-duplicates --pure-lockfile && yarn release --linux --win"
    else
      yarn release
    fi
before_cache:
  - rm -rf $HOME/.cache/electron-builder/wine

branches:
  except:
    - "/^v\\d+\\.\\d+\\.\\d+$/"
1 Like