tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[TASK] Embed Relayer version, git commit/rev into relayer binary for `/api/v1/info` #512

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Overview

It is hard to tell what version or what git commit this relayer is currently running? which makes me think we should embed these information in the result binary at compile-time so that we can return these info in the /api/v1/info endpoint. This will be super useful in the future (for now here is a tease for future usage of this: relayerup clone https://relayer1.webb.tools :shushing_face: )

Example

By default, most of the information we add in Cargo.toml are already exposed as CARGO_* env during compile time, for example:

let version = env!("CARGO_PKG_VERSION");

For more, you can read about it here.

println!("cargo:rustc-env=GIT_BRANCH={}", get_git_branch()));

This will tell cargo to set this env for us, so that we can do the following in our main program:

let branch = env!("GIT_BRANCH");

There a crate that actually helps in doing all of this build-data

Expected Response

Utilizing this in Our CI/CD, and reading that in our code, we want to have something like the following in our /api/v1/info

{
  "evm": {},
  "substrate": {},
  "experimental": {},
  "features": {},
  "assets": {},
  "build": {
    "version": "0.5.0-rc22-alpha",
    "commit": "ef4e899",
    "timestamp": "2023-05-12T13:42:54Z"
  }
}

NOTE: the build.timestamp uses SOURCE_TIMESTAMP env, to help making this a Reproducible build

Task Checklist