80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
name: Build and Upload RPM
|
|
description: "Builds rpm for given spec file and uploads to hydrosaber gitea repository."
|
|
inputs:
|
|
spec-file-path:
|
|
description: "Path to spec file for rpm"
|
|
required: true
|
|
package-group:
|
|
description: "Group repository to upload package to"
|
|
default: "f43"
|
|
repository-url:
|
|
description: "Gitea repository to upload package to"
|
|
default: "https://git.hydrosaber.com"
|
|
repository-user:
|
|
description: "User in repository to upload as"
|
|
required: true
|
|
repository-user-token:
|
|
description: "Token to use with user"
|
|
required: true
|
|
extra-source-directory:
|
|
description: "(Optional) Directory to grab files for sources."
|
|
default: ""
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Setup workspace
|
|
shell: bash
|
|
env:
|
|
SPEC_FILE_PATH: ${{ inputs.spec-file-path }}
|
|
run: |
|
|
mkdir -p ./rpmbuild/{RPMS,SPECS}
|
|
cp ${SPEC_FILE_PATH} ./rpmbuild/SPECS
|
|
|
|
- name: Add extra source files
|
|
shell: bash
|
|
if: "${{ inputs.extra-source-directory != '' }}"
|
|
env:
|
|
SOURCE_DIRECTORY: ${{ inputs.extra-source-directory }}
|
|
run: |
|
|
mkdir -p ./rpmbuild/PATCHES
|
|
find ${SOURCE_DIRECTORY} -type f -not -name "*\.spec" \
|
|
-exec cp {} ./rpmbuild/PATCHES \;
|
|
|
|
- name: Build RPM
|
|
shell: bash
|
|
env:
|
|
SPEC_FILE_PATH: ${{ inputs.spec-file-path }}
|
|
ACTION_ROOT: ${{ gitea.action_path }}
|
|
run: |
|
|
SPEC_FILE_NAME=$(basename ${SPEC_FILE_PATH})
|
|
podman run --rm \
|
|
-v ./rpmbuild:/root/rpmbuild:rw,z \
|
|
-v ${ACTION_ROOT}/entrypoint.sh:/root/entrypoint.sh:ro,z \
|
|
-w /root \
|
|
fedora:latest \
|
|
/root/entrypoint.sh /root/rpmbuild/SPECS/${SPEC_FILE_NAME}
|
|
|
|
- name: Upload package
|
|
shell: bash
|
|
env:
|
|
SPEC_FILE_PATH: ${{ inputs.spec-file-path }}
|
|
REPOSITORY_URL: ${{ inputs.repository-url }}
|
|
PACKAGE_GROUP: ${{ inputs.package-group }}
|
|
REPOSITORY_OWNER: ${{ gitea.repository_owner }}
|
|
UPLOAD_USER: ${{ inputs.repository-user }}
|
|
UPLOAD_USER_TOKEN: ${{ inputs.repository-user-token }}
|
|
run: |
|
|
PACKAGE_NAME=$(basename -s .spec ${SPEC_FILE_PATH})
|
|
echo "Goal package to upload: ${PACKAGE_NAME}"
|
|
RPM_PATH="./rpmbuild/RPMS/"
|
|
echo "Searching in ${RPM_PATH}"
|
|
find ./rpmbuild/RPMS/ -type f -name "*.rpm"
|
|
UPLOAD_URL="${REPOSITORY_URL}/api/packages/${REPOSITORY_OWNER}/rpm/${PACKAGE_GROUP}/upload"
|
|
echo "Uploading to url: ${UPLOAD_URL}"
|
|
find ./rpmbuild/RPMS/ -name "*.rpm" -type f \
|
|
-exec curl \
|
|
--user ${UPLOAD_USER}:${UPLOAD_USER_TOKEN} \
|
|
--upload-file {} \
|
|
${UPLOAD_URL} \;
|