Skip to content

Default values for pkgname and pkgbuild #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ GitHub Actions to publish AUR package.

### `pkgname`

**Required** AUR package name.
**Optional** AUR package name. If not specified the name will be extracted from the PKGBUILD file.

### `pkgbuild`

**Required** Path to PKGBUILD file. This file is often generated by prior steps.
**Optional** Path to PKGBUILD file. This file is often generated by prior steps. The default value is './PKGBUILD'

### `assets`

Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ branding:
icon: package
inputs:
pkgname:
description: 'AUR package name'
required: true
description: 'AUR package name, extracted from PKGBUILD if not specified'
required: false
pkgbuild:
description: 'Path to PKGBUILD file'
required: true
default: './PKGBUILD'
required: false
assets:
description: 'Newline-separated glob patterns for additional files to be added to the AUR repository'
required: false
Expand Down
21 changes: 19 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ assert_non_empty() {
fi
}

assert_non_empty inputs.pkgname "$pkgname"
assert_non_empty inputs.pkgbuild "$pkgbuild"
assert_non_empty inputs.commit_username "$commit_username"
assert_non_empty inputs.commit_email "$commit_email"
assert_non_empty inputs.ssh_private_key "$ssh_private_key"
Expand Down Expand Up @@ -53,6 +51,25 @@ git config --global user.name "$commit_username"
git config --global user.email "$commit_email"
echo '::endgroup::'

echo '::group::Getting pkgname'
if [[ -z "$pkgname" ]]; then
echo 'Extracting pkgname from PKGBUILD'

mkdir -p /tmp/makepkg
cp "$pkgbuild" /tmp/makepkg/PKGBUILD
info=$(cd /tmp/makepkg; makepkg --printsrcinfo)

pattern='pkgname = ([a-z0-9@._+-]*)'
[[ "$info" =~ $pattern ]]

pkgname="${BASH_REMATCH[1]}"
echo "Got pkgname '$pkgname'"
else
echo "Using pkgname '$pkgname' from argument"
assert_non_empty inputs.pkgname "$pkgname"
fi
echo '::endgroup::'

echo '::group::Cloning AUR package into /tmp/local-repo'
git clone -v "https://aur.archlinux.org/${pkgname}.git" /tmp/local-repo
echo '::endgroup::'
Expand Down