Skip to content

Commit faf4ccb

Browse files
authored
Merge pull request #510 from holdeg/gh8/cargo-generate-rpm
Add cargo generate-rpm configuration
2 parents 7257283 + c12d739 commit faf4ccb

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,55 @@ jobs:
6767
floki*.zip
6868
floki*.tar.gz
6969
70+
71+
rpm:
72+
name: Build and test RPM using cargo generate-rpm
73+
runs-on: ubuntu-24.04
74+
needs: build
75+
steps:
76+
- uses: actions/checkout@v5
77+
- name: Install rust
78+
uses: dtolnay/rust-toolchain@master
79+
with:
80+
toolchain: stable
81+
- name: Install cargo-generate-rpm
82+
run: cargo install cargo-generate-rpm
83+
# Download the ubuntu artifact instead of rebuilding.
84+
- name: Download artifacts
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: stableartifacts-ubuntu-24.04
88+
- name: Build RPM
89+
run: |
90+
tar -xzvf floki*.tar.gz
91+
mkdir -p target/release
92+
cp floki target/release/floki
93+
cargo generate-rpm
94+
- name: Debug
95+
run: |
96+
set -ex
97+
98+
ls -ltR .
99+
ls -l /usr/bin
100+
101+
- name: Install RPM
102+
run: find . -name "floki*.rpm" | xargs sudo rpm -ivh
103+
- name: Test installation
104+
run: floki -V
105+
- name: Archive artifacts
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: rpm
109+
path: |
110+
target/generate-rpm/floki*.rpm
111+
70112
publish:
71113
name: Publish release artifact
72114
runs-on: ubuntu-latest
73115
if: github.ref_type == 'tag'
74116
needs:
75117
- build
118+
- rpm
76119
# Required to publish a release
77120
permissions:
78121
contents: write
@@ -97,6 +140,10 @@ jobs:
97140
uses: actions/download-artifact@v5
98141
with:
99142
name: stableartifacts-macos-latest
143+
- name: Download RPM
144+
uses: actions/download-artifact@v5
145+
with:
146+
name: rpm
100147
- name: Generate release.txt
101148
run: "./changelog.sh"
102149
- name: Release
@@ -106,6 +153,7 @@ jobs:
106153
files: |
107154
floki*.zip
108155
floki*.tar.gz
156+
floki*.rpm
109157
# # Announce the release
110158
# - run: "./announce.sh"
111159
# env:
@@ -117,6 +165,7 @@ jobs:
117165
if: github.ref_type != 'tag'
118166
needs:
119167
- build
168+
- rpm
120169
steps:
121170
- uses: actions/checkout@v5
122171
- name: Install rust
@@ -136,6 +185,10 @@ jobs:
136185
uses: actions/download-artifact@v5
137186
with:
138187
name: stableartifacts-macos-latest
188+
- name: Download rpm
189+
uses: actions/download-artifact@v5
190+
with:
191+
name: rpm
139192
# Test generating release.txt
140193
- name: Generate release.txt
141194
run: "./changelog.sh"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Status: Available for use
1515

1616
### Added
1717
- Set minimum Rust version to 1.80
18+
- 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
1819

1920
### Fixed
2021

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ shell-words = "1.1.0"
3636
[dev-dependencies]
3737
tempfile = "3.19.1"
3838

39+
[package.metadata.generate-rpm]
40+
assets = [
41+
{ source = "target/release/floki", dest = "/usr/bin/floki", mode = "0755" },
42+
{ source = "LICENSE", dest = "/usr/share/doc/floki/LICENSE", doc = true, mode = "0644" },
43+
]
44+
require-sh = false
45+
auto-req = "no" # Required to stop cargo generate-rpm introducing a dep on the RTLD
46+
3947
[profile.release]
4048
strip = true # Automatically strip symbols from the binary.
4149
opt-level = "z" # Optimize for size.

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ then
2828
# Check that it's statically compiled!
2929
ldd floki
3030

31+
# Strip .gnu.hash since floki is statically compiled.
32+
# Required so that cargo-generate-rpm does not introduce a dependency on the RTLD.
33+
strip --remove-section=.gnu.hash floki
34+
3135
tar -cvzf floki-${LABEL}.tar.gz floki
3236
else
3337
echo "Building release binary"

0 commit comments

Comments
 (0)