44set -o errexit -o pipefail -o nounset
55
66pkgname=$INPUT_PKGNAME
7+ pkgbuild=$INPUT_PKGBUILD
8+ assets=$INPUT_ASSETS
79commit_username=$INPUT_COMMIT_USERNAME
810commit_email=$INPUT_COMMIT_EMAIL
911ssh_private_key=$INPUT_SSH_PRIVATE_KEY
@@ -22,12 +24,16 @@ assert_non_empty() {
2224}
2325
2426assert_non_empty inputs.pkgname " $pkgname "
27+ assert_non_empty inputs.pkgbuild " $pkgbuild "
2528assert_non_empty inputs.commit_username " $commit_username "
2629assert_non_empty inputs.commit_email " $commit_email "
2730assert_non_empty inputs.ssh_private_key " $ssh_private_key "
2831
2932export HOME=/home/builder
3033
34+ # Ignore "." and ".." to prevent errors when glob pattern for assets matches hidden files
35+ GLOBIGNORE=" .:.."
36+
3137echo ' ::group::Adding aur.archlinux.org to known hosts'
3238ssh-keyscan -v -t " $ssh_keyscan_types " aur.archlinux.org >> ~/.ssh/known_hosts
3339echo ' ::endgroup::'
@@ -42,7 +48,7 @@ echo '::group::Checksums of SSH keys'
4248sha512sum ~ /.ssh/aur ~ /.ssh/aur.pub
4349echo ' ::endgroup::'
4450
45- echo ' ::group::Configuring git '
51+ echo ' ::group::Configuring Git '
4652git config --global user.name " $commit_username "
4753git config --global user.email " $commit_email "
4854echo ' ::endgroup::'
@@ -51,20 +57,35 @@ echo '::group::Cloning AUR package into /tmp/local-repo'
5157git clone -v " https://aur.archlinux.org/${pkgname} .git" /tmp/local-repo
5258echo ' ::endgroup::'
5359
54- echo ' ::group::Generating PKGBUILD and .SRCINFO'
55- cd /tmp/local-repo
56-
57- echo ' Copying PKGBUILD...'
58- cp -v /PKGBUILD ./
59-
60- echo " Updating .SRCINFO"
61- makepkg --printsrcinfo > .SRCINFO
60+ echo ' ::group::Copying files into /tmp/local-repo'
61+ {
62+ echo " Copying $pkgbuild "
63+ cp -r " $pkgbuild " /tmp/local-repo/
64+ }
65+ # shellcheck disable=SC2086
66+ # Ignore quote rule because we need to expand glob patterns to copy $assets
67+ {
68+ echo " Copying " $assets
69+ cp -rt /tmp/local-repo/ $assets
70+ }
71+ echo ' ::endgroup::'
6272
73+ echo ' ::group::Generating .SRCINFO'
74+ cd /tmp/local-repo
75+ makepkg --printsrcinfo > .SRCINFO
6376echo ' ::endgroup::'
6477
65- echo ' ::group::Publishing'
66- git remote add aur " ssh://aur@aur.archlinux.org/${pkgname} .git"
67- git add -fv PKGBUILD .SRCINFO
78+ echo ' ::group::Committing files to the repository'
79+ if [[ -z " $assets " ]]; then
80+ # When $assets are not set, we can add just PKGBUILD and .SRCINFO
81+ # This is to prevent unintended behaviour and maintain backwards compatibility
82+ git add -fv PKGBUILD .SRCINFO
83+ else
84+ # We cannot just re-use $assets because it contains absolute paths outside repository
85+ # But we can just add all files in the repository which should also include all $assets
86+ git add --all
87+ fi
88+
6889case " $allow_empty_commits " in
6990true)
7091 git commit --allow-empty -m " $commit_message "
@@ -77,6 +98,10 @@ false)
7798 exit 2
7899 ;;
79100esac
101+ echo ' ::endgroup::'
102+
103+ echo ' ::group::Publishing the repository'
104+ git remote add aur " ssh://aur@aur.archlinux.org/${pkgname} .git"
80105case " $force_push " in
81106true)
82107 git push -v --force aur master
0 commit comments