archlinux-aur/.forgejo/actions/update-aur-package/action.yaml
xengi 2964488bfe Update .forgejo/actions/update-aur-package/action.yaml
Signed-off-by: xengi <forgejo@xengi.de>
2026-08-14 11:48:37 +02:00

148 lines
5.1 KiB
YAML

name: Update AUR package
description: Build, test and optionally publish an AUR package
inputs:
package-name:
description: AUR package name
required: true
upstream-version:
description: Upstream version
required: true
aur-version:
description: Current AUR package version
required: true
aur-dependencies:
description: Space-separated AUR packages required to build this package
required: false
default: ''
test-command:
description: Command(s) used to test the installed package
required: true
commit-message:
description: Git commit message
required: false
default: bumped package version
notify-message:
description: Pushover success message
required: true
git-package:
description: Treat the package as a VCS/git package and publish when PKGBUILD or .SRCINFO changes
required: false
default: 'false'
aur-ssh-private-key:
description: SSH private key to login to the AUR
required: true
pushover-api-token:
description: API token for Pushover service
required: true
pushover-user-key:
description: User key for Pushover service
required: true
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: yay -Sy --needed --noconfirm --noprogressbar curl jq namcap openssh git
- name: Setup SSH
shell: bash
env:
AUR_SSH_PRIVATE_KEY: ${{ inputs.aur-ssh-private-key }}
run: |
mkdir -p ~/.ssh
echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Clone AUR repository
shell: bash
run: git clone "ssh://aur@aur.archlinux.org/${{ inputs.package-name }}.git"
- name: Install AUR dependencies
if: ${{ inputs.aur-dependencies != '' }}
shell: bash
run: |
yay -S \
--needed \
--noconfirm \
--noprogressbar \
--asdeps \
${{ inputs.aur-dependencies }}
- name: Update package
id: update
shell: bash
working-directory: ${{ inputs.package-name }}
run: |
if [ "${{ inputs.git-package }}" != "true" ]; then
sed -i "s/^pkgver=.*/pkgver=${{ inputs.upstream-version }}/" PKGBUILD
if [ "${{ inputs.upstream-version }}" != "${{ inputs.aur-version }}" ]; then
sed -i 's/^pkgrel=.*/pkgrel=1/' PKGBUILD
fi
fi
updpkgsums
makepkg --printsrcinfo > .SRCINFO
if [ "${{ inputs.git-package }}" = "true" ] &&
! git diff --quiet -- PKGBUILD .SRCINFO; then
echo "modified=yes" >> "$FORGEJO_OUTPUT"
fi
- name: Test package
shell: bash
working-directory: ${{ inputs.package-name }}
run: |
makepkg -csi --noconfirm --noprogressbar
namcap -i PKGBUILD
namcap -i "${{ inputs.package-name }}-"*.pkg.tar.zst
${{ inputs.test-command }}
- name: Upload new package
if: ${{ inputs.git-package == 'true' && steps.update.outputs.modified == 'yes' || inputs.git-package != 'true' && inputs.upstream-version != inputs.aur-version }}
shell: bash
working-directory: ${{ inputs.package-name }}
env:
PUSHOVER_API_TOKEN: ${{ inputs.pushover-api-token }}
PUSHOVER_USER_KEY: ${{ inputs.pushover-user-key }}
run: |
git config user.name "update-bot"
git config user.email "email@ricardo.band"
git commit -m "${{ inputs.commit-message }}" .SRCINFO PKGBUILD
git push
curl -fsSL \
--form-string "token=$PUSHOVER_API_TOKEN" \
--form-string "user=$PUSHOVER_USER_KEY" \
--form-string "priority=-2" \
--form-string "sound=hey_listen" \
--form-string "timestamp=$(date +%s)" \
--form-string "title=AUR package ${{ inputs.package-name }}" \
--form-string "message=${{ inputs.notify-message }}" \
--form-string "url_title=Forgejo Pipeline" \
--form-string "url=${{ env.FORGEJO_SERVER_URL }}/${{ env.FORGEJO_REPOSITORY }}/actions?workflow=packages.yaml&actor=0&status=0" \
https://api.pushover.net/1/messages.json
- name: Send notification
if: ${{ failure() }}
shell: bash
env:
PUSHOVER_API_TOKEN: ${{ inputs.pushover-api-token }}
PUSHOVER_USER_KEY: ${{ inputs.pushover-user-key }}
run: |
curl -sL \
--form-string "token=$PUSHOVER_API_TOKEN" \
--form-string "user=$PUSHOVER_USER_KEY" \
--form-string "priority=0" \
--form-string "sound=hey_listen" \
--form-string "timestamp=$(date +%s)" \
--form-string "title=AUR package ${{ inputs.package-name }} failure" \
--form-string "message=Updating ${{ inputs.package-name }} from ${{ inputs.aur-version }} to ${{ inputs.upstream-version }} failed." \
--form-string "url_title=Forgejo Pipeline" \
--form-string "url=${{ env.FORGEJO_SERVER_URL }}/${{ env.FORGEJO_REPOSITORY }}/actions?workflow=packages.yaml&actor=0&status=0" \
https://api.pushover.net/1/messages.json || true