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

ci: add RPM package generation #1206

Merged
merged 3 commits into from
Jun 15, 2023
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
82 changes: 82 additions & 0 deletions .github/workflows/build_releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,85 @@ jobs:
retention-days: 3
name: release
path: release

build-rpm:
name: "Build Red Hat .rpm software packages"
runs-on: ubuntu-latest
container: ghcr.io/clementtsang/almalinux-8
strategy:
fail-fast: false
matrix:
info:
- { target: "x86_64-unknown-linux-gnu" }
- { target: "x86_64-unknown-linux-musl" }
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 1

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d
with:
toolchain: stable
target: ${{ matrix.info.target }}

# TODO: Could I use the previous jobs to skip this call?
- name: Build
uses: ClementTsang/cargo-action@v0.0.3
env:
BTM_GENERATE: true
BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
with:
command: build
args: --release --locked --verbose --features deploy --target ${{ matrix.info.target }}

- name: Move automatically generated completion/manpage
shell: bash
run: |
mv "$COMPLETION_DIR" completion
mv "$MANPAGE_DIR" manpage

- name: Zip manpage
run: |
gzip ./manpage/btm.1

- name: Build rpm release
if: matrix.info.cross == false
env:
BTM_GENERATE: true
run: |
cargo install cargo-generate-rpm --version 0.11.0 --locked
cargo generate-rpm --target ${{ matrix.info.target }}
cp ./target/${{ matrix.info.target }}/generate-rpm/bottom-*.rpm .

- name: Rename if it is a musl target
if: contains(matrix.info.target, 'musl')
run: |
TMP_NAME=$(find bottom-*.rpm)
mv $TMP_NAME $(echo $TMP_NAME | sed "s/bottom/bottom-musl/")

- name: Verify rpm release
id: verify
run: |
RPM_FILE=$(find bottom-*.rpm)
rpm -qip $RPM_FILE
echo "RPM_FILE=$RPM_FILE" >> $GITHUB_OUTPUT

- name: Delete generated rpm folder
run: |
sudo chown $USER ./target/${{ matrix.info.target }}/generate-rpm/ 2>/dev/null || true
rm -r ./target/${{ matrix.info.target }}/generate-rpm/

- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv ${{ steps.verify.outputs.RPM_FILE }} release/

- name: Save release as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
retention-days: 3
name: release
path: release
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,13 @@ depends = "libc6:armhf (>= 2.28)"

[package.metadata.wix]
output = "bottom_x86_64_installer.msi"

[package.metadata.generate-rpm]
assets = [
{ source = "target/release/btm", dest = "/usr/bin/", mode = "755" },
{ source = "LICENSE", dest = "/usr/share/doc/btm/", mode = "644" },
{ source = "manpage/btm.1.gz", dest = "/usr/share/man/man1/btm.1.gz", mode = "644", doc = true },
{ source = "completion/btm.bash", dest = "/usr/share/bash-completion/completions/btm", mode = "644" },
{ source = "completion/btm.fish", dest = "/usr/share/fish/vendor_completions.d/btm.fish", mode = "644" },
{ source = "completion/_btm", dest = "/usr/share/zsh/vendor-completions/", mode = "644" },
]
2 changes: 1 addition & 1 deletion docs/content/contribution/packaging-and-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ a manpage and shell completions for the following shells:
- Powershell
- Elvish

If you want to generate manpages and/or completion files, set the `BTM_GENERATION` env var to a non-empty value. For
If you want to generate manpages and/or completion files, set the `BTM_GENERATE` env var to a non-empty value. For
example, run something like this:

```bash
Expand Down