Link the uploaded package to the relevant repo, if not already linked
This commit is contained in:
+15
-11
@@ -23,27 +23,31 @@ runs:
|
||||
[ "$SPECFILE" == "" ] && exit 1
|
||||
|
||||
DIST="$(rpmspec --rpms --eval='%distcore')" DIST=${DIST#[.-]}
|
||||
CURLARGS=(-i -s --fail-with-body --user ${{ gitea.actor }}:${{ inputs.pat }})
|
||||
CURLARGS=(-s --fail-with-body --user ${{ gitea.actor }}:${{ inputs.pat }})
|
||||
REPO_NAME=$(basename "${{ gitea.repository }}")
|
||||
|
||||
IFS=$'\n' RPM_OUTPUTS=( $(rpmspec -q --builtrpms --target=${{ inputs.build_arch }} --qf '%{n};%{evr};%{arch}\n' $SPECFILE) )
|
||||
for RPM_OUTPUT in ${RPM_OUTPUTS[@]}; do
|
||||
IFS=';' RPM_PARTS=($RPM_OUTPUT)
|
||||
echo Publishing ${RPM_PARTS[0]}-${RPM_PARTS[1]}.${RPM_PARTS[2]}.rpm to ${{ gitea.server_url }}
|
||||
curl "${CURLARGS[@]}" -H "Content-Type: application/octet-stream" --upload-file RPMS/${RPM_PARTS[2]}/${RPM_PARTS[0]}-${RPM_PARTS[1]}.${RPM_PARTS[2]}.rpm ${{ gitea.server_url }}/api/packages/${{ gitea.actor }}/${{ gitea.actor }}-${DIST}/upload
|
||||
if [ $? -ne 0 ]; then
|
||||
curl "${CURLARGS[@]}" -H "Content-Type: application/octet-stream" --upload-file RPMS/${RPM_PARTS[2]}/${RPM_PARTS[0]}-${RPM_PARTS[1]}.${RPM_PARTS[2]}.rpm ${{ gitea.server_url }}/api/packages/${{ gitea.actor }}/rpm/${{ gitea.actor }}-${DIST}/upload
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo Publishing failed
|
||||
exit $?
|
||||
exit $EXITCODE
|
||||
fi
|
||||
PACKAGE_API_ARGS=(${CURLARGS[@]} ${{ gitea.api_url }}/packages/${{ gitea.actor }}/rpm/${RPM_PARTS[0]})
|
||||
if [ "$(curl ${PACKAGE_API_ARGS[@]}?page=1'&'limit=1 | jq '.[0].repository.id > 0')" == "false" ]; then
|
||||
echo Linking $RPM to $REPO_NAME
|
||||
curl -X POST ${PACKAGE_API_ARGS[@]}/-/link/$REPO_NAME
|
||||
EXITCODE=$?
|
||||
if [ $EXITCODE -ne 0 ]; then
|
||||
echo Linking failed
|
||||
exit $EXITCODE
|
||||
fi
|
||||
fi
|
||||
curl "${CURLARGS[@]}" -X POST ${{ gitea.api_url }}/packages/${RPM_PARTS[0]}/-/link/$REPO_NAME
|
||||
echo Linked $RPM to $REPO_NAME
|
||||
echo
|
||||
done
|
||||
|
||||
echo "Pushed the following files to the ${{ gitea.server_url }}/${{ gitea.actor }} rpm repository:"
|
||||
for RPM in $(rpmspec --rpms -q --qf '%{nevra} ' $SPECFILE); do
|
||||
echo $RPM.rpm
|
||||
done
|
||||
branding:
|
||||
icon: "upload"
|
||||
color: "gray-dark"
|
||||
|
||||
Reference in New Issue
Block a user