Initial try on an action to build RPM packages
Some checks failed
Build docker image / build-and-publish (push) Failing after 37s

This commit is contained in:
Carlos Mogas da Silva 2024-12-03 18:33:26 +00:00
parent ff083951fd
commit aa810b33e8
4 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,22 @@
name: Build docker image
on: [push]
jobs:
build-and-publish:
runs-on: ubuntu-22.04
env:
DOCKER_HOST: ${{ vars.DOCKER_HOST }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build & Publish
uses: https://codeberg.org/umglurf/kaniko-action@main
with:
credentials: |
code.r3pek.org=${{ github.repository_owner }}:${{ secrets.PUBLISH_TOKEN }}
destinations: |
code.r3pek.org/${{ github.repository }}:latest
push: true

9
Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM fedora:41
RUN dnf update -y && dnf upgrade -y; \
dnf install -y mock rpmdevtools
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

26
action.yml Normal file
View file

@ -0,0 +1,26 @@
name: "RPM Build"
description: "Builds RPMs for a target system from a spec file"
inputs:
spec:
description: "Path to the spec file"
required: true
system:
description: "System target to build the package"
required: true
arch:
description: "Target arch to build the package"
required: true
default: "x86_64"
outputs:
rpm:
description: "Path to the generated rpm file"
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.spec }}
- ${{ inputs.system }}
- ${{ inputs.arch }}

39
entrypoint.sh Normal file
View file

@ -0,0 +1,39 @@
#!/bin/bash
SPEC=$1
SYSTEM=$2
ARCH=$3
SPEC_NAME=$(basename ${SPEC})
CONFIGURATION="${SYSTEM}-${ARCH}"
echo "Building ${SPEC_NAME} for ${CONFIGURATION}"
echo "::group::Building SRPM"
cd $(dirname ${SPEC})
spectool -g ${SPEC}
if [ $? -ne 0 ]; then
echo "::error Failed to download sources"
exit 1
fi
mock -r "${SYSTEM}-${ARCH}" --buildsrpm --spec ${SPEC_NAME} --sources . --resultdir result
if [ $? -ne 0 ]; then
echo "::error Failed to build SRPM"
exit 1
fi
echo "::endgroup::"
SRPM=$(grep Wrote result/build.log | cut -d" " -f 2)
echo "::group::Building RPM"
mock -r "${SYSTEM}-${ARCH}" --resultdir result ${SRPM}
if [ $? -ne 0 ]; then
echo "::error Failed to build RPM"
exit 1
fi
echo "::endgroup::"
RPM=i$(grep Wrote result/build.log | grep "/RPMS/" | cut -d" " -f 2)
echo "rpm=${RPM}" >> ${GITHUB_OUTPUT}