{"id":24995971,"url":"https://github.com/fclairamb/ci-info","last_synced_at":"2025-04-12T04:34:04.286Z","repository":{"id":38359969,"uuid":"484853696","full_name":"fclairamb/ci-info","owner":"fclairamb","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-08T12:07:02.000Z","size":193,"stargazers_count":1,"open_issues_count":13,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T05:48:19.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fclairamb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-04-23T20:50:36.000Z","updated_at":"2023-09-05T13:56:37.000Z","dependencies_parsed_at":"2023-10-22T10:29:11.727Z","dependency_job_id":"5e21501e-b00f-456e-90ca-2371de77f935","html_url":"https://github.com/fclairamb/ci-info","commit_stats":{"total_commits":85,"total_committers":5,"mean_commits":17.0,"dds":0.5647058823529412,"last_synced_commit":"9bc87d7dd71166f8e1b16143132dcc02dbbb8393"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fci-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fci-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fci-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclairamb%2Fci-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fclairamb","download_url":"https://codeload.github.com/fclairamb/ci-info/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248517575,"owners_count":21117482,"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":[],"created_at":"2025-02-04T15:53:07.070Z","updated_at":"2025-04-12T04:34:04.258Z","avatar_url":"https://github.com/fclairamb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI Info\n\n[![Go version](https://img.shields.io/github/go-mod/go-version/fclairamb/ci-info)](https://golang.org/doc/devel/release.html)\n[![Release](https://img.shields.io/github/v/release/fclairamb/ci-info)](https://github.com/fclairamb/ci-info/releases/latest)\n[![Build](https://github.com/fclairamb/ci-info/workflows/Build/badge.svg)](https://github.com/fclairamb/ci-info/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/fclairamb/ci-info/branch/main/graph/badge.svg?token=Ajv8lfWGJy)](https://codecov.io/gh/fclairamb/ci-info)\u003c!--- [![gocover.io](https://gocover.io/_badge/github.com/fclairamb/ci-info)](https://gocover.io/github.com/fclairamb/ci-info) --\u003e\n[![Go Report Card](https://goreportcard.com/badge/fclairamb/ci-info)](https://goreportcard.com/report/fclairamb/ci-info)\n[![GoDoc](https://godoc.org/github.com/fclairamb/ci-info?status.svg)](https://godoc.org/github.com/fclairamb/ci-info)\n\n\nThis tool helps extract CI info and embed them in a resulting code (whether it's compiled or not).\n\n## Why\nAdding the CI info useful to identify what was used to build any app. Yet, doing it properly is boring.\n\n## How it works\nYou provide a template file and it will take care of writing the final file with the build information.\n\nThis makes it completely language-agnostic.\n\n## Very basic usage\nYou can also completely skip the templating system:\n```zsh\n% ci-info -b build.json -vf version.txt\n\n% cat build.json  \n{\n  \"ci_info_version\": \"0.1.0-feature-config-change-6ea1772\",\n  \"version\": \"0.1.0-feature-config-change-6ea1772\",\n  \"git_hash\": \"6ea17722aa995a6c69c67e833d3c5abee463f7da\",\n  \"git_date\": \"2022-09-10 22:51:17 +0200\",\n  \"git_branch\": \"feature/config-change\",\n  \"build_date\": \"2022-09-10-2126\",\n  \"build_host\": \"MBPdeFlorent2\",\n  \"build_user\": \"florent\"\n}\n\n% cat version.txt\n0.1.0-feature-config-change-6ea1772\n```\n\n## Supported CI\n\nThe most popular continuous integration services are supported.\n\n- [CircleCI](https://circleci.com/)\n- [GitHub Actions](https://github.com/features/actions)\n- [Gitlab CI](https://docs.gitlab.com/ee/ci/)\n- [Drone CI](https://drone.io/)\n- [Travis CI](https://travis-ci.org/)\n- [Jenkins](https://jenkins.io/)\n\n## Supported package managers\nTo extract version information:\n\n- [NPM](https://www.npmjs.com/)\n- [Maven](https://maven.apache.org/)\n\n## Sample config file\nThe `.ci-info.json` looks like this:\n```json\n{\n  \"$schema\": \"https://raw.githubusercontent.com/fclairamb/ci-info/main/config-schema.json\",\n  \"version_input_file\": {\n    \"file\": \"README.md\",\n    \"pattern\": \"Version: ([0-9.]+)\\n\"\n  },\n  \"version_input_tag\": {\n    \"pattern\": \"^v?([0-9.]+)$\"\n  },\n  \"version_input_env_var\": {\n    \"env_var\": \"VERSION\",\n    \"pattern\": \"^([0-9.]+)$\"\n  },\n  \"templates\": [{\n    \"input_file\": \"build.go.tpl\",\n    \"output_file\": \"build.go\"\n  }, {\n    \"input_content\": \"{{ .Version }}\",\n    \"output_file\": \"version.txt\"\n  }],\n  \"build_info_file\": \"build.json\"\n}\n```\n## Possible template arguments\n| Argument | Sample value | Description |\n| -------- | ------------ | ----------- |\n| `{{ .Version }}` | `0.1.0-fix-pr-check-f96a756` | The automatically generated version. This is mix of the declared one and the current GIT info. |\n| `{{ .GitCommitHash }}` | `f96a75638b0e1767f969e23f383f4bc75c0e6ba0` | The current GIT commit |\n| `{{ .GitCommitHashShort }}` | `f96a756` | Short version of a hash |\n| `{{ .GitCommitDate }}` | `2022-04-23 23:52:13 +0200` | The commit's date |\n| `{{ .GitCommitDateClean }}` | `2022-04-23-2157` | The commit's date in a clean format |\n| `{{ .GitBranch }}` | `fix/pr-check` | The current branch |\n| `{{ .GitBranchClean }}` | `fix-pr-check` | The commit branch without special chars |\n| `{{ .GitTag }}` | `v0.1.0` | The current GIT tag |\n| `{{ .GitRef }}` | `v0.1.0` | The current GIT tag or branch |\n| `{{ .GitSmartRef }}` | `fix-pr-check-f96a756` | The current GIT commit described by tag, otherwise branch + hash, otherwise hash |\n| `{{ .BuildDate }}` | `2022-04-23-2210` | The build time |\n| `{{ .BuildHost }}` | `build-server` | The build host |\n| `{{ .BuildUser }}` | `runner` | The build user |\n| `{{ .CISolution }}` | `circleci` | The CI solution |\n| `{{ .CIBuildNumber }}` | `123` | The CI build number |\n| `{{ .PackageManager }}` | `npm` | The package manager |\n\n# Run it\n## With a local binary\n```sh\ncurl -L https://github.com/fclairamb/ci-info/releases/download/v0.3.0/ci-info_0.3.0_darwin_arm64.tar.gz | tar -x \u0026\u0026 ./ci-info\n```\n\n## with a container\nFrom scratch (single binary):\n```sh\ndocker run --rm -ti -v $(pwd):/work fclairamb/ci-info:v0.3.0\n```\n\nWith alpine:\n```sh\ndocker run --rm -ti -v $(pwd):/work fclairamb/ci-info:v0.3.0-alpine\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclairamb%2Fci-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffclairamb%2Fci-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclairamb%2Fci-info/lists"}