Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: CLI Distribution #119

Open
JohannesKaufmann opened this issue Nov 19, 2024 · 2 comments
Open

[Feature]: CLI Distribution #119

JohannesKaufmann opened this issue Nov 19, 2024 · 2 comments
Labels
cli command line interface enhancement New feature or request

Comments

@JohannesKaufmann
Copy link
Owner

Describe the improvement

Right now, I am using GoReleaser to build the CLI and publish it. This automatically adds it 1) to the releases page and 2) to JohannesKaufmann/homebrew-tap.

It would be great to also release for your favourite distro. For that nfpm could be used.

GoReleaser can be wired to nfpm to generate and publish .deb, .rpm, .apk, .ipk, and Archlinux packages.

Unfortunately I am not a Linux user, so any help is appreciated!

  • What are the most common distros/package managers?
  • How are they distributed/hosted?
  • Which choice/combination would serve the most users?
@JohannesKaufmann JohannesKaufmann added enhancement New feature or request cli command line interface labels Nov 19, 2024
@kielmarj
Copy link

Unfortunately I am not a Linux user, so any help is appreciated!

Warning: Linux is a an endless rabbit hole. Proceed with caution if you don't have very much free time. 🙃

For transparency, I have to admit I am heavily biased in favor of Arch Linux over any other distribution. Arch is the Best. However, I have used quite a few different distributions and may be able to offer some general insight.

Almost every Linux distribution is open source and free to use. There are many options for installing Linux, including dual-booting if you want to try it out. Or, you can experiment with many distributions in a virtual machine. If you just want to focus on how to release Linux packages, it isn't necessary to use Linux at all (but it is fun).

Since you're already familiar with go, you could use Docker to test your packages in different Linux environments without needing to dual-boot or fully install Linux.

  • What are the most common distros/package managers?

There are many Linux distributions, each using different package management systems. Here are the most common:

  • Debian-based
    • Operating systems: Ubuntu, Debian, Linux Mint, Kali Linux
    • Package manager: APT (.deb files)
    • Known for: Stability. LTS (long term support) releases. Broad software support. Large community. Popular in cloud environments. Many cloud platforms, like AWS and Azure, offer Ubuntu as the default Linux image.
    • Ubuntu consistently ranks as the most used Linux distribution by developers. A significant portion of open-source projects hosted on GitHub provides installation instructions for .deb packages.
  • Arch-based
    • Operating systems: Arch Linux, Manjaro, Garuda, BlackArch, EndeavourOS
    • Package manager: Pacman
    • Known for: Bleeding-edge software. Rolling releases. High-level customization. The Arch User Repository (AUR) - offers unparalleled access to community-maintained software packages. The Arch Wiki - somewhat of a holy grail when it comes to Linux documentation for users of any Linux distribution. It's a good starting point for researching any Linux-related question.
    • Popular among advanced developers and power users. Arch Linux and its derivatives have a smaller but highly active community of passionate and technically skilled users, many of whom are open-source contributors.
  • Red Hat-based
    • Operating systems: Fedora, Red Hat Enterprise Linux (RHEL), CentOS
    • Package manager: DNF (.rpm files)
  • How are they distributed/hosted?

Most distributions have official repositories that serve as the primary source of packages. For Debian and Ubuntu, .deb packages are hosted in APT repositories. For Fedora, CentOS, and openSUSE, .rpm packages are hosted in DNF/YUM or Zypper repositories. Arch Linux uses the Arch User Repository (AUR) as well as official repositories for package hosting.

  • Which choice/combination would serve the most users?

Debian-based and Arch-based distributions are the most most popular among developers, and these distributions are almost always supported by popular software releases. Red Hat-based distributions are also commonly supported. There are many other smaller and niche distributions, but by focusing on these three you’ll cover most Linux users with minimal effort.

You're already doing great with GoReleaser and I think you're on the right track with nfpm. Use nfpm to generate .deb packages for Ubuntu, Debian, and related distros and .rpm packages for Fedora, RHEL, and CentOS.

For Arch, it appears that you can use nfpm to generate .pkg.tar.zst packages. However, this method isn’t as common as providing a PKGBUILD. I highly recommend spending time learning how to package programs for the AUR because this would showcase your tool to many potential contributors and early adopters. A PKGBUILD file is a script that defines how to build and install your program on Arch Linux. Arch users expect software to be available in the AUR, even if not officially packaged. The AUR allows users to build packages directly from source, ensuring compatibility with their system. You only need to provide a PKGBUILD file (a simple build script), and the Arch community handles the rest.

Here's a dummy PKGBUILD for a made-up go package (I don't know go, but this might give you a better idea of what a PKGBUILD looks like):

# Maintainer: Your Name <[email protected]>
pkgname=mycli
pkgver=1.0.0
pkgrel=1
pkgdesc="A CLI tool built in Go"
arch=('x86_64')
url="https://github.com/yourusername/mycli"
license=('MIT')
depends=('glibc') # List runtime dependencies here
source=("$pkgname-$pkgver.tar.gz::https://github.com/yourusername/mycli/archive/v$pkgver.tar.gz")
sha256sums=('SKIP') # Replace with real checksum if needed

build() {
    cd "$srcdir/$pkgname-$pkgver"
    go build -o mycli
}

package() {
    cd "$srcdir/$pkgname-$pkgver"
    install -Dm755 mycli "$pkgdir/usr/bin/mycli"
}

After you have a PKGBUILD, follow the AUR Guidelines to create and submit your package. If your project updates frequently, you can automate AUR updates using tools like aurpublish or a custom GitHub Action.

@JohannesKaufmann
Copy link
Owner Author

@kielmarj Wow, thanks a lot for the detailed information!

There is now already everything configured for Debian. Building the deb packages & uploading them to Cloudsmith.

See the Setup Instructions

Others will follow soon. Will definitely have to spend some more time on this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli command line interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants