Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Slinet6056 committed Sep 4, 2024
1 parent 7c8e5c4 commit f41d0eb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ name: Test build

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@master

- name: Build Package
uses: ./
with:
package_name: ciallo
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Build Package
uses: ./
with:
package_name: ciallo
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
pkgs_directory: test

- name: Upload Package
uses: actions/upload-artifact@main
with:
name: ciallo-package
path: test/ciallo/*.pkg.tar.zst*
- name: Upload Package
uses: actions/upload-artifact@main
with:
name: ciallo-package
path: test/ciallo/*.pkg.tar.zst*
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ FROM archlinux:base-devel

RUN pacman -Syu --noconfirm
RUN pacman -S git gnupg --noconfirm

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ inputs:
gpg_passphrase:
description: "GPG passphrase for building"
required: true
pkgs_directory:
description: "Directory of package subdirectories"
required: false
default: "."
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.package_name }}
- ${{ inputs.gpg_private_key }}
- ${{ inputs.gpg_passphrase }}
- ${{ inputs.pkgs_directory }}
35 changes: 22 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ set -e
pkgname=$1
gpg_private_key=$2
gpg_passphrase=$3

# Create builder user
useradd builder -m
echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
pkgdir=$4

# Find the PKGBUILD directory
pkgbuild_dir=$(readlink -f "$pkgname")
pkgbuild_dir=$(readlink -f "$pkgdir/$pkgname")

if [[ ! -d $pkgbuild_dir ]]; then
echo "$pkgbuild_dir should be a directory."
Expand All @@ -23,20 +20,32 @@ if [[ ! -e $pkgbuild_dir/PKGBUILD ]]; then
exit 1
fi

# Fix directory permissions
# Create builder user
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
mkdir -p /home/builder/.gnupg
chown -R builder:builder /home/builder/.gnupg
chmod 700 /home/builder/.gnupg
chown -R builder:builder "$pkgbuild_dir"
chown -R builder:builder /home/builder

# Import GPG key
echo "$gpg_private_key" | sudo -u builder gpg --import
echo "$gpg_passphrase" | sudo -u builder gpg --batch --passphrase-fd 0 --pinentry-mode loopback -s /dev/null
sudo -u builder bash <<EOF
export HOME=/home/builder
echo "$gpg_private_key" | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
EOF

# Build package
cd "$pkgbuild_dir"
sudo -u builder bash <<EOF
export GPG_TTY=\$(tty)
echo "$gpg_passphrase" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback -s /dev/null
makepkg -srf --sign --noconfirm
cd "$pkgbuild_dir"
makepkg -srf --noconfirm
EOF

# Sign package
sudo -E -u builder bash <<EOF
export HOME=/home/builder
cd "$pkgbuild_dir"
echo "$gpg_passphrase" | gpg --pinentry-mode loopback --passphrase-fd 0 --detach-sign *.pkg.tar.zst
EOF

cd -

0 comments on commit f41d0eb

Please sign in to comment.