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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --all-targets --locked -- -D warnings
- name: Test
run: cargo test --locked
- name: Build
run: cargo build --release --locked
- uses: actions/upload-artifact@v4
with:
name: dfetch-x86_64-linux
path: target/release/dfetch
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release

on:
push:
tags: ["v*"]

env:
CARGO_TERM_COLOR: always

permissions:
contents: write

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
- target: aarch64-unknown-linux-musl
os: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4

- name: Check tag matches Cargo.toml version
run: |
version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match Cargo.toml version v$version"
exit 1
fi

- name: Install musl tools
if: contains(matrix.target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}

- name: Package
run: |
name=dfetch-${GITHUB_REF_NAME}-${{ matrix.target }}
mkdir "$name"
cp target/${{ matrix.target }}/release/dfetch README.md LICENSE "$name/"
tar czf "$name.tar.gz" "$name"
sha256sum "$name.tar.gz" > "$name.tar.gz.sha256"

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: dfetch-*.tar.gz*

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
21 changes: 0 additions & 21 deletions .github/workflows/rust.yml

This file was deleted.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,21 @@ However, maintaining clean code is also a priority.. <br>
- emerge ( [Gentoo Linux](https://www.gentoo.org/) )

btw, i'll be happy if somebody send some cool ascii cat arts in issues :point_right::point_left:

### installation

Prebuilt static (musl) and glibc binaries for `x86_64` and `aarch64` are attached to every [release](https://github.com/DeityLamb/dfetch/releases).

```sh
cargo install --git https://github.com/DeityLamb/dfetch
```

### releasing

Bump `version` in `Cargo.toml`, commit, then push a matching tag:

```sh
git tag v0.1.2 && git push origin v0.1.2
```

The `Release` workflow builds all targets and publishes a GitHub release with generated notes.
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ fn main() {
じ しˍ,)ノ {memory_field:<width$} {memory}
"#,
username = whoami::username().yellow().bold(),
hostname = whoami::hostname().yellow().bold(),
hostname = whoami::fallible::hostname()
.unwrap_or_else(|_| "unknown".to_owned())
.yellow()
.bold(),
os = whoami::distro(),
host = get_host().unwrap_or("Unknown".to_owned()),
uptime = uptime::get().unwrap_or_default(),
Expand Down
3 changes: 1 addition & 2 deletions src/package_managers/emerge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ impl PackageManager for EmergePackageManager {
.flatten()
.filter(|entry| entry.metadata().is_ok_and(|v| v.is_dir()))
.flat_map(|v| fs::read_dir(v.path()).map(|v| v.count()))
.fold(0, |acc, count| acc + count as u64)
)
.fold(0, |acc, count| acc + count as u64))
}

fn is_available(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/package_managers/xbps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl PackageManager for XBPSPackageManager {

Ok(io::BufReader::new(File::open(file.path())?)
.lines()
.flatten()
.map_while(Result::ok)
.filter(|line| line.contains("<key>repository</key>"))
.count() as u64)
}
Expand Down
Loading