Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 3, 2020
2 parents 81e4bce + 8c24742 commit a1a0b13
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 40 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
strategy:
matrix:
build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc]
feature: ["lean", "small"]
include:
- build: linux
os: ubuntu-18.04
Expand Down Expand Up @@ -119,12 +120,6 @@ jobs:
run: |
ci/macos-install-packages
- name: Patch Cargo.toml (Windows)
if: matrix.os == 'windows-2019'
shell: bash
run: |
cat Cargo.toml.windows-suffix >> Cargo.toml
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -166,11 +161,12 @@ jobs:
echo "release version: $RELEASE_VERSION"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} --no-default-features --features ${{ matrix.feature }}

- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}"
shell: bash
run: strip target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p}

- name: Strip release binary (arm)
if: matrix.build == 'linux-arm'
Expand All @@ -179,22 +175,22 @@ jobs:
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.BIN_NAME }}
/target/arm-unknown-linux-gnueabihf/release/${{ env.BIN_NAME }}{,p}
- name: Build archive
shell: bash
run: |
staging="${{ env.BIN_NAME }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
staging="${{ env.BIN_NAME }}-${{ matrix.feature }}-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE,CHANGELOG.md} "$staging/"
cp {README.md,LICENSE.md,CHANGELOG.md} "$staging/"
if [ "${{ matrix.os }}" = "windows-2019" ]; then
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/"
cp target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p}.exe "$staging/"
7z a "$staging.zip" "$staging"
echo "::set-env name=ASSET::$staging.zip"
else
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/"
cp target/${{ matrix.target }}/release/${{ env.BIN_NAME }}{,p} "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "::set-env name=ASSET::$staging.tar.gz"
fi
Expand Down
Empty file added CHANGELOG.md
Empty file.
20 changes: 10 additions & 10 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ test = false
doctest = false

[features]
default = ["fast", "pretty-cli"]
default = ["max"]
max = ["fast", "pretty-cli"]
lean = ["fast", "lean-cli"]
small = ["lean-cli"]

fast = ["git-features/parallel", "git-features/fast-sha1"]
pretty-cli = ["structopt",
"git-features/progress-prodash",
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ interactive-developer-environment-in-docker: ## Use docker for all dependencies

##@ Release Builds

release-default: always ## the default build, big bug pretty (builds in ~2min 35s)
release-default: always ## the default build, big but pretty (builds in ~2min 35s)
cargo build --release

release-lean: always ## lean and fast (builds in ~1min 10s)
cargo build --release --no-default-features --features lean-cli,fast
cargo build --release --no-default-features --features lean

release-small: always ## minimal dependencies, at cost of performance (builds in ~46s)
cargo build --release --no-default-features --features lean-cli
cargo build --release --no-default-features --features small

##@ Development

target/release/gio: always
cargo build --release --no-default-features --features lean-cli
cargo build --release --no-default-features --features small

lint: ## Run lints with clippy
cargo clippy
Expand All @@ -39,14 +39,14 @@ benchmark: target/release/gio ## see how fast things are, powered by hyperfine

##@ Testing

tests: check unit-tests journey-tests journey-tests-lean-cli ## run all tests, including journey tests
tests: check unit-tests journey-tests journey-tests-small ## run all tests, including journey tests

check: ## Build all code in suitable configurations
cargo check --all
cargo check --all --all-features
cargo check --no-default-features --features lean-cli
cargo check --no-default-features --features pretty-cli
cargo check --no-default-features --features lean-cli,fast
cargo check --no-default-features --features small
cargo check --no-default-features --features lean
cargo check --no-default-features --features max
cd gitoxide-core && cargo check --all-features
cd git-object && cargo check --all-features
cd git-odb && cargo check --all-features
Expand All @@ -60,13 +60,13 @@ unit-tests: ## run all unit tests
continuous-unit-tests: ## run all unit tests whenever something changes
watchexec -w src $(MAKE) unit-tests

journey-tests: always ## run stateless journey tests (pretty-cli)
journey-tests: always ## run stateless journey tests (max)
cargo build
./tests/stateless-journey.sh target/debug/gio target/debug/giop pretty_and_fast
./tests/stateless-journey.sh target/debug/gio target/debug/giop max

journey-tests-lean-cli: always ## run stateless journey tests (lean-cli)
cargo build --no-default-features --features lean-cli
./tests/stateless-journey.sh target/debug/gio target/debug/giop lean_and_small
journey-tests-small: always ## run stateless journey tests (lean-cli)
cargo build --no-default-features --features small
./tests/stateless-journey.sh target/debug/gio target/debug/giop small

continuous-journey-tests: ## run stateless journey tests whenever something changes
watchexec $(MAKE) journey-tests
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ The top-level command-line interface.
* **lean-cli** _(mutually exclusive to pretty-cli)_
* Use `argh` to produce a usable binary with decent documentation that is smallest in size, usually 300kb less than `pretty-cli`.
* If `pretty-cli` is enabled as well, `small-cli` will take precedence, and you pay for building unnecessary dependencies.

There are convenience features, which combine common choices of the above into one name

* **max** = *pretty-cli* + *fast*
* **lean** = *lean-cli* + *fast*
* **small** = *lean-cli*

### git-features

Expand Down
155 changes: 155 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/bin/sh

set -e

help() {
cat <<'EOF'
Install a binary release of a Rust crate hosted on GitHub
Usage:
install.sh [options]
Options:
-h, --help Display this message
--git SLUG Get the crate from "https://github/$SLUG"
-f, --force Force overwriting an existing binary
--crate NAME Name of the crate to install (default <repository name>)
--tag TAG Tag (version) of the crate to install (default <latest release>)
--target TARGET Install the release compiled for $TARGET (default <`rustc` host>)
--to LOCATION Where to install the binary (default ~/.cargo/bin)
EOF
}

say() {
echo "install.sh: $1"
}

say_err() {
say "$1" >&2
}

err() {
if [ ! -z $td ]; then
rm -rf $td
fi

say_err "ERROR $1"
exit 1
}

need() {
if ! command -v $1 > /dev/null 2>&1; then
err "need $1 (command not found)"
fi
}

force=false
while test $# -gt 0; do
case $1 in
--crate)
crate=$2
shift
;;
--force | -f)
force=true
;;
--git)
git=$2
shift
;;
--help | -h)
help
exit 0
;;
--tag)
tag=$2
shift
;;
--target)
target=$2
shift
;;
--to)
dest=$2
shift
;;
*)
;;
esac
shift
done

