{"id":17681265,"url":"https://github.com/hugopl/version_from_shard","last_synced_at":"2025-07-23T06:03:25.290Z","repository":{"id":143004451,"uuid":"218131649","full_name":"hugopl/version_from_shard","owner":"hugopl","description":"A macro to declare the VERSION constant from the value found in shard.yml, so you don't need to write the same version number in multiple places.","archived":false,"fork":false,"pushed_at":"2023-04-19T20:08:30.000Z","size":19,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T23:13:02.777Z","etag":null,"topics":["crystal","versioning"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/hugopl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-28T19:44:59.000Z","updated_at":"2022-07-21T18:01:19.000Z","dependencies_parsed_at":"2024-10-24T10:56:05.281Z","dependency_job_id":"525ee100-9429-4f3b-8e0a-5ccdfafa2e52","html_url":"https://github.com/hugopl/version_from_shard","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/hugopl/version_from_shard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugopl%2Fversion_from_shard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugopl%2Fversion_from_shard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugopl%2Fversion_from_shard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugopl%2Fversion_from_shard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugopl","download_url":"https://codeload.github.com/hugopl/version_from_shard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugopl%2Fversion_from_shard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266626115,"owners_count":23958344,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["crystal","versioning"],"created_at":"2024-10-24T09:10:40.339Z","updated_at":"2025-07-23T06:03:25.263Z","avatar_url":"https://github.com/hugopl.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/hugopl/version_from_shard/actions/workflows/ci.yml/badge.svg?branch=master)\n\n# Version From Shard\n\nA macro to declare the VERSION constant from the value found in `shard.yml`, so you don't need to write the same version number in multiple places.\n\n*⚠ Words of advise ⚠*\n\nI had been using this shard in multiple projects of mine, however nowadays I see that is more pratical to just do:\n\n```Crystal\nmodule MyShard\n  VERSION = {{ `shards version \"#{__DIR__}\"`.chomp.stringify }}\nend\n```\n\nThe only difference is that you wont have the in between version numbers like `1.0.0+1.g2dd5299`, however for the sake of having less dependencies in my projects I'm starting to remove this dependency from all my projects.\n\nWhat's this means? This means that soon this project will be archived in github. \n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     version_from_shard:\n       github: hugopl/version_from_shard\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n\n```crystal\nrequire \"version_from_shard\"\n\nmodule MyAwesomeApp\n  VersionFromShard.declare\nend\n\nputs MyAwesomeApp::VERSION # Should print the version value found in shard.yml, e.g. \"1.0.0\"\n```\n\nIf you are developing a library is necessary to pass \\_\\_DIR__ to the declare macro, otherwise when compiling a\napplication using your library it will show the version of the application instead the version of your library.\nSo, on libraries do:\n\n```crystal\nmodule MyAwesomeLib\n  VersionFromShard.declare(__DIR__)\nend\n\n# Then, the App code can safely do:\nputs \"Awesome app v#{MyAwesomeApp::VERSION} using awesome lib v#{MyAwesomeLib::VERSION}\"\n```\n\nWhen compiling a development version, i.e. not a tagged commit, the version will try to\nuse `git describe --tags` output (ignoring tag prefixes) for the version string. If git isn't\nfound or someone is compiling the project from a tarball, normal version will be used.\n\nExample:\n\nYou have `version: 1.0.0` on your shard.yml file but your master branch is 1 commit ahead of the tag named `v1.0.0` that you released yesterday, in this case VersionFromShard.declare will declare a VERSION constant with the value `1.0.0+1.g2dd5299`, assuming `2dd5299` is the current commit hash, note the `g` prefix, that means git.\n\n## About Semantic Version\n\n[This issue](https://github.com/semver/semver/issues/200) summarize the problems with semantic version and nightly builds\nwhen you don't know yet if the final version of your software will increase a major, minor or patch version.\n\n## Development\n\nSuggestions are welcome.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/hugopl/version_from_shard/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Hugo Parente Lima](https://github.com/hugopl) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugopl%2Fversion_from_shard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugopl%2Fversion_from_shard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugopl%2Fversion_from_shard/lists"}