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
61 changes: 61 additions & 0 deletions .github/workflows/aur-git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish AUR Git Package

on:
push:
branches:
- main
workflow_dispatch:

jobs:
publish-aur-git:
runs-on: ubuntu-latest
container: archlinux:base-devel

steps:
- name: Install packaging tools
run: pacman -Sy --noconfirm --needed gettext git openssh

- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create build user
run: |
useradd --create-home --shell /bin/bash builder
chown -R builder:builder "$GITHUB_WORKSPACE"

- name: Configure AUR SSH
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
test -n "${AUR_SSH_PRIVATE_KEY}"
install -d -m 700 /home/builder/.ssh
printf '%s\n' "${AUR_SSH_PRIVATE_KEY}" > /home/builder/.ssh/aur
chmod 600 /home/builder/.ssh/aur
ssh-keyscan -H aur.archlinux.org >> /home/builder/.ssh/known_hosts
cat <<'EOF' > /home/builder/.ssh/config
Host aur.archlinux.org
User aur
IdentityFile ~/.ssh/aur
EOF
chmod 600 /home/builder/.ssh/config
chown -R builder:builder /home/builder/.ssh

- name: Compute ghfetch-rs-git version
id: meta
run: |
pkgver="$(su builder -c "cd '$GITHUB_WORKSPACE' && scripts/compute-git-pkgver.sh .")"
echo "pkgver=${pkgver}" >> "$GITHUB_OUTPUT"

- name: Render ghfetch-rs-git
run: |
su builder -c "cd '$GITHUB_WORKSPACE' && \
scripts/render-aur-package.sh ghfetch-rs-git /tmp/ghfetch-rs-git \
--pkgver '${{ steps.meta.outputs.pkgver }}'"

- name: Publish ghfetch-rs-git
run: |
su builder -c "cd '$GITHUB_WORKSPACE' && \
scripts/publish-aur.sh ghfetch-rs-git /tmp/ghfetch-rs-git \
'chore: update ghfetch-rs-git to ${{ steps.meta.outputs.pkgver }}'"
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,25 @@ jobs:

- name: Test
run: cargo test

aur-metadata:
runs-on: ubuntu-latest
container: archlinux:base-devel

steps:
- name: Install packaging tools
run: pacman -Sy --noconfirm --needed gettext git

- name: Check out code
uses: actions/checkout@v4

- name: Create build user
run: |
useradd --create-home --shell /bin/bash builder
chown -R builder:builder "$GITHUB_WORKSPACE"

- name: Render AUR package metadata
run: |
su builder -c "cd '$GITHUB_WORKSPACE' && \
scripts/render-aur-package.sh ghfetch-rs-git /tmp/ghfetch-rs-git --pkgver 0.1.0.r1.gabcdef0 && \
scripts/render-aur-package.sh ghfetch-rs-bin /tmp/ghfetch-rs-bin --pkgver 0.1.0 --sha256 0000000000000000000000000000000000000000000000000000000000000000"
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
archive_name: ${{ steps.meta.outputs.archive_name }}
archive_sha256: ${{ steps.meta.outputs.archive_sha256 }}

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2

- name: Validate tag version
run: |
tag_version="${GITHUB_REF_NAME#v}"
cargo_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n1)"
test "${tag_version}" = "${cargo_version}"

- name: Run tests
run: cargo test --locked

- name: Build release archive
id: meta
run: |
version="${GITHUB_REF_NAME#v}"
archive_path="$(scripts/build-release-archive.sh "${version}" dist)"
archive_name="$(basename "${archive_path}")"
archive_sha256="$(cut -d' ' -f1 "${archive_path}.sha256")"

{
echo "version=${version}"
echo "archive_name=${archive_name}"
echo "archive_sha256=${archive_sha256}"
} >> "$GITHUB_OUTPUT"

- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
dist/${{ steps.meta.outputs.archive_name }}
dist/${{ steps.meta.outputs.archive_name }}.sha256
generate_release_notes: true

publish-aur-bin:
runs-on: ubuntu-latest
container: archlinux:base-devel
needs: release

steps:
- name: Install packaging tools
run: pacman -Sy --noconfirm --needed gettext git openssh

- name: Check out code
uses: actions/checkout@v4

- name: Create build user
run: |
useradd --create-home --shell /bin/bash builder
chown -R builder:builder "$GITHUB_WORKSPACE"