# Dependencies
need basename
need curl
need install
need mkdir
need mktemp
need tar

# Optional dependencies
if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then
need cut
fi

if [ -z $tag ]; then
need rev
fi

if [ -z $target ]; then
need grep
need rustc
fi

if [ -z $git ]; then
err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`'
fi

url="https://github.com/$git"
say_err "GitHub repository: $url"

if [ -z $crate ]; then
crate=$(echo $git | cut -d'/' -f2)
fi

say_err "Crate: $crate"

url="$url/releases"

if [ -z $tag ]; then
tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev)
say_err "Tag: latest ($tag)"
else
say_err "Tag: $tag"
fi

if [ -z $target ]; then
target=$(rustc -Vv | grep host | cut -d' ' -f2)
fi

say_err "Target: $target"

if [ -z $dest ]; then
dest="$HOME/.cargo/bin"
fi

say_err "Installing to: $dest"

url="$url/download/$tag/$crate-$tag-$target.tar.gz"

say_err "Downloading: $url"
td=$(mktemp -d || mktemp -d -t tmp)
curl -sL $url | tar -C $td -xz

for f in $(cd $td && find . -type f); do
test -x $td/$f || continue

if [ -e "$dest/$f" ] && [ $force = false ]; then
err "$f already exists in $dest"
else
mkdir -p $dest
install -v -m 755 $td/$f $dest
fi
done

rm -rf $td
2 changes: 2 additions & 0 deletions ci/macos-install-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh

5 changes: 5 additions & 0 deletions ci/ubuntu-install-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

sudo apt-get update
sudo apt-get install -y --no-install-recommends \
xz-utils liblz4-tool musl-tools
2 changes: 1 addition & 1 deletion src/plumbing/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod options {
use structopt::{clap::AppSettings, StructOpt};

#[derive(Debug, StructOpt)]
#[structopt(name = "gio-plumbing", about = "The pretty git underworld")]
#[structopt(name = "gio-plumbing", about = "The git underworld")]
#[structopt(settings = &[AppSettings::SubcommandRequired,
AppSettings::ColoredHelp])]
pub struct Args {
Expand Down
2 changes: 1 addition & 1 deletion src/porcelain/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod options {
use structopt::{clap::AppSettings, StructOpt};

#[derive(Debug, StructOpt)]
#[structopt(about = "The pretty git")]
#[structopt(about = "The git")]
#[structopt(settings = &[AppSettings::SubcommandRequired,
AppSettings::ColoredHelp])]
pub struct Args {
Expand Down
Loading

0 comments on commit a1a0b13

Please sign in to comment.