diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..2a4bc92 --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e04c2dd --- /dev/null +++ b/Dockerfile @@ -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"] + diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..98bedc3 --- /dev/null +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..5d4b270 --- /dev/null +++ b/entrypoint.sh @@ -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}