diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f47652..5818794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,12 +67,55 @@ jobs: floki*.zip floki*.tar.gz + + rpm: + name: Build and test RPM using cargo generate-rpm + runs-on: ubuntu-24.04 + needs: build + steps: + - uses: actions/checkout@v5 + - name: Install rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + - name: Install cargo-generate-rpm + run: cargo install cargo-generate-rpm + # Download the ubuntu artifact instead of rebuilding. + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: stableartifacts-ubuntu-24.04 + - name: Build RPM + run: | + tar -xzvf floki*.tar.gz + mkdir -p target/release + cp floki target/release/floki + cargo generate-rpm + - name: Debug + run: | + set -ex + + ls -ltR . + ls -l /usr/bin + + - name: Install RPM + run: find . -name "floki*.rpm" | xargs sudo rpm -ivh + - name: Test installation + run: floki -V + - name: Archive artifacts + uses: actions/upload-artifact@v4 + with: + name: rpm + path: | + target/generate-rpm/floki*.rpm + publish: name: Publish release artifact runs-on: ubuntu-latest if: github.ref_type == 'tag' needs: - build + - rpm # Required to publish a release permissions: contents: write @@ -97,6 +140,10 @@ jobs: uses: actions/download-artifact@v5 with: name: stableartifacts-macos-latest + - name: Download RPM + uses: actions/download-artifact@v5 + with: + name: rpm - name: Generate release.txt run: "./changelog.sh" - name: Release @@ -106,6 +153,7 @@ jobs: files: | floki*.zip floki*.tar.gz + floki*.rpm # # Announce the release # - run: "./announce.sh" # env: @@ -117,6 +165,7 @@ jobs: if: github.ref_type != 'tag' needs: - build + - rpm steps: - uses: actions/checkout@v5 - name: Install rust @@ -136,6 +185,10 @@ jobs: uses: actions/download-artifact@v5 with: name: stableartifacts-macos-latest + - name: Download rpm + uses: actions/download-artifact@v5 + with: + name: rpm # Test generating release.txt - name: Generate release.txt run: "./changelog.sh" diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0c01c..eaceda1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Status: Available for use ### Added - Set minimum Rust version to 1.80 +- Add configuration for [`cargo generate-rpm`](https://crates.io/crates/cargo-generate-rpm), allowing an RPM for floki to be built using Cargo against the project ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 3a61d13..88d3a29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,14 @@ shell-words = "1.1.0" [dev-dependencies] tempfile = "3.19.1" +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/floki", dest = "/usr/bin/floki", mode = "0755" }, + { source = "LICENSE", dest = "/usr/share/doc/floki/LICENSE", doc = true, mode = "0644" }, +] +require-sh = false +auto-req = "no" # Required to stop cargo generate-rpm introducing a dep on the RTLD + [profile.release] strip = true # Automatically strip symbols from the binary. opt-level = "z" # Optimize for size. diff --git a/build.sh b/build.sh index ba10def..274633f 100755 --- a/build.sh +++ b/build.sh @@ -28,6 +28,10 @@ then # Check that it's statically compiled! ldd floki + # Strip .gnu.hash since floki is statically compiled. + # Required so that cargo-generate-rpm does not introduce a dependency on the RTLD. + strip --remove-section=.gnu.hash floki + tar -cvzf floki-${LABEL}.tar.gz floki else echo "Building release binary"