From baf4da80639682628ca4ae538b4555ff1b6262da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 30 Sep 2023 14:30:30 +0300 Subject: [PATCH] feat(ci): distribute RPM package (#159) --- .github/workflows/cd.yml | 51 ++++++++++++++++++++++++++++++++++++++++ git-cliff/Cargo.toml | 11 +++++++++ 2 files changed, 62 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 711e259f66..78a735ea2f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -376,6 +376,57 @@ jobs: release_name: "Pre-release v${{ env.RELEASE_VERSION }}" prerelease: true + publish-rpm: + name: Publish RPM package + needs: generate-changelog + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set the release version + shell: bash + run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-unknown-linux-gnu + - name: Install cargo-generate-rpm + run: cargo install cargo-generate-rpm + - name: Build RPM package + run: | + cargo build --release --locked -p git-cliff + mkdir man/ + OUT_DIR=man cargo run --bin git-cliff-mangen + mkdir completions + OUT_DIR=completions cargo run --bin git-cliff-completions + cargo generate-rpm -p git-cliff -o git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm + - name: Sign the package + run: | + echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ + --passphrase-fd 0 --import private.key + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ + --passphrase-fd 0 --detach-sign \ + git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm + - name: Upload the release + if: ${{ !contains(env.RELEASE_VERSION, 'alpha') && !contains(env.RELEASE_VERSION, 'beta') && !contains(env.RELEASE_VERSION, 'rc') }} + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm + tag: ${{ github.ref }} + release_name: "Release v${{ env.RELEASE_VERSION }}" + body: "${{ needs.generate-changelog.outputs.release_body }}" + - name: Upload the pre-release + if: ${{ contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc') }} + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm + tag: ${{ github.ref }} + release_name: "Pre-release v${{ env.RELEASE_VERSION }}" + prerelease: true + publish-crates-io: name: Publish on crates.io runs-on: ubuntu-22.04 diff --git a/git-cliff/Cargo.toml b/git-cliff/Cargo.toml index 54dccbab88..bfa21bd971 100644 --- a/git-cliff/Cargo.toml +++ b/git-cliff/Cargo.toml @@ -52,3 +52,14 @@ pkg-fmt = "tgz" [package.metadata.maturin] name = "git-cliff" + +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/git-cliff", dest = "/usr/bin/git-cliff", mode = "755" }, + { source = "LICENSE", dest = "/usr/share/doc/git-cliff/LICENSE", mode = "644" }, + { source = "README.md", dest = "/usr/share/doc/git-cliff/README.md", mode = "644" }, + { source = "man/git-cliff.1", dest = "/usr/share/man/man1/git-cliff.1", mode = "644", doc = true }, + { source = "completions/git-cliff.bash", dest = "/usr/share/bash-completion/completions/git-cliff", mode = "644" }, + { source = "completions/git-cliff.fish", dest = "/usr/share/fish/vendor_completions.d/git-cliff.fish", mode = "644" }, + { source = "completions/_git-cliff", dest = "/usr/share/zsh/vendor-completions/", mode = "644" }, +]