Skip to content

Add workflow to bump package after dependabot merge #1

Add workflow to bump package after dependabot merge

Add workflow to bump package after dependabot merge #1

name: Update package after dependabot merge
on:
push:
paths:
- automation/requirements.txt
env:
GIT_AUTHOR_NAME: Foreman Packaging Automation
GIT_AUTHOR_EMAIL: [email protected]
PACKAGE_TO_UPDATE: requirements.txt
jobs:
bump-package:
name: "Bump packages after dependabot merge"
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.head_ref == 'rpm/develop'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get install -y --no-install-recommends python3-rpm rpm git-annex python3-semver
sudo curl --create-dirs -o /usr/local/bin/spectool https://pagure.io/rpmdevtools/raw/26a8abc746fba9c0b32eb899b96c92841a37855a/f/spectool.in
sudo curl --create-dirs -o /usr/local/bin/rpmdev-bumpspec https://pagure.io/rpmdevtools/raw/6f387c1deaa5cbed770310e288abde04b17421dc/f/rpmdev-bumpspec
sudo curl --create-dirs -o /usr/local/bin/rpmdev-vercmp https://pagure.io/rpmdevtools/raw/79740e6f1881e399b0b4340a8090dd5adc91a4ea/f/rpmdev-vercmp
printf '#!/bin/bash\necho "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"' | sudo tee /usr/local/bin/rpmdev-packager
sudo chmod +x /usr/local/bin/*
- name: Sort Updated Libs
if: github.event_name == 'push' && github.head_ref == 'rpm/develop'
run: git diff --unified=0 ${{github.event.before}} ${{github.sha}} automation/requirements.txt | grep -Po '(?<=^\+)(?!\+\+).*' > $PACKAGE_TO_UPDATE
- name: Checkout New Branch
if: github.event_name == 'push' && github.head_ref == 'rpm/develop'
- name: Check if package can be updated
if: github.event_name == 'push' && github.head_ref == 'rpm/develop'
run: |
set +e
while ((i++)); read line; do
pkg=${line%==*}
NEW_VERSION=${line#*==}
NEW_VR=$NEW_VERSION
SPEC_FILE="packages/python-$pkg/python-$pkg.spec"
rpm_version=$(rpmspec -q --queryformat='%{version}' packages/python-$pkg/python-$pkg.spec --srpm)
rpmdev-vercmp $rpm_version $NEW_VERSION
exit_code=$?
if [ 12 -eq $exit_code ];
then
echo "RPM for Package $pkg needs to be updated from $rpm_version to $NEW_VERSION"
TARBALL_TO_REMOVE=$(spectool --list-files $SPEC_FILE | cut -d' ' -f2 | grep http | xargs --no-run-if-empty -n 1 basename)
git rm packages/python-$pkg/$TARBALL_TO_REMOVE
rpmdev-bumpspec --comment "- Update to ${NEW_VERSION}" --new "${NEW_VR}" $SPEC_FILE
git add $SPEC_FILE
spectool --get-files $SPEC_FILE -C packages/python-$pkg
TARBALL_ADDED=$(spectool --list-files $SPEC_FILE | cut -d' ' -f2 | grep http | xargs --no-run-if-empty -n 1 basename)
git annex add packages/python-$pkg/$TARBALL_ADDED
fi
if [ 0 -eq $exit_code ];
then
echo "Package $pkg version is the same as the packaged RPM"
fi
if [ 11 -eq $exit_code ];
then
echo "Packaged $pkg RPM is newer than version in requirements"
fi
done < $PACKAGE_TO_UPDATE
output:
- name: Open a PR
if: github.event_name == 'push' && github.head_ref == 'rpm/develop'
uses: peter-evans/create-pull-request@v6
with:

Check failure on line 74 in .github/workflows/update-pulp-packages.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/update-pulp-packages.yml

Invalid workflow file

You have an error in your yaml syntax on line 74
commit-message: "Update ${{ pkg }}" to ${{ NEW_VERSION }}""
branch: "bump_rpm/${{ pkg }}"
title: "Update ${{ pkg }}to ${{ NEW_VERSION }}"
body: ''
delete-branch: true