Split crates and clean up structure of codebase (#294)

Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Félix Saparelli 2022-08-20 23:24:12 +12:00 committed by GitHub
parent bf700f9012
commit 4b00f5f143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 2989 additions and 1423 deletions

35
.github/scripts/compile-settings.jq vendored Normal file
View file

@ -0,0 +1,35 @@
if $for_release then {
output: "release",
profile: "release",
# Use build-std to build a std library optimized for size and abort immediately on abort,
# so that format string for `unwrap`/`expect`/`unreachable`/`panic` can be optimized out.
args: ($matrix.release_build_args // "-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort"),
features: ($matrix.release_features // []),
} else {
output: "debug",
profile: "dev",
args: ($matrix.debug_build_args // ""),
features: ($matrix.debug_features // ["rustls", "fancy-with-backtrace"]),
} end
|
.rustflags = (
if $for_release and $matrix.target == "aarch64-unknown-linux-musl" or $matrix.target == "armv7-unknown-linux-musleabihf"
then "-C link-arg=-lgcc -Clink-arg=-static-libgcc"
else "" end
)
|
.features = (
if (.features | length > 0)
then "--no-default-features --features \(.features | join(","))"
else "" end
)
|
{
CBIN: (if ($matrix.target | test("windows")) then "cargo-binstall.exe" else "cargo-binstall" end),
CTOOL: (if ($matrix."use-cross" // false) then "cross" else "cargo" end),
COUTPUT: .output,
CARGS: "--target \($matrix.target) --profile \(.profile) \(.features) \(.args)",
RUSTFLAGS: .rustflags,
}
|
to_entries[] | "\(.key)=\(.value)"

16
.github/scripts/extract-release-notes.sh vendored Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
set -euxo pipefail
release_pr=$(head -n1 <<< "${COMMIT_MESSAGE:-}" | jq -Rr 'split("[()]"; "")[1] // ""')
if [[ -z "$release_pr" ]]; then
echo "::set-output name=notes_json::null"
exit
fi
gh \
pr --repo "$GITHUB_REPO" \
view "$release_pr" \
--json body \
--jq '"::set-output name=notes_json::\((.body | split("### Release notes")[1] // "") | tojson)"'

View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail
message="$(head -n1 <<< "$COMMIT_MESSAGE")"
version="$(cut -d ' ' -f 2 <<< "${message}")"
echo "::set-output name=version::${version}"

6
.github/scripts/install-deps.sh vendored Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euxo pipefail
apt update
exec apt install -y --no-install-recommends liblzma-dev libzip-dev libzstd-dev

18
.github/scripts/pack-release-archives.sh vendored Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
set -euxo pipefail
for o in outputs/*; do
pushd "$o"
chmod +x cargo-binstall*
cp ../../LICENSE.txt ../../README.md .
target=$(basename "$o" | cut -d. -f1)
if grep -qE '(apple|windows)' <<< "$target"; then
zip "../cargo-binstall-${target}.zip" *
else
tar cv * | gzip -9 > "../cargo-binstall-${target}.tgz"
fi
popd
done

28
.github/scripts/release-pr.txt vendored Normal file
View file

@ -0,0 +1,28 @@
This is a release PR for version **%version%**.
**Use squash merge.**
Upon merging, this will automatically build the CLI and create a GitHub release.
You still need to manually publish the cargo crate.
```
$ git pull
$ git checkout v%version%
$ cargo publish
```
---
_Edit release notes into the section below:_
<!-- do not change or remove this heading -->
### Release notes
_Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`._
#### In this release:
-
#### Other changes:
-

60
.github/scripts/tests.sh vendored Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
set -euxo pipefail
bins="cargo-llvm-cov cargo-binstall"
test_bins="cargo-llvm-cov"
unset CARGO_INSTALL_ROOT
unset CARGO_HOME
# Install binaries using cargo-binstall
# shellcheck disable=SC2086
"./$1" binstall --log-level debug --no-confirm $bins
# Test that the installed binaries can be run
for bin in $test_bins; do
"$HOME/.cargo/bin/$bin" --version
done
cargo binstall --help >/dev/null
# Install binaries using `--manifest-path`
"./$1" binstall --force --log-level debug --manifest-path crates/bin/Cargo.toml --no-confirm cargo-binstall
"./$1" binstall --force --log-level debug --manifest-path crates/bin --no-confirm cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Install binaries using secure mode
min_tls=1.3
[[ "${2:-}" == "Windows" ]] && min_tls=1.2 # WinTLS on GHA doesn't support 1.3 yet
"./$1" binstall \
--force \
--log-level debug \
--secure \
--min-tls-version $min_tls \
--no-confirm \
cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test --version
"./$1" binstall --force --log-level debug --no-confirm --version 0.11.1 cargo-binstall
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test "$crate_name@$version"
"./$1" binstall --force --log-level debug --no-confirm cargo-binstall@0.11.1
# Test that the installed binaries can be run
cargo binstall --help >/dev/null
# Test skip when installed
"./$1" binstall --no-confirm --force cargo-binstall@0.11.1
"./$1" binstall --no-confirm cargo-binstall@0.11.1 | grep -q 'cargo-binstall v0.11.1 is already installed'
"./$1" binstall --no-confirm cargo-binstall@0.10.0 | grep -q -v 'cargo-binstall v0.10.0 is already installed'
## Test When 0.11.0 is installed but can be upgraded.
"./$1" binstall --no-confirm cargo-binstall@0.11.0
"./$1" binstall --no-confirm cargo-binstall@0.11.0 | grep -q 'cargo-binstall v0.11.0 is already installed'
"./$1" binstall --no-confirm cargo-binstall@^0.11.0 | grep -q -v 'cargo-binstall v0.11.0 is already installed'