- name: Configure AUR SSH
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
test -n "${AUR_SSH_PRIVATE_KEY}"
install -d -m 700 /home/builder/.ssh
printf '%s\n' "${AUR_SSH_PRIVATE_KEY}" > /home/builder/.ssh/aur
chmod 600 /home/builder/.ssh/aur
ssh-keyscan -H aur.archlinux.org >> /home/builder/.ssh/known_hosts
cat <<'EOF' > /home/builder/.ssh/config
Host aur.archlinux.org
User aur
IdentityFile ~/.ssh/aur
EOF
chmod 600 /home/builder/.ssh/config
chown -R builder:builder /home/builder/.ssh

- name: Render ghfetch-rs-bin
run: |
su builder -c "cd '$GITHUB_WORKSPACE' && \
scripts/render-aur-package.sh ghfetch-rs-bin /tmp/ghfetch-rs-bin \
--pkgver '${{ needs.release.outputs.version }}' \
--sha256 '${{ needs.release.outputs.archive_sha256 }}'"

- name: Publish ghfetch-rs-bin
run: |
su builder -c "cd '$GITHUB_WORKSPACE' && \
scripts/publish-aur.sh ghfetch-rs-bin /tmp/ghfetch-rs-bin \
'chore: update ghfetch-rs-bin to ${{ needs.release.outputs.version }}'"
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ GitHub stats in the terminal, neofetch-style.
cargo install ghfetch
```

### From the AUR

```bash
paru -S ghfetch-rs-bin
paru -S ghfetch-rs-git
```

### From source

```bash
Expand All @@ -50,6 +57,7 @@ Unauthenticated mode still works for public data, but GitHub rate limits are muc
ghfetch octocat
ghfetch user octocat --all
ghfetch repo rust-lang/rust
ghfetch repo https://github.com/rust-lang/rust
ghfetch org rust-lang --languages
ghfetch octocat --json
ghfetch repo rust-lang/rust --theme latte
Expand All @@ -59,7 +67,7 @@ ghfetch repo rust-lang/rust --theme latte

- `ghfetch [username]`
- `ghfetch user <username>`
- `ghfetch repo <owner/repo>`
- `ghfetch repo <owner/repo|github-url|ssh-remote>`
- `ghfetch org <orgname>`

### Common flags
Expand All @@ -72,7 +80,7 @@ ghfetch repo rust-lang/rust --theme latte
## Notes

- `ghfetch user <username>` shows a compact summary by default. Use `--all` to include every section, or specific section flags like `--repos` or `--languages`.
- `ghfetch org <orgname>` and `ghfetch repo <owner/repo>` show language summaries by default.
- `ghfetch org <orgname>` and `ghfetch repo <owner/repo|github-url|ssh-remote>` show language summaries by default.
- Detailed language mode (`--languages`) prints a wider table instead of the card view.

