From 41acdff3dfaf0c78394085503ca9b70fe7780593 Mon Sep 17 00:00:00 2001 From: Alexei Samokvalov Date: Thu, 7 Oct 2021 14:43:31 +0200 Subject: [PATCH] Fix version check --- src/util.rs | 3 +++ src/version.rs | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/util.rs b/src/util.rs index 42dc31a..f363c05 100644 --- a/src/util.rs +++ b/src/util.rs @@ -4,6 +4,8 @@ use std::{env, fs}; use ansi_term::{Color, Style}; use reqwest::Proxy; +use crate::version::VERSION; + pub fn path_to_absolute(path: &str) -> PathBuf { let home = env::var("HOME").expect("HOME is not set"); let abs = path.replace("~", &home).replace("$HOME", &home); @@ -35,6 +37,7 @@ pub fn get_https_client() -> Result { ); } builder + .user_agent(format!("awscredx/{}", VERSION)) .build() .map_err(|e| format!("cannot build http client: {}", e)) } diff --git a/src/version.rs b/src/version.rs index ed69dae..7c60526 100644 --- a/src/version.rs +++ b/src/version.rs @@ -40,7 +40,10 @@ impl Display for PublishedVersion { } pub const VERSION: &str = env!("CARGO_PKG_VERSION"); -const TRAVIS_OS_NAME_OPT: Option<&str> = option_env!("TRAVIS_OS_NAME"); + +// The environment variable is provided by github actions. +// See https://docs.github.com/en/actions/learn-github-actions/environment-variables +const CI_RUNNER_OS: Option<&str> = option_env!("RUNNER_OS"); pub fn print_version() { println!( @@ -58,8 +61,10 @@ pub fn print_version() { } } -fn os_name() -> &'static str { - TRAVIS_OS_NAME_OPT.unwrap_or("osx") +fn os_name() -> String { + CI_RUNNER_OS + .map(|s| s.to_lowercase()) + .unwrap_or_else(|| "macos".to_owned()) } pub fn check_new_version() -> Result, String> {