Using Travis CI to build and release simple plugins

From Koha Wiki
Jump to navigation Jump to search

Building and deploying simple plugins using Travis CI

There's a generic build mechanism described in another guide. This guide only works for REST API plugins and other plugins that don't serve static files to the user.

This mechanism uses the [CI built-in GitHub release system].

  1. Browse to https://travis-ci.org/ and connect your GitHub account to Travis CI.
  2. Set up Travis releases using the command line [client]: `travis setup releases`
    1. This will create a .travis.yml with an encrypted secret. Copy the file to a safe place.
  3. You will need to copy the following files from the REST DI plugin (replace .travis.yml created by the above step with this version):
    1. .travis.yml
    2. build.sh
  4. Edit .travis.yml and change the secret to your own (from the file created by `travis setup releases`).
  5. Edit build.sh and change PM_FILE and RELEASE_FILE to those matching your plugin.
  6. In your pm file:
    1. Replace the actual version with "{VERSION}", like so: our $VERSION = "{VERSION}";
    2. Change the date_updated to "1900-01-01", like so: date_updated => "1900-01-01",
  7. Commit the new files and changes to your module file.
  8. Tag the latest commit with a version tag such as v1.0.0: `git tag -a v1.0.0 -m "Release v1.0.0"`
  9. Push the commits and tags to GitHub (adjust as necessary): `git push --tags origin main`
  10. Wait a bit, within a minute or so you should see a build kick off on https://travis-ci.org/
  11. Once it has completed, check the releases page for your plugin on GitHub, you should now see a shiny new release!

Note that by default only the main branch is released. Adjust .travis.yml as necessary.

Any commit that isn't tagged will be built but not released. Thus it's safe to commit and push changes without accidentally creating a release.