summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-06-15 04:26:54 +0000
committerGitHub <noreply@github.com>2023-06-15 00:26:54 -0400
commit6c7635038d1a4ffe79a4b9baf44e594cf5745c3c (patch)
treeb709a589d3f9855f6513549318fa018f1f607d70
parent2e5d59f84d056f90c985d762cbc935b081e4bb1b (diff)
ci: add RPM package generation (#1206)
* ci: add RPM package generation * edit container * fix install
-rw-r--r--.github/workflows/build_releases.yml82
-rw-r--r--Cargo.toml10
-rw-r--r--docs/content/contribution/packaging-and-distribution.md2
3 files changed, 93 insertions, 1 deletions
diff --git a/.github/workflows/build_releases.yml b/.github/workflows/build_releases.yml
index 667a97fa..109b8c0a 100644
--- a/.github/workflows/build_releases.yml
+++ b/.github/workflows/build_releases.yml
@@ -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
diff --git a/Cargo.toml b/Cargo.toml
index a3d39f71..175e04c0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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" },
+]
diff --git a/docs/content/contribution/packaging-and-distribution.md b/docs/content/contribution/packaging-and-distribution.md
index 104217c2..26693c8f 100644
--- a/docs/content/contribution/packaging-and-distribution.md
+++ b/docs/content/contribution/packaging-and-distribution.md
@@ -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