{"id":17195407,"url":"https://github.com/ianpurvis/heroku-buildpack-version","last_synced_at":"2025-04-13T19:32:18.829Z","repository":{"id":31884960,"uuid":"35453629","full_name":"ianpurvis/heroku-buildpack-version","owner":"ianpurvis","description":"Heroku buildpack that compiles a profile.d script for the SOURCE_VERSION environment variable.","archived":false,"fork":false,"pushed_at":"2019-09-12T17:37:45.000Z","size":12,"stargazers_count":19,"open_issues_count":0,"forks_count":40,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-07T03:02:03.148Z","etag":null,"topics":["buildpack","heroku","heroku-buildpacks","version"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ianpurvis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-11T22:33:20.000Z","updated_at":"2022-08-11T18:23:48.000Z","dependencies_parsed_at":"2022-09-10T16:20:52.216Z","dependency_job_id":null,"html_url":"https://github.com/ianpurvis/heroku-buildpack-version","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianpurvis%2Fheroku-buildpack-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianpurvis%2Fheroku-buildpack-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianpurvis%2Fheroku-buildpack-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianpurvis%2Fheroku-buildpack-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ianpurvis","download_url":"https://codeload.github.com/ianpurvis/heroku-buildpack-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248768033,"owners_count":21158575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buildpack","heroku","heroku-buildpacks","version"],"created_at":"2024-10-15T01:50:21.278Z","updated_at":"2025-04-13T19:32:18.589Z","avatar_url":"https://github.com/ianpurvis.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Source Version Buildpack\n==================\n\nAs a developer,  \nI want to display the source version of my app  \nso that the team can refer to it for QA.\n\n## Background\n\nWhen you push your source to Heroku, the repo is used for slug compilation and then purged before the app is deployed. Unfortunately this prevents you from using something like the following in your app code:\n\n\tversion = `git rev-parse --short HEAD`\n\nSo, let's capture the information during slug compilation. Heroku provides the [SOURCE_VERSION](https://devcenter.heroku.com/changelog-items/630) environment variable as a nice SCM-agnostic way to do this. We can use a buildpack to create a [profile.d](https://devcenter.heroku.com/articles/profiled) script that will export SOURCE_VERSION into the app runtime environment.\n\n## Usage\n\nFirst thing, add the buildpack to your app:\n\n\t$ heroku buildpacks:add https://github.com/ianpurvis/heroku-buildpack-version\n\nDuring your next deployment, the buildpack will generate the environment configuration script:\n\n\t-----\u003e Fetching custom git buildpack... done\n\t-----\u003e Source app detected\n\t-----\u003e Creating profile.d script\n\t       SOURCE_VERSION: d9f63da90bc76ee878a0e9a54d9e85db7da4a52b\n\t       Script installed to .profile.d/source_version.sh\n\nThe script itself is simple, just a single export statement with default expansion: \n\n\texport SOURCE_VERSION=${SOURCE_VERSION:-f5efc0615dbd0f64f718e142bad858b8e1cf59bb}\n\nNote the expansion syntax ':-' ensures that any existing value is not overidden.\n\nIn dev environments, scripting `git rev-parse` is still probably the most convenient way to get your current source version. For easy portablity, you can cascade the initialization:\n\n\tversion = ENV['SOURCE_VERSION'] || `git rev-parse HEAD`.presence || '1.0'\n\n## Links\n\n- [Heroku Buildpacks](http://devcenter.heroku.com/articles/buildpacks)\n- [Buildpack API](https://devcenter.heroku.com/articles/buildpack-api)\n- [SOURCE_VERSION](https://devcenter.heroku.com/changelog-items/630)\n- [Default Config Values](https://devcenter.heroku.com/articles/buildpack-api#default-config-values)\n\n\n## License\nThe pack is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n[![https://purvisresearch.com](logo.svg)](https://purvisresearch.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianpurvis%2Fheroku-buildpack-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianpurvis%2Fheroku-buildpack-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianpurvis%2Fheroku-buildpack-version/lists"}