From 05d15e7e427421fe9648d3615b8b594384e019b5 Mon Sep 17 00:00:00 2001 From: Oliver Lin Date: Sun, 13 Sep 2026 12:05:21 +0800 Subject: [PATCH 1/3] feat: add RPM packaging to CI and release artifacts Build and publish x86_64 RPM packages through the Fedora-based workflow, verify RPM artifacts during releases, and document installation instructions for Fedora and compatible distributions. --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 3 +++ .gitignore | 3 +++ README.md | 8 +++++++ README_zh-cn.md | 7 ++++++ packaging/patchsplit.spec | 3 ++- 6 files changed, 68 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b3bdf5..e4759f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -126,3 +126,48 @@ jobs: name: patchsplit-debian-amd64 path: debian-artifacts/patchsplit_*.deb if-no-files-found: error + + build-rpm: + name: Build RPM package + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build RPM package in Fedora + shell: bash + run: | + set -euo pipefail + mkdir -p rpm-artifacts + version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1) + git archive --format=tar.gz --prefix="patchsplit-${version}/" HEAD \ + -o "patchsplit-${version}.tar.gz" + docker run --rm \ + -v "$GITHUB_WORKSPACE:/workspace:ro" \ + -v "$GITHUB_WORKSPACE/rpm-artifacts:/artifacts" \ + -w /tmp \ + fedora:latest \ + bash -euxo pipefail -c ' + dnf install -y \ + cargo \ + gcc \ + make \ + redhat-rpm-config \ + rpm-build \ + rust + version=$(sed -n "s/^version = \"\\([^\"]*\\)\"/\\1/p" /workspace/Cargo.toml | head -n 1) + topdir=/tmp/rpmbuild + mkdir -p "$topdir"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} + cp "/workspace/patchsplit-${version}.tar.gz" "$topdir/SOURCES/" + cp /workspace/packaging/patchsplit.spec "$topdir/SPECS/" + rpmbuild --define "_topdir $topdir" -bb "$topdir/SPECS/patchsplit.spec" + cp "$topdir"/RPMS/*/patchsplit-*.rpm /artifacts/ + ' + + - name: Upload RPM package + uses: actions/upload-artifact@v4 + with: + name: patchsplit-rpm-x86_64 + path: rpm-artifacts/patchsplit-*.rpm + if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91ec3ac..6c1ecb9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,9 @@ jobs: path: artifacts merge-multiple: true + - name: Verify RPM package + run: test -n "$(find artifacts -type f -name '*.rpm' -print -quit)" + - name: Create Draft Release env: GH_TOKEN: ${{ github.token }} diff --git a/.gitignore b/.gitignore index fa71e56..7557cec 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ debian/cargo-target/ cargo_home cargo_registry debian/patchsplit.debhelper.log + +# RPM packaging build artifacts +rpm-artifacts/ diff --git a/README.md b/README.md index 981ab37..df1a249 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ exist, it will point to the workflow commit. The workflow creates these files: - `patchsplit-macos-x86_64.tar.gz` - `patchsplit-windows-x86_64.zip` - `patchsplit__amd64.deb` +- `patchsplit--.*.x86_64.rpm` Releases are created as drafts, so they should be reviewed and published from the GitHub Releases page. @@ -105,6 +106,13 @@ On Debian and Ubuntu, download the `.deb` release asset and install it with: sudo apt install ./patchsplit__amd64.deb ``` +On Fedora, RHEL, and compatible distributions, download the `.rpm` release +asset and install it with: + +```sh +sudo dnf install ./patchsplit--.*.x86_64.rpm +``` + > [!NOTE] > For Arch Linux, use the [`patchsplit-bin`](https://aur.archlinux.org/packages/patchsplit-bin) AUR package > maintained by [lingbopro](https://github.com/lingbopro). diff --git a/README_zh-cn.md b/README_zh-cn.md index de23063..465f7c4 100644 --- a/README_zh-cn.md +++ b/README_zh-cn.md @@ -87,6 +87,7 @@ git push origin v1.x.x - `patchsplit-macos-x86_64.tar.gz` - `patchsplit-windows-x86_64.zip` - `patchsplit__amd64.deb` +- `patchsplit--.*.x86_64.rpm` release 默认是草稿,需要在 GitHub Releases 页面检查后手动发布。 @@ -107,6 +108,12 @@ release 默认是草稿,需要在 GitHub Releases 页面检查后手动发布 sudo apt install ./patchsplit__amd64.deb ``` +在 Fedora、RHEL 及兼容发行版上,下载 release 中的 `.rpm` 文件并执行: + +```sh +sudo dnf install ./patchsplit--.*.x86_64.rpm +``` + ```sh tar -xzf patchsplit-linux-x86_64.tar.gz chmod +x patchsplit diff --git a/packaging/patchsplit.spec b/packaging/patchsplit.spec index fa5ac44..78e63b4 100644 --- a/packaging/patchsplit.spec +++ b/packaging/patchsplit.spec @@ -12,6 +12,7 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: rust BuildRequires: cargo +BuildRequires: gcc %description Patchsplit is a command-line tool for splitting patch files into @@ -41,4 +42,4 @@ install -Dm644 packaging/patchsplit.1 \ %changelog * Sun Sep 13 2026 Oliver Lin - 1.0.4-1 -- Initial RPM package \ No newline at end of file +- Initial RPM package From 576dfe56779653e5cf95b91def073ba3544472e7 Mon Sep 17 00:00:00 2001 From: Oliver Lin Date: Sun, 13 Sep 2026 12:09:11 +0800 Subject: [PATCH 2/3] docs: simplify RPM installation command patterns Update English and Chinese README instructions to use a wildcard RPM filename, avoiding the need to specify version and release details manually. --- README.md | 2 +- README_zh-cn.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index df1a249..9ee0863 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ On Fedora, RHEL, and compatible distributions, download the `.rpm` release asset and install it with: ```sh -sudo dnf install ./patchsplit--.*.x86_64.rpm +sudo dnf install ./patchsplit-*.x86_64.rpm ``` > [!NOTE] diff --git a/README_zh-cn.md b/README_zh-cn.md index 465f7c4..d4bf469 100644 --- a/README_zh-cn.md +++ b/README_zh-cn.md @@ -111,7 +111,7 @@ sudo apt install ./patchsplit__amd64.deb 在 Fedora、RHEL 及兼容发行版上,下载 release 中的 `.rpm` 文件并执行: ```sh -sudo dnf install ./patchsplit--.*.x86_64.rpm +sudo dnf install ./patchsplit-*.x86_64.rpm ``` ```sh From d0acc58d29b5df8d31fb8d74873c715448f1f113 Mon Sep 17 00:00:00 2001 From: Oliver Lin Date: Sun, 13 Sep 2026 12:11:11 +0800 Subject: [PATCH 3/3] docs: clarify RPM package selection Add notes to the English and Chinese READMEs advising users to install the main RPM package instead of the debuginfo package when both are present in a release. --- README.md | 3 +++ README_zh-cn.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 9ee0863..fdc0337 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,9 @@ asset and install it with: sudo dnf install ./patchsplit-*.x86_64.rpm ``` +If the release also includes a debuginfo package, install the main package +`patchsplit--.x86_64.rpm` instead of the debuginfo package. + > [!NOTE] > For Arch Linux, use the [`patchsplit-bin`](https://aur.archlinux.org/packages/patchsplit-bin) AUR package > maintained by [lingbopro](https://github.com/lingbopro). diff --git a/README_zh-cn.md b/README_zh-cn.md index d4bf469..a5c2c9c 100644 --- a/README_zh-cn.md +++ b/README_zh-cn.md @@ -114,6 +114,9 @@ sudo apt install ./patchsplit__amd64.deb sudo dnf install ./patchsplit-*.x86_64.rpm ``` +如果 release 中同时提供了 debuginfo 包,请安装主包 +`patchsplit--.x86_64.rpm`,不要安装 debuginfo 包。 + ```sh tar -xzf patchsplit-linux-x86_64.tar.gz chmod +x patchsplit