Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dist/brew): remove v prefix in brew formula version #400

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ xshell = "0.2.2"
[dependencies]
async-trait = "0.1.56"
bytes = "1.1.0"
clap = { version = "3.2.6", features = ["cargo", "derive"] }
clap = { version = "3.2.7", features = ["cargo", "derive"] }
colored = "2.0.0"
confy = "0.4.0"
dirs-next = "2.0.0"
Expand Down
4 changes: 2 additions & 2 deletions xtask/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use const_format::formatcp;
use xshell::{cmd, Shell};

use crate::dispatch::{get_ver_from_env, names::CORE};
use crate::dispatch::{get_ref_from_env, names::CORE};

pub struct Binary<'s> {
pub artifact: &'s str,
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<'s> BinaryBuilder<'s> {
pub fn upload(&self) -> Result<()> {
println!(":: Uploading binary and sha256...");
let s = Shell::new()?;
let tag = get_ver_from_env()?;
let tag = get_ref_from_env()?;
let asset = self.bin().asset();
cmd!(
s,
Expand Down
10 changes: 5 additions & 5 deletions xtask/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ pub trait Runner {
}

/// Strip the `refs/*/` prefix from `GITHUB_REF` to get a version string.
pub fn get_ver(gh_ref: impl AsRef<str>) -> Result<String> {
pub fn get_ref(gh_ref: impl AsRef<str>) -> Result<String> {
Ok(Regex::new(r"refs/\w+/")?
.replace(gh_ref.as_ref(), "")
.to_string())
}

/// Strip the `refs/*/` prefix from `GITHUB_REF` to get a version string.
/// Where the value of `GITHUB_REF` is read from environment variables.
pub fn get_ver_from_env() -> Result<String> {
get_ver(env::var("GITHUB_REF")?)
/// Strip the `refs/*/` prefix from `GITHUB_REF` to get a version string,
/// where the value of `GITHUB_REF` is read from environment variables.
pub fn get_ref_from_env() -> Result<String> {
get_ref(env::var("GITHUB_REF")?)
}

#[macro_export]
Expand Down
8 changes: 4 additions & 4 deletions xtask/src/dispatch/bump_choco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use regex::Regex;
use xml::escape::escape_str_attribute;
use xshell::{cmd, Shell};

use super::{get_ver_from_env, names::*, Runner};
use super::{get_ref_from_env, names::*, Runner};
use crate::binary::WIN_X64;
use crate::replace;

Expand All @@ -19,12 +19,12 @@ impl Runner for BumpChoco {
}

let s = Shell::new()?;
let tag = get_ver_from_env()?;
let tag = get_ref_from_env()?;

// Remove leading `v` and suffix `-take.X` from the tag.
let ver: &str = {
let tag = tag.strip_prefix('v').unwrap_or(&tag);
&Regex::new(r"-?take\.\d+")?.replace(tag, "")
let ver = tag.strip_prefix('v').unwrap_or(&tag);
&Regex::new(r"-?take\.\d+")?.replace(ver, "")
};

let release_uri = format!(
Expand Down
15 changes: 7 additions & 8 deletions xtask/src/dispatch/bump_tap.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use xshell::{cmd, Shell};

use super::{get_ver_from_env, names::*, Runner};
use super::{get_ref_from_env, names::*, Runner};
use crate::{
binary::{LINUX_X64, MAC_UNIV},
replace,
Expand All @@ -17,12 +17,11 @@ impl Runner for BumpTap {
}

let s = Shell::new()?;
let version = get_ver_from_env()?;
let url_prefix = format!(
"{homepage}/releases/download/{tag}",
homepage = HOMEPAGE,
tag = version
);
let tag = get_ref_from_env()?;
// Remove leading `v` from the tag.
let version = tag.strip_prefix('v').unwrap_or(&tag);

let url_prefix = format!("{HOMEPAGE}/releases/download/{tag}");
let url_mac = format!(
"{prefix}/{bin}",
prefix = url_prefix,
Expand Down Expand Up @@ -61,7 +60,7 @@ impl Runner for BumpTap {
cmd!(s, "cat {formula}").run()?;

println!(":: Uploading new Formula");
cmd!(s, "gh release upload {version} {formula}").run()?;
cmd!(s, "gh release upload {tag} {formula}").run()?;

Ok(())
}
Expand Down