Skip to content

Commit beeaa2c

Browse files
authored
Merge pull request #21 from filips123/support-adding-assets
Add support for adding assets to AUR repository
2 parents 40901a3 + 08f677a commit beeaa2c

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ GitHub Actions to publish AUR package.
1212

1313
**Required** Path to PKGBUILD file. This file is often generated by prior steps.
1414

15+
### `assets`
16+
17+
**Optional** Newline-separated glob patterns for additional files to be added to the AUR repository.
18+
Glob patterns will be expanded by bash when copying the files to the repository.
19+
1520
### `commit_username`
1621

1722
**Required** The username to use when creating the new commit.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
pkgbuild:
1212
description: 'Path to PKGBUILD file'
1313
required: true
14+
assets:
15+
description: 'Newline-separated glob patterns for additional files to be added to the AUR repository'
16+
required: false
17+
default: ''
1418
commit_username:
1519
description: 'The username to use when creating the new commit'
1620
required: true

build.sh

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
set -o errexit -o pipefail -o nounset
55

66
pkgname=$INPUT_PKGNAME
7+
pkgbuild=$INPUT_PKGBUILD
8+
assets=$INPUT_ASSETS
79
commit_username=$INPUT_COMMIT_USERNAME
810
commit_email=$INPUT_COMMIT_EMAIL
911
ssh_private_key=$INPUT_SSH_PRIVATE_KEY
@@ -22,12 +24,16 @@ assert_non_empty() {
2224
}
2325

2426
assert_non_empty inputs.pkgname "$pkgname"
27+
assert_non_empty inputs.pkgbuild "$pkgbuild"
2528
assert_non_empty inputs.commit_username "$commit_username"
2629
assert_non_empty inputs.commit_email "$commit_email"
2730
assert_non_empty inputs.ssh_private_key "$ssh_private_key"
2831

2932
export HOME=/home/builder
3033

34+
# Ignore "." and ".." to prevent errors when glob pattern for assets matches hidden files
35+
GLOBIGNORE=".:.."
36+
3137
echo '::group::Adding aur.archlinux.org to known hosts'
3238
ssh-keyscan -v -t "$ssh_keyscan_types" aur.archlinux.org >>~/.ssh/known_hosts
3339
echo '::endgroup::'
@@ -42,7 +48,7 @@ echo '::group::Checksums of SSH keys'
4248
sha512sum ~/.ssh/aur ~/.ssh/aur.pub
4349
echo '::endgroup::'
4450

45-
echo '::group::Configuring git'
51+
echo '::group::Configuring Git'
4652
git config --global user.name "$commit_username"
4753
git config --global user.email "$commit_email"
4854
echo '::endgroup::'
@@ -51,20 +57,35 @@ echo '::group::Cloning AUR package into /tmp/local-repo'
5157
git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo
5258
echo '::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
6376
echo '::endgroup::'
6477

65-
echo '::group::Publishing'
66-
git remote add aur "ssh://[email protected]/${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+
6889
case "$allow_empty_commits" in
6990
true)
7091
git commit --allow-empty -m "$commit_message"
@@ -77,6 +98,10 @@ false)
7798
exit 2
7899
;;
79100
esac
101+
echo '::endgroup::'
102+
103+
echo '::group::Publishing the repository'
104+
git remote add aur "ssh://[email protected]/${pkgname}.git"
80105
case "$force_push" in
81106
true)
82107
git push -v --force aur master

entrypoint.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@
22

33
set -o errexit -o pipefail -o nounset
44

5-
pkgbuild=$INPUT_PKGBUILD
6-
75
echo '::group::Creating builder user'
86
useradd --create-home --shell /bin/bash builder
97
passwd --delete builder
108
echo '::endgroup::'
119

12-
echo '::group::Initializing ssh directory'
10+
echo '::group::Initializing SSH directory'
1311
mkdir -pv /home/builder/.ssh
1412
touch /home/builder/.ssh/known_hosts
1513
cp -v /ssh_config /home/builder/.ssh/config
1614
chown -vR builder:builder /home/builder
1715
chmod -vR 600 /home/builder/.ssh/*
1816
echo '::endgroup::'
1917

20-
echo '::group::Copying PKGBUILD'
21-
cp -r "$pkgbuild" /PKGBUILD
22-
echo '::endgroup::'
23-
2418
exec runuser builder --command 'bash -l -c /build.sh'

0 commit comments

Comments
 (0)