Skip to content
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
10 changes: 10 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@ Dependency updates were blocked for some time due to incompatibilities:

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1389 https://github.com/apollographql/router/pull/1395

### Insert the full target triplet in the package name [PR #1393](https://github.com/apollographql/router/pull/1393)

The released package names will now contain the full target triplet in their name:

* `router-0.11.0-x86_64-linux.tar.gz` -> `router-0.11.0-x86_64-unknown-linux-gnu.tar.gz`
* `router-0.11.0-x86_64-macos.tar.gz` -> `router-0.11.0-x86_64-apple-darwin.tar.gz`
* `router-0.11.0-x86_64-windows.tar.gz` -> `router-0.11.0-x86_64-pc-windows-msvc.tar.gz`

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1393

## 📚 Documentation
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.router
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM --platform=linux/amd64 alpine:latest AS build
ARG ROUTER_RELEASE

# Pull release from GH
ADD https://github.com/apollographql/router/releases/download/v${ROUTER_RELEASE}/router-${ROUTER_RELEASE}-x86_64-linux.tar.gz /tmp/router.tar.gz
ADD https://github.com/apollographql/router/releases/download/v${ROUTER_RELEASE}/router-${ROUTER_RELEASE}-x86_64-unknown-linux-gnu.tar.gz /tmp/router.tar.gz

WORKDIR /tmp

Expand Down
84 changes: 77 additions & 7 deletions xtask/src/commands/package/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(target_os = "macos")]
mod macos;

use std::fmt;
use std::path::Path;
use std::str::FromStr;

use anyhow::ensure;
use anyhow::Context;
Expand All @@ -11,6 +13,16 @@ use structopt::StructOpt;
use xtask::*;

const INCLUDE: &[&str] = &["README.md", "LICENSE", "licenses.html"];
pub(crate) const TARGET_X86_64_MUSL_LINUX: &str = "x86_64-unknown-linux-musl";
pub(crate) const TARGET_X86_64_GNU_LINUX: &str = "x86_64-unknown-linux-gnu";
pub(crate) const TARGET_X86_64_WINDOWS: &str = "x86_64-pc-windows-msvc";
pub(crate) const TARGET_X86_64_MACOS: &str = "x86_64-apple-darwin";
pub(crate) const POSSIBLE_TARGETS: [&str; 4] = [
TARGET_X86_64_MUSL_LINUX,
TARGET_X86_64_GNU_LINUX,
TARGET_X86_64_WINDOWS,
TARGET_X86_64_MACOS,
];

#[derive(Debug, StructOpt)]
pub struct Package {
Expand All @@ -21,6 +33,9 @@ pub struct Package {
#[cfg(target_os = "macos")]
#[structopt(flatten)]
macos: macos::PackageMacos,

#[structopt(long, default_value, possible_values = &POSSIBLE_TARGETS)]
target: Target,
}

impl Package {
Expand All @@ -42,13 +57,8 @@ impl Package {
}
self.output.to_owned()
} else if self.output.is_dir() {
self.output.join(format!(
"router-{}-{}-{}.tar.gz",
*PKG_VERSION,
// NOTE: same as xtask
std::env::consts::ARCH,
std::env::consts::OS,
))
self.output
.join(format!("router-{}-{}.tar.gz", *PKG_VERSION, self.target))
} else {
self.output.to_owned()
};
Expand Down Expand Up @@ -82,3 +92,63 @@ impl Package {
Ok(())
}
}

#[derive(Debug, PartialEq, Clone)]
pub(crate) enum Target {
MuslLinux,
GnuLinux,
Windows,
MacOS,
Other,
}

impl Default for Target {
fn default() -> Self {
if cfg!(target_arch = "x86_64") {
if cfg!(target_os = "windows") {
Target::Windows
} else if cfg!(target_os = "linux") {
if cfg!(target_env = "gnu") {
Target::GnuLinux
} else if cfg!(target_env = "musl") {
Target::MuslLinux
} else {
Target::Other
}
} else if cfg!(target_os = "macos") {
Target::MacOS
} else {
Target::Other
}
} else {
Target::Other
}
}
}

impl FromStr for Target {
type Err = anyhow::Error;

fn from_str(input: &str) -> Result<Self, Self::Err> {
match input {
TARGET_X86_64_MUSL_LINUX => Ok(Self::MuslLinux),
TARGET_X86_64_GNU_LINUX => Ok(Self::GnuLinux),
TARGET_X86_64_WINDOWS => Ok(Self::Windows),
TARGET_X86_64_MACOS => Ok(Self::MacOS),
_ => Ok(Self::Other),
}
}
}

impl fmt::Display for Target {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match &self {
Target::MuslLinux => TARGET_X86_64_MUSL_LINUX,
Target::GnuLinux => TARGET_X86_64_GNU_LINUX,
Target::Windows => TARGET_X86_64_WINDOWS,
Target::MacOS => TARGET_X86_64_MACOS,
Target::Other => "unknown-target",
};
write!(f, "{}", msg)
}
}