diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..eed19c2 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,80 @@ +name: Linux + +on: + pull_request: + push: + branches: [main] + tags: ['v[0-9]*'] + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + persist-credentials: false + - name: Set up Rust + run: rustup toolchain install stable --profile minimal --component rustfmt + - name: Check formatting + run: cargo +stable fmt --check + - name: Run tests + run: cargo +stable test --locked + + release: + if: github.ref_type == 'tag' + needs: check + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + persist-credentials: false + - name: Build and test the release binary + env: + RELEASE_TAG: ${{ github.ref_name }} + run: | + rustup toolchain install stable --profile minimal + cargo +stable build --release --locked + binary="$PWD/target/release/nload-rs" + if [[ "$("$binary" --version)" != "nload-rs ${RELEASE_TAG#v}" ]]; then + echo "Release tag must match the binary version (v followed by the Cargo version)." >&2 + exit 1 + fi + NLOAD_RS_PTY_BINARY="$binary" cargo +stable test --release --locked --test linux_pty + - name: Package the binary + run: | + archive=nload-rs-linux-x86_64.tar.gz + staging="$(mktemp -d)" + install -m 755 target/release/nload-rs "$staging/" + install -m 644 LICENSE THIRD-PARTY-NOTICES.md "$staging/" + tar -czf "$archive" -C "$staging" nload-rs LICENSE THIRD-PARTY-NOTICES.md + sha256sum "$archive" > "$archive.sha256" + - name: Package and verify corresponding source + run: | + archive=nload-rs-source.tar.gz + staging="$(mktemp -d)" + git archive --prefix=nload-rs-source/ HEAD | tar -xf - -C "$staging" + ( + cd "$staging/nload-rs-source" + mkdir -p .cargo + cargo +stable vendor --locked > .cargo/config.toml + ) + tar -czf "$archive" -C "$staging" nload-rs-source + + verification="$(mktemp -d)" + tar -xzf "$archive" -C "$verification" + cd "$verification/nload-rs-source" + CARGO_HOME="$verification/cargo-home" cargo +stable build --release --locked --offline + - name: Publish GitHub release + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ github.ref_name }} + run: | + gh release create "$RELEASE_TAG" \ + nload-rs-linux-x86_64.tar.gz nload-rs-linux-x86_64.tar.gz.sha256 \ + nload-rs-source.tar.gz \ + --verify-tag --generate-notes diff --git a/README.md b/README.md index bbc4549..2c094d8 100644 --- a/README.md +++ b/README.md @@ -7,20 +7,32 @@ and per-interface statistics. *The loopback interface (`lo`) under local test traffic, with `--color` enabled.* -## Quick start +## Install -From this checkout, with stable Rust that supports edition 2024: +Download `nload-rs-linux-x86_64.tar.gz` and its `.sha256` file from +[GitHub Releases](https://github.com/CodeWithMa/nload-rs/releases). ```sh -cargo run --release --locked -- +sha256sum -c nload-rs-linux-x86_64.tar.gz.sha256 && + tar -xzf nload-rs-linux-x86_64.tar.gz ``` +Run `./nload-rs` from the extraction directory, or move it onto your `PATH`. + +## Quick start + Press the arrow keys to switch interfaces and `q` to quit. The graphs use your -terminal’s foreground color by default. To enable color and start on a specific -interface: +terminal’s foreground color by default. To enable color and start on `lo`, run +this from the extraction directory: + +```sh +./nload-rs --color lo +``` + +If `nload-rs` is on your `PATH`, run: ```sh -cargo run --release --locked -- --color lo +nload-rs --color lo ``` Replace `lo` with the interface you want to watch. If it isn’t present at @@ -30,13 +42,24 @@ appear; disconnected interfaces stay in the list and are marked unavailable. Use `-i VALUE` and `-o VALUE` to set the incoming and outgoing graph ceilings. Both default to 10,240 kBit/s (10 MBit/s in binary units). Run -`cargo run --release --locked -- --help` for all options. +`nload-rs --help` for all options. Use a terminal at least 60×16 with UTF-8 and a font that renders Braille. `TERM` must be nonempty and neither `dumb` nor `linux`. `--color` requires 256-color support and takes precedence over `NO_COLOR`. -## Install on Arch Linux +## Build from source + +Use this checkout or extract `nload-rs-source.tar.gz` from +[GitHub Releases](https://github.com/CodeWithMa/nload-rs/releases). The release +archive includes the locked dependencies and can be built offline. From the +source directory, with stable Rust that supports edition 2024: + +```sh +cargo install --path . --locked +``` + +### Arch Linux package Build the `x86_64` package from this checkout using the [PKGBUILD](packaging/arch/PKGBUILD): @@ -61,6 +84,11 @@ cargo test --locked The tests require access to `/proc` and the ability to allocate a pseudoterminal (PTY). +To cut a release, push a `v` tag matching the version in `Cargo.toml` (for +example, `v0.1.4` for version `0.1.4`). The Linux workflow runs the tests, +checks the release binary, and publishes the binary archive, its checksum, and +the corresponding source archive. + ## Credits and license Inspired by [nload](https://github.com/rolandriegel/nload) by Roland Riegel,