## Development
Expand All @@ -83,6 +91,32 @@ cargo clippy --all-targets --all-features -- -D warnings
cargo test
```

## Release Automation

This repository ships two AUR packages:

- `ghfetch-rs-bin` for tagged GitHub release artifacts
- `ghfetch-rs-git` for the live `main` branch

The package names are suffixed with `-rs` because `ghfetch` is already taken in the AUR, but both packages still install the `ghfetch` executable.

### GitHub Actions flow

- Pushing a `vX.Y.Z` tag builds `ghfetch-X.Y.Z-x86_64-unknown-linux-gnu.tar.gz`, publishes a GitHub Release, and updates `ghfetch-rs-bin`
- Pushing to `main` refreshes `ghfetch-rs-git`
- CI also renders both AUR package definitions to catch metadata regressions early

### Required repository secret

Add `AUR_SSH_PRIVATE_KEY` to the GitHub repository secrets. It should be the private key for the AUR account `notes`, with the matching public key registered in that AUR account.

The generated AUR commits use:

- `Jonatan Jonasson`
- `notes@madeingotland.com`

The AUR templates and publish scripts live under [`packaging/aur`](/home/notes/Projects/ghfetch/packaging/aur) and [`scripts`](/home/notes/Projects/ghfetch/scripts).

## License

MIT. See [LICENSE](LICENSE).
19 changes: 19 additions & 0 deletions packaging/aur/ghfetch-rs-bin/PKGBUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Maintainer: ${AUR_MAINTAINER_NAME} <${AUR_MAINTAINER_EMAIL}>

pkgname=${AUR_PKGNAME}
pkgver=${AUR_PKGVER}
pkgrel=${AUR_PKGREL}
pkgdesc='GitHub stats in the terminal, neofetch-style (prebuilt binary)'
arch=('x86_64')
url='https://github.com/OneNoted/ghfetch'
license=('MIT')
depends=('gcc-libs' 'glibc' 'openssl')
provides=('ghfetch')
conflicts=('ghfetch' 'ghfetch-rs-git')
source=("${AUR_ARCHIVE_NAME}::https://github.com/${AUR_REPO_SLUG}/releases/download/v${AUR_PKGVER}/${AUR_ARCHIVE_NAME}")
sha256sums=('${AUR_ARCHIVE_SHA256}')

package() {
install -Dm755 "${srcdir}/${AUR_ARCHIVE_ROOT}/ghfetch" "${pkgdir}/usr/bin/ghfetch"
install -Dm644 "${srcdir}/${AUR_ARCHIVE_ROOT}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
54 changes: 54 additions & 0 deletions packaging/aur/ghfetch-rs-git/PKGBUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Maintainer: ${AUR_MAINTAINER_NAME} <${AUR_MAINTAINER_EMAIL}>

pkgname=${AUR_PKGNAME}
pkgver=${AUR_PKGVER}
pkgrel=${AUR_PKGREL}
pkgdesc='GitHub stats in the terminal, neofetch-style (development snapshot)'
arch=('x86_64')
url='https://github.com/OneNoted/ghfetch'
license=('MIT')
depends=('gcc-libs' 'glibc' 'openssl')
makedepends=('git' 'rust')
provides=('ghfetch')
conflicts=('ghfetch' 'ghfetch-rs-bin')
_target='x86_64-unknown-linux-gnu'
source=('ghfetch::git+${AUR_REPO_URL}#branch=main')
sha256sums=('SKIP')

pkgver() {
cd "${srcdir}/ghfetch"

local cargo_version
local description
description="$(git describe --long --tags --abbrev=7 --match 'v[0-9]*' 2>/dev/null || true)"

if [[ -n "${description}" ]]; then
description="${description#v}"
printf '%s\n' "${description}" | sed 's/\([^-]*-g\)/r\1/; s/-/./g'
return
fi

cargo_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)"

printf '%s.r%s.g%s\n' \
"${cargo_version:-0.0.0}" \
"$(git rev-list --count HEAD)" \
"$(git rev-parse --short=7 HEAD)"
}

prepare() {
cd "${srcdir}/ghfetch"
cargo fetch --locked --target "${_target}"
}

build() {
cd "${srcdir}/ghfetch"
export CARGO_TARGET_DIR=target
cargo build --frozen --release --target "${_target}"
}

package() {
cd "${srcdir}/ghfetch"
install -Dm755 "target/${_target}/release/ghfetch" "${pkgdir}/usr/bin/ghfetch"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
45 changes: 45 additions & 0 deletions scripts/build-release-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

set -euo pipefail

if [[ $# -ne 2 ]]; then
echo "usage: $0 <version> <output-dir>" >&2
exit 1
fi

version="$1"
output_dir="$2"
target_triple="${TARGET_TRIPLE:-x86_64-unknown-linux-gnu}"
source_date_epoch="${SOURCE_DATE_EPOCH:-0}"

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
archive_root="ghfetch-${version}-${target_triple}"
archive_path="${output_dir}/${archive_root}.tar.gz"
tar_path="${output_dir}/${archive_root}.tar"

cd "${repo_root}"

mkdir -p "${output_dir}"

cargo build --locked --release --target "${target_triple}"

staging_dir="$(mktemp -d)"
trap 'rm -rf "${staging_dir}"' EXIT

install -Dm755 "target/${target_triple}/release/ghfetch" "${staging_dir}/${archive_root}/ghfetch"
install -Dm644 LICENSE "${staging_dir}/${archive_root}/LICENSE"

tar \
--sort=name \
--owner=0 \
--group=0 \
--numeric-owner \
--mtime="@${source_date_epoch}" \
-cf "${tar_path}" \
-C "${staging_dir}" \
"${archive_root}"

gzip -n -f "${tar_path}"
sha256sum "${archive_path}" > "${archive_path}.sha256"

printf '%s\n' "${archive_path}"
Loading
Loading