These instructions tell you how to create a new release of the
Ground2Cloud product, including packages for both the Windows G2C
Client(s) and Linux G2C server. Also included are means to create the
new "release" downloads on the g2c-releases repo, and notify clients by
creating an empty pull-request, whose Highlights will be included on the
next client notification email.

This walkthrough assumes that you are roughly familiar with how
Ground2Cloud works, and that you have checked out all 4 petit
repositories ([petit](https://github.com/cloud-elements/petit/),
[petit-gui](https://github.com/cloud-elements/petit-gui/),
[petit-linux](https://github.com/cloud-elements/petit-linux/), and
[petit-windows](https://github.com/cloud-elements/petit-windows/)), as
well as the Ground2Cloud release repo
([g2c-releases](https://github.com/cloud-elements/g2c-releases/)). The
walkthrough refers to the local path to these repos as (i.e.)
`/path/to/petit`, `/path/to/petit-gui` etc. You need write access to the
repos, and must have pulled the latest version(s) and made any local
changes that you wish to publish.

There are two types of releases here: the normal unbranded Ground2Cloud
release, and a customer-specific "branded imprint". Instructions for
both are presented here.

## To release a new unbranded version:

* Checkout the `master` branch in the petit, petit-gui, petit-linux, and
  petit-windows repos.

* Bump version numbers of petit (in `package.json`), petit-gui (also
  `package.json`), petit-linux (`resources/deb-src/DEBIAN/control`), and
  petit-windows (`resources/install*`, both for "define MyAppVersion"
  and in the "CompareVersion" argument of "[Code]:InitializeSetup").
  Remove any `displayVersion` properties.

* If you want, you can update the package dependencies for petit, by
  changing the `dependencies` property in the petit and petit-gui
  `package.json`, then `npm update` in those repos. (`npm install
  --save-exact` might help here.)

* If you upgraded the electron version, you should also use
  `electron-download` to download the correct windows versions:

        sudo -H npm install -g electron-download
        cd /path/to/petit-windows
        elec_vers=<whatever>
        for a in x86 x64 ; do
          arch=$a
          if [ $a == 'x86' ] ; then arch='ia32' ; fi
          rm -rf arch/$a/node_modules/electron-prebuilt
          cp -R /path/to/petit-gui/node_modules/electron-prebuilt \
                arch/$a/node_modules
          pushd arch/$a/node_modules/electron-prebuilt
          cat > path2.txt <<< 'dist/electron.exe'  # for win32 only
          tr -d '\n' < path2.txt > path.txt
          rm path2.txt
          pushd dist
          rm -rf *
          electron-download --version=$elec_vers --platform=win32 --arch=$arch
          ar=electron-v$elec_vers-win32-$arch.zip
          cp $HOME/.electron/$ar .
          unzip $ar
          rm $ar
          popd
          popd
        done

* Build petit with `node setup`.

* Switch to petit-gui and install petit with `npm install --save
  /path/to/petit`.

* Build petit-gui with `node setup`.

* Switch to petit-linux and install petit. Npm now uses symlinks with
  local folders, which can't be installed. Instead, use a pack pipe:

        cd program
        rm -rf node_modules
        npm install $(npm pack path/to/petit | tail -1)

* Build petit-linux (see its README), creating a
  `resources/petitserver*.deb` file.

* Switch to petit-windows and install petit and petit-gui with

        rm -rf node_modules
        npm install $(npm pack path/to/petit | tail -1)
        npm install $(npm pack path/to/petit-gui | tail -1)
        rm -rf node_modules/.bin

* Build petit-windows (see its README), creating one or more
  `Ground2Cloud*Setup.exe` files.

* Test that everything works.

* Reset the `dependencies.cloudelements-petit` property to "latest" in
  `petit-gui/package.json`, reverting the `--save` operation from
  earlier.

* Commit and tag the repos with the new version (i.e. `git tag -a 1.2.3 -m
  "Release 1.2.3"`).

* Publish only the petit repo via NPM (`npm publish`).

* Create and push an empty commit in the g2c-releases repo (to keep the
  release tags in the correct chronology) with e.g. `git commit
  --allow-empty -m 'Release v1.2.3'`).

* Create a new release in g2c-releases following these instructions:
  https://help.github.com/articles/creating-releases/, uploading all the
  `*.deb` and `*.exe` files created earlier. Use a tag name like
  `v1.2.3`.

* Create an empty commit / branch in soba. e.g.

        git checkout -b g2c-release develop
        git commit --allow-empty -m 'Add G2C release note'
        git push -u origin g2c-release

* Create an empty pull request in soba to merge in the new branch, and
  include the text "Released Ground2Cloud version v1.2.3 at
  https://github.com/cloud-elements/g2c-releases/releases/latest" in the
  Customer Highlights section. Assign to Travis.

## To release a new branded imprint:

A "branded imprint" is the normal Ground2Cloud client installer and
application, but with various portions (such as logos, color, text,
titles, version numbers, etc.) swapped out with customer assets, in
order to make it more consistent in look and feel with that customer's
other products.

An imprint has the same operational code as the Ground2Cloud version it
is based off, and communicates with the server as that version would.

To create an imprint, follow the unbranded instructions above, with the
following exceptions:

* Checkout or create the brand branch--usually named after the customer
  (e.g. `swiftpage`)--in the petit, petit-gui, and petit-windows repos.

* Merge everything from master to the brand branch.

* Create or copy branding changes (logos, text, etc) on that branch.

* In the `[client.vitae]` section of the petit-window's
  `resources/config*.toml` files, make sure that the "brand" property is
  set correctly. (e.g. `brand = "swiftpage"`)

* Keep the core G2C version (e.g. 1.2.3) in petit and petit-gui's
  `version` property (in `package.json`), but use the branded version
  (e.g. 1.0.1 for swiftpage) for the `displayVersion` property, and in
  petit-windows's `resources/install*`.

* When tagging, Don't use the unbranded tag: use a tag that contains the
  customer name and version (`git tag -a swiftpage-1.0.1 -m "Release
  1.0.1 for Swiftpage"`).

* *Don't* publish the petit repo in NPM.

* You don't need to create a `petitserver.deb` file out of the
  petit-linux repo: brands apply to client-side apps only.

* Neither create a separate release on the g2c-releases site, nor
  upload the branded `*.exe` files; branded releases should be
  distributed only to that customer. (Currently, I use a shared google
  docs folder to distribute the files.)

* Don't create a commit or pull request in soba: notify the customer
  directly that their new G2C imprint is ready.

