Skip to content

Commit

Permalink
properly set crate version during build
Browse files Browse the repository at this point in the history
  • Loading branch information
derklaro committed Jan 25, 2024
1 parent e3bc669 commit 1ffd470
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ jobs:
toolchain: stable
targets: ${{ matrix.platform.target }}

- name: Install Cargo Edit
run: cargo install cargo-edit

- name: Set Crate Version
run: cargo set-version ${{ steps.get_release_version.outputs.version }}

- name: Initialize Rust caching
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.target }}

- name: Compile Binary
uses: clechasseur/rs-cargo@v2
env:
BUILD_VERSION: ${{ steps.get_release_version.outputs.version }}
with:
command: build
use-cross: true
Expand Down
2 changes: 1 addition & 1 deletion openmetrics_udpserver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub static METRIC_COUNTER_REQUESTS: Lazy<Counter<u64>> = Lazy::new(Default::defa
pub static METRIC_COUNTER_ERRORS: Lazy<Counter<u64>> = Lazy::new(Default::default);
pub static METRIC_COUNTER_UDP_PACKETS: Lazy<Counter<u64>> = Lazy::new(Default::default);

const VERSION: Option<&str> = option_env!("BUILD_VERSION");
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");

#[tokio::main]
async fn main() -> anyhow::Result<(), anyhow::Error> {
Expand Down

0 comments on commit 1ffd470

Please sign in to comment.