From time to time, or whenever an important and needed code change is made, the principle maintainer of the BETYdb Rails application should issue a new release and upgrade all of the sites under his or her purview. In what follows, we delineate the key steps in this process.
Begin a new release by visiting the Web page https://github.com/PecanProject/bety/releases and clicking the Draft a new release button. The begin writing release notes in the large textarea box.
The release notes should begin with a one-line summary of the release, written as a level-one heading (that is, with one "#" mark flush left). Follow this with a paragraph describing the release in slightly greater detail.
Subsequent sections should summarize new features, bug fixes, and give some instruction to site maintainers on doing an upgrade to the new release.
An easy way to begin writing release notes is to use an earlier version's release notes (perhaps the notes from the previous one) as a template. Just click on the Releases link, click the Edit button of the release you choose to be you model, copy the text from the description section to the clipboard, and paste it into the description section for the release you are creating. Then change the text of each section as appropriate.
To remind oneself of what changes to the code have been made since the previous release, you can examine the Git log content starting with the previous release using (for example) the command
git log betydb_x.xx..master --stat
betydb_x.xx is assumed to be the tag name for the previous release. The
--stat flag is used to include a list of each file that was changed in each update.)
Once the release notes are written, it remains only to fill in the release title and tag name text boxes and click the Publish Release button. But these final steps should be delayed until at least the primary site, https://www.betydb.org/, has been upgraded, especially if the release involves a database migration. We give more details about this below. For now, just click the Save draft button to ensure your release notes don't disappear.
Note: Although these instructions are specific to the primary production site, https://www.betydb.org, upgrading the beta site before upgrading the production site is highly recommended. If there are serious problems with the pending release version, it is much easier if they are found while upgrading a test version of the site so as not to have to try to back out of an upgrade to the production site. Moreover, upgrading the beta site can serve as a trial run for upgrading the production site.
Note the following modification of the steps below when upgrading the beta site:
After logging in to
Making a backup copy of the database is unnecessary.
Important If a migration is done, do not commit the updated
production_structure.sqlto the Git repository. It is the structure of the canonical copy of the database—ebi_production—that we want to document. While it is likely that the structure of the beta site's database and the structure of the production site's database are identical, it is best not to rely on this.
Here are the steps required to upgrade the primary BETYdb Rails site to a newly-released version. These step are roughly the same for all the sites to be upgraded, but there are some slight differences, which we shall make note of where appropriate.
Log in to the host machine ebi-forecast.igb.illinois.edu:
ssh -X ebi-forecast.igb.illinois.edu
Go to the Rails root directory for the EBI site:
Check the git status to be sure the copy is "clean":
Generally there shouldn't be any modified files and you should be on the master branch.
Get the latest code from Github:
In rare cases, it may be that you need to release and deploy a version of the code other than the head of the master branch. This should be avoided if at all possible, especially if the release contains one or more migrations: it complicates incorporating an up-to-date version of the
production_structure.sql into the release. Note that we tag releases AFTER deploying them, so we can't use the release tag as the git reference.
git checkout <git reference to version being deployed>
Check the gem bundle and install new Gems if needed:
If the the bundle contains uninstalled Gems, run this:
Check for pending migrations and if needed, migrate the database:
bundle exec rake db:migrate:status RAILS_ENV=production
If there are no pending migrations, skip to the testing step.
Make a backup copy of the database:
pg_dump ebi_production > [some suitable directory]/ebi_production.psql
Generally, after the dump file has been created, I rename it to include the timestamp information in the file name: ebi_production_YYYYMMDDhhmm.psql. This way multiple dump files can be stored in the same directory.)
Perform the pending migrations:
bundle exec rake db:migrate RAILS_ENV=production
It is especially important to dump the database if any of the pending migrations will delete data!
Generate an up-to-date copy of
db/production_structure.sql and check it in:
bundle exec rake db:structure:dump RAILS_ENV=productiongit add db/production_structure.sqlgit commitgit push
Run automated tests:
bundle exec rake db:test:preparebundle exec rake db:fixtures:load RAILS_ENV=testbundle exec rspec -t ~jsbundle exec rspec -t js
The two rspec lines can be combined (just
-X option when ssh-ing into the production server. For more information about automated tests, see Automated Tests.
If the tests pass, restart the Rails server:
Visit the updated site in a browser.
This is to ensure the site is up and running. You may also wish to check some of the changes the upgrade is meant to implement to make sure they are working as expected.
The steps for upgrading other production sites is largely the same as for the primary site https://www.betydb.org.
[To do: add details]
Now that the release has been deployed, you can finish the formal release on GitHub. Go to the releases list at https://github.com/PecanProject/bety/releases and click on the draft that you started earlier. Give the release a title of the form "BETYdb X.XX" or "BETYdb X.XX.XX" and a Tag version identifier of the form "betydb_X.XX" (or "betydb_X.XX.XX") and click the Publish release button. (See Version Numbering below.)
I usually announce a new release on the Gitter chat page for BETYdb at https://gitter.im/PecanProject/bety?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge. Include a link to the release notes in your announcement.
We loosely follow semantic versioning.
Any tag of the form betydb_x.x or betydb_x.x.x refers to a version that has been tested and deployed.
Changes in the first or second digit of the version number mark some
significant change. For example, the change to major version number
2.x marks the change to a new user interface.