Fix: use passphrase preset

This commit is contained in:
2025-07-28 01:32:11 +08:00
parent 41c036c2a6
commit 52b03a8b3c

View File

@@ -12,6 +12,10 @@ inputs:
description: "Password of the gpg secret key to sign the package" description: "Password of the gpg secret key to sign the package"
required: false required: false
default: 'none' default: 'none'
gpg-keygrip:
description: "KeyGrip of the gpg secret key to sign the package"
required: false
default: 'none'
repo-name: repo-name:
description: "The repo name to be pushed to" description: "The repo name to be pushed to"
required: false required: false
@@ -46,8 +50,13 @@ runs:
run: | run: |
cd "${{ inputs.context }}" cd "${{ inputs.context }}"
if [[ "${{ inputs.gpg-password }}" != 'none' ]]; then if [[ "${{ inputs.gpg-password }}" != 'none' ]]; then
eval $(gpg-agent --daemon)
echo "${{ inputs.gpg-password }}" | \ echo "${{ inputs.gpg-password }}" | \
/usr/lib/gnupg/gpg-preset-passphrase --preset "${{ inputs.gpg-keygrip }}"
makepkg -sc --needed --noconfirm --sign makepkg -sc --needed --noconfirm --sign
killall gpg-agent
else else
makepkg -sc --needed --noconfirm makepkg -sc --needed --noconfirm
fi fi
@@ -72,10 +81,16 @@ runs:
- name: Add pkgs to repo db - name: Add pkgs to repo db
run: | run: |
if [[ "${{ inputs.gpg-password }}" != 'none' ]]; then if [[ "${{ inputs.gpg-password }}" != 'none' ]]; then
eval $(gpg-agent --daemon)
echo "${{ inputs.gpg-password }}" | \ echo "${{ inputs.gpg-password }}" | \
/usr/lib/gnupg/gpg-preset-passphrase --preset "${{ inputs.gpg-keygrip }}"
repo-add --verify --sign \ repo-add --verify --sign \
"repo/${{ inputs.repo-name }}.db.tar.gz" *.pkg.tar.zst -- "repo/${{ inputs.repo-name }}.db.tar.gz" *.pkg.tar.zst
mv *.pkg.tar.zst *.pkg.tar.zst.sig repo mv *.pkg.tar.zst *.pkg.tar.zst.sig repo
killall gpg-agent
else else
repo-add "repo/${{ inputs.repo-name }}.db.tar.zst" *.pkg.tar.zst repo-add "repo/${{ inputs.repo-name }}.db.tar.zst" *.pkg.tar.zst
mv *.pkg.tar.zst repo mv *.pkg.tar.zst repo