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 @@ -66,6 +66,16 @@ These items have been removed from the public API of `apollo_router::services::e

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

### Insert the full target triplet in the package name, and prefix with `v` ([Issue #1385](https://github.com/apollographql/router/issues/1385))

The release tarballs now contain the full target triplet in their name along with a `v` prefix to be consistent with our other packaging techniques (e.g., Rover):

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

By [@abernix](https://github.com/abernix) and [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1433 (which re-lands work done in https://github.com/apollographql/router/pull/1393)

### Many structs and enums are now `#[non_exhaustive]` ([Issue #1550](https://github.com/apollographql/router/issues/1550))

This means we may add struct fields or enum variants in the future.
Expand Down
29 changes: 15 additions & 14 deletions RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ in lieu of an official changelog.
(release) or "#.#.#-rc.#" (release candidate)
3. Update the `version` in `*/Cargo.toml` (do not forget the ones in scaffold templates).
- Be certain to also update the ones in the `scaffold` templates
4. Update `docker.mdx` and `kubernetes.mdx` with the release version.
5. Update `helm/chart/router/Chart.yaml` and in `helm/chart/router/README.md` as follows:
4. Update the `PACKAGE_VERSION` value in `scripts/install.sh` (it should be prefixed with `v`!)
5. Update `docker.mdx` and `kubernetes.mdx` with the release version.
6. Update `helm/chart/router/Chart.yaml` and in `helm/chart/router/README.md` as follows:
- increment the version. e.g. `version: 0.1.2` becomes `version: 0.1.3`
- update the appVersion to the release version. e.g.: `appVersion: "v0.9.0"`
6. cd helm/chart && helm-docs router; cd - (if required, install [helm-docs](https://github.com/norwoodj/helm-docs))
7. Update `federation-version-support.mdx` with the latest version info. Use https://github.com/apollographql/version_matrix to generate the version matrix.
8. Update the `version` in `docker-compose*` files in the `dockerfiles` directory.
9. Update the license list with `cargo about generate --workspace -o licenses.html about.hbs`.
7. cd helm/chart && helm-docs router; cd - (if required, install [helm-docs](https://github.com/norwoodj/helm-docs))
8. Update `federation-version-support.mdx` with the latest version info. Use https://github.com/apollographql/version_matrix to generate the version matrix.
9. Update the `version` in `docker-compose*` files in the `dockerfiles` directory.
10. Update the license list with `cargo about generate --workspace -o licenses.html about.hbs`.
You can install `cargo-about` by running `cargo install cargo-about`.
10. Add a new section in `CHANGELOG.md` with the contents of `NEXT_CHANGELOG.md`
11. Put a Release date and the version number on the new `CHANGELOG.md` section
12. Update the version in `NEXT_CHANGELOG.md`.
13. Clear `NEXT_CHANGELOG.md` leaving only the template.
14. Run `cargo check` so the lock file gets updated.
15. Run `cargo xtask check-compliance`.
16. Push up a commit with all the changes. The commit message should be "release: v#.#.#" or "release: v#.#.#-rc.#"
17. Request review from the Router team.
11. Add a new section in `CHANGELOG.md` with the contents of `NEXT_CHANGELOG.md`
12. Put a Release date and the version number on the new `CHANGELOG.md` section
13. Update the version in `NEXT_CHANGELOG.md`.
14. Clear `NEXT_CHANGELOG.md` leaving only the template.
15. Run `cargo check` so the lock file gets updated.
16. Run `cargo xtask check-compliance`.
17. Push up a commit with all the changes. The commit message should be "release: v#.#.#" or "release: v#.#.#-rc.#"
18. Request review from the Router team.

### Review

Expand Down
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
95 changes: 47 additions & 48 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@

set -u

BINARY_DOWNLOAD_PREFIX="https://github.com/apollographql/router/releases/download"

# Router version defined in apollo-router's Cargo.toml
# Note: Change this line manually during the release steps.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future step should automate bumping this, in the same way that it's already automated on rover.

PACKAGE_VERSION="v0.16.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be overridden by an environment variable or an argument?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, yes, but again, same comment as #1433 (comment), the point is that is not durable because the package installer might change over time based on the version. It is very intentional that it does not allow installing different versions. 😸

If you want a different version, you change the version in the curl install URL path itself. That lets us track the actual invocations of the installer and change the installer over time with the versions.


download_binary() {
need_cmd curl
downloader --check
need_cmd mktemp
need_cmd chmod
need_cmd mkdir
need_cmd rm
Expand All @@ -19,17 +26,18 @@ download_binary() {
need_cmd awk
need_cmd cut

ARG_VERSION=${1:-"latest"}

# if $VERSION isn't provided or has 0 length, use version apollo-router's cargo.toml
# ${VERSION:-} checks if version exists, and if doesn't uses the default
# which is after the :-, which in this case is empty. -z checks for empty str
if [ -z "${VERSION:-}" ]; then
# VERSION is either not set or empty
DOWNLOAD_VERSION=$ARG_VERSION
DOWNLOAD_VERSION=$PACKAGE_VERSION
else
# VERSION set and not empty
DOWNLOAD_VERSION=$VERSION
fi


get_architecture || return 1
_arch="$RETVAL"
assert_nz "$_arch" "arch"
Expand All @@ -41,44 +49,16 @@ download_binary() {
;;
esac

ARG_ARCH=${2:-"$_arch"}

ARG_OUT_FILE=${3:-"./router"}

GITHUB_REPO="https://github.com/apollographql/router"

# Validate token.
curl -o /dev/null -s $GITHUB_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; }

#_tardir="router-$DOWNLOAD_VERSION-${_arch}"
#_url="$BINARY_DOWNLOAD_PREFIX/$DOWNLOAD_VERSION/${_tardir}.tar.gz"
_tardir="router-$DOWNLOAD_VERSION-${_arch}"
_url="$BINARY_DOWNLOAD_PREFIX/$DOWNLOAD_VERSION/${_tardir}.tar.gz"
_dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t router)"
_file="$_dir/input.tar.gz"
_router="$_dir/router$_ext"

_release_download_url="$GITHUB_REPO/releases"
_router_version=$DOWNLOAD_VERSION
if [ "$DOWNLOAD_VERSION" = "latest" ]; then
_response=$(curl -Ls -o /dev/null -w '%{url_effective}' $GITHUB_REPO/releases/latest)
_router_version=$(echo "$_response" | cut -d'/' -f 8)
[ "$_router_version" ] || { echo "Error: Failed to get asset version for '$ARG_ARCH', response: $_response" | awk 'length($0)<100' >&2; exit 1; }
fi;

say "Downloading release info for '$_release_download_url'"

# Cut the 'v' prefix
_name="router-$(echo "$_router_version" | cut -c2-)-$ARG_ARCH.tar.gz"

_url="$GITHUB_REPO/releases/download/$_router_version/$_name"

say "Found $_name" 1>&2
say "Downloading router from $_url ..." 1>&2

ensure mkdir -p "$_dir"

# Download asset file.
say "Downloading router from $_url"

curl -sSfL -H 'Accept: application/octet-stream' "$_url" -o "$_file"
downloader "$_url" "$_file"
if [ $? != 0 ]; then
Comment on lines +61 to 62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: this is considered to be better style (SC2181)

Suggested change
downloader "$_url" "$_file"
if [ $? != 0 ]; then
if ! downloader "$_url" "$_file"; then

say "Failed to download $_url"
say "This may be a standard network error, but it may also indicate"
Expand All @@ -87,20 +67,19 @@ download_binary() {
say "https://github.com/apollographql/router/issues/new/choose"
exit 1
fi

ensure tar xf "$_file" --strip-components 1 -C "$_dir"

say "Moving $_router to $ARG_OUT_FILE"
mv "$_router" "$ARG_OUT_FILE"
outfile="./router"

_version="$($ARG_OUT_FILE --version)"
say "Moving $_router to $outfile ..."
mv "$_router" "$outfile"

_version="$($outfile --version)"
_retval=$?

say "Moved router version: $_version to $ARG_OUT_FILE"
say ""
say "You can now run the Apollo Router using '$ARG_OUT_FILE'"


chmod +x "$ARG_OUT_FILE"
say "You can now run the Apollo Router using '$outfile'"

ignore rm -rf "$_dir"

Expand Down Expand Up @@ -137,15 +116,15 @@ get_architecture() {

case "$_ostype" in
Linux)
_ostype=linux
_ostype=unknown-linux-gnu
;;

Darwin)
_ostype=macos
_ostype=apple-darwin
;;

MINGW* | MSYS* | CYGWIN*)
_ostype=windows
_ostype=pc-windows-msvc
;;

*)
Expand All @@ -169,7 +148,7 @@ get_architecture() {
say() {
green=$(tput setaf 2 2>/dev/null || echo '')
reset=$(tput sgr0 2>/dev/null || echo '')
echo "$1" 1>&2
echo "$1"
}

err() {
Expand Down Expand Up @@ -213,5 +192,25 @@ ignore() {
"$@"
}

# This wraps curl or wget. Try curl first, if not installed,
# use wget instead.
downloader() {
if check_cmd curl
then _dld=curl
elif check_cmd wget
then _dld=wget
else _dld='curl or wget' # to be used in error message of need_cmd
fi

if [ "$1" = --check ]
then need_cmd "$_dld"
elif [ "$_dld" = curl ]
then curl -sSfL "$1" -o "$2"
elif [ "$_dld" = wget ]
then wget "$1" -O "$2"
else err "Unknown downloader" # should not reach here
fi
}

download_binary "$@" || exit 1

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-v{}-{}.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)
}
}