name: "Build rpm package on COPR" description: "Build a src package and push it to a copr build." author: "Daniel Demus" inputs: copr_config: description: A copr config file to allow communicating with COPR required: true copr_project: description: The name of the project to build required: true fedora_release: description: The fedora release version to build for required: true build_arch: description: Build architecture, default x86_64 required: false default: x86_64 specdir: description: A directory to switch to before trying to find a spec file. required: false specfile: description: The filename of the spec file to build. If not set and there is only 1 specfile, it will be selected automatically. required: false runs: using: "composite" steps: - id: entrypoint name: Build src.rpm and send to COPR shell: bash run: | set -e echo Switching to ${{ gitea.workspace }}/${{ inputs.specdir }} to prepare a src.rpm from ${{ gitea.repository }} cd "${{ gitea.workspace }}/${{ inputs.specdir }}" # Derive the name of the .spec file SPECFILE=$([ "${{ inputs.specfile }}" ] && echo -n "${{ inputs.specfile }}" || echo -n $([ $(ls -1 *.spec 2>/dev/null| wc -l) -eq 1 ] && echo -n "$(ls -1 *.spec)")) [ "$SPECFILE" == "" ] && echo Could\'t find a singular spec file to use && exit 1 echo Specfile is $SPECFILE # The output of https://copr.fedorainfracloud.org/api/ echo Setting up copr config mkdir config cat << EOF > config/copr ${{ inputs.copr_config }} EOF echo RPM autospeccing rpmautospec process-distgit "$SPECFILE" "$SPECFILE" echo install_weak_deps=false >> /etc/dnf/dnf.conf echo Validate builddep availability microdnf builddep -y $SPECFILE counter=1 RPMBUILDARGS=(--target=${{ inputs.build_arch }} --define="_disable_source_fetch 0" --define "_sourcedir $PWD" --define "_topdir $PWD") until rpmbuild "${RPMBUILDARGS[@]}" -br $SPECFILE || [ $counter -gt 5 ]; do echo Installing missing builddeps round $counter microdnf builddep -y SRPMS/$(rpmspec -q --srpm --qf '%{nevr}' $SPECFILE).buildreqs.nosrc.rpm ((counter++)) done echo Build src.rpm and build on COPR rpmbuild -bs --target=${{ inputs.build_arch }} --define="_disable_source_fetch 0" --define "_sourcedir $PWD" --define "_topdir $PWD" --define "_rpmdir $PWD" $SPECFILE copr-cli --config config/copr build --chroot fedora-$(echo "${{ inputs.fedora_release }}" | sed 's/^f//' )-${{ inputs.build_arch }} ${{ inputs.copr_project }} SRPMS/*.src.rpm branding: icon: "package" color: "green"