Implement working on a array of spec files
All checks were successful
Build docker image / build-and-publish (push) Successful in 3m46s

Forgejo Runner doesn't support dynamic matrix jobs (where the input comes from output of another job).
To work around this, accept a list of spec files to process and run the same thing over and over.

Might still have to fix the output.
This commit is contained in:
Carlos Mogas da Silva 2024-12-05 15:38:41 +00:00
parent 058cfccd52
commit 8841a1df54
2 changed files with 44 additions and 36 deletions

View file

@ -2,8 +2,8 @@ name: "RPM Build"
description: "Builds RPMs for a target system from a spec file" description: "Builds RPMs for a target system from a spec file"
inputs: inputs:
spec: specs:
description: "Path to the spec file" description: "Paths to the spec files"
required: true required: true
system: system:
description: "System target to build the package" description: "System target to build the package"

View file

@ -1,48 +1,56 @@
#!/bin/bash #!/bin/bash
SPEC=${INPUT_SPEC} # SPECS should be a JSON array of all the to-process spec files
# Forgejo runner doesn't support dynamic matrix jobs so, this has to be made this way
# Convert the JSON array to a bash array and iterate over it
readarray -t SPECS < <(echo ${INPUT_SPECS} | jq -c .[] | tr -d '"')
echo "::debug::specs: ${SPECS}"
SYSTEM=${INPUT_SYSTEM} SYSTEM=${INPUT_SYSTEM}
ARCH=${INPUT_ARCH} ARCH=${INPUT_ARCH}
NOCHECK=${INPUT_NOCHECK} NOCHECK=${INPUT_NOCHECK}
SPEC_NAME=$(basename ${SPEC})
CONFIGURATION="${SYSTEM}-${ARCH}"
echo "::debug::spec file: ${INPUT_SPEC}" for SPEC in ${SPECS[@]}; do
echo "::debug::target: ${INPUT_SYSTEM}-${INPUT_ARCH}" SPEC_NAME=$(basename ${SPEC})
echo "::debug::nocheck: ${INPUT_NOCHECK}" CONFIGURATION="${SYSTEM}-${ARCH}"
echo "Building ${SPEC_NAME} for ${CONFIGURATION}" echo "::debug::spec file: ${INPUT_SPEC}"
echo "::debug::target: ${INPUT_SYSTEM}-${INPUT_ARCH}"
echo "::debug::nocheck: ${INPUT_NOCHECK}"
echo "::group::Building SRPM" echo "Building ${SPEC_NAME} for ${CONFIGURATION}"
cd $(dirname ${SPEC})
spectool -g ${SPEC} echo "::group::Building SRPM"
if [ $? -ne 0 ]; then cd $(dirname ${SPEC})
spectool -g ${SPEC}
if [ $? -ne 0 ]; then
echo "::error::Failed to download sources" echo "::error::Failed to download sources"
exit 1 exit 1
fi fi
mock -r "${SYSTEM}-${ARCH}" --buildsrpm --spec ${SPEC_NAME} --sources . --resultdir result mock -r "${SYSTEM}-${ARCH}" --buildsrpm --spec ${SPEC_NAME} --sources . --resultdir result
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "::error::Failed to build SRPM" echo "::error::Failed to build SRPM"
exit 1 exit 1
fi fi
echo "::endgroup::" echo "::endgroup::"
SRPM=$(grep Wrote result/build.log | cut -d" " -f 2) SRPM=$(grep Wrote result/build.log | cut -d" " -f 2)
echo "::group::Building RPM" echo "::group::Building RPM"
OPTS="" OPTS=""
if [ ${NOCHECK,,} == "true"]; then if [ ${NOCHECK,,} == "true"]; then
OPTS="${OPTS} --nocheck" OPTS="${OPTS} --nocheck"
fi fi
mock -r "${SYSTEM}-${ARCH}" --resultdir result ${OPTS} ${SRPM} mock -r "${SYSTEM}-${ARCH}" --resultdir result ${OPTS} ${SRPM}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "::error::Failed to build RPM" echo "::error::Failed to build RPM"
exit 1 exit 1
fi fi
echo "::endgroup::" echo "::endgroup::"
RPM=i$(grep Wrote result/build.log | grep "/RPMS/" | cut -d" " -f 2) RPMS=i$(grep Wrote result/build.log | grep "/RPMS/" | cut -d" " -f 2)
echo "rpm=${RPM}" >> ${GITHUB_OUTPUT} echo "::debug::rpms: ${RPMS}"
echo "rpms=${RPMS}" >> ${GITHUB_OUTPUT}
done