├── README.md └── bin ├── compile ├── detect └── release /README.md: -------------------------------------------------------------------------------- 1 | # heroku-buildpacks-sourceversion 2 | Writes the SOURCE_VERSION variable (usually the Git SHA) to a file for use by the app. 3 | 4 | Created by @sreid out of the need to show which Git commit version of an app was running on a Heroku instance. Made possible by the [addition of the SOURCE_VERSION variable during the build process](https://devcenter.heroku.com/changelog-items/630). This variable is available during the build process, but not available to a running app, making this approach neccessary. Suggestions and improvements appreciated! 5 | 6 | ## Usage 7 | To use this buildpack, the app should already be successfully running the [multi buildpack](https://github.com/heroku/heroku-buildpack-multi). 8 | 9 | Then just add this buildpack in addition to the existing buildpacks in the `.buildpacks` file: 10 | 11 | https://github.com/sreid/heroku-buildpack-sourceversion.git 12 | 13 | In the application code, read the `.source_version` file that will be created on deployment. For example, in a Rails, it might look something like: 14 | 15 | git_sha = File.read(Rails.root.join('.source_version')) 16 | 17 | (add any error handling for environments where this file doesn't exist, such as your development machine, of course...) 18 | 19 | ## License 20 | MIT -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Syntax bin/compile 4 | 5 | BUILD_DIR=$1 6 | CACHE_DIR=$2 7 | 8 | echo "=====> Writing out SOURCE_VERSION to .source_version ($SOURCE_VERSION)" 9 | echo $SOURCE_VERSION > $BUILD_DIR/.source_version 10 | -------------------------------------------------------------------------------- /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 4 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exit 0 4 | --------------------------------------------------------------------------------