From 205e914a60e982826c97d514a00db717880c7ccf Mon Sep 17 00:00:00 2001 From: susurri Date: Wed, 15 Mar 2023 08:49:22 +0900 Subject: [PATCH 1/3] feat: add run_command to run a command after installing the package - add base-devel package which is required to do makepkg in many packages - use yay-bin to install dependencies - makepkg -si to install the package - run command to make sure the installed package works well --- Dockerfile | 2 +- action.yml | 3 +++ build.sh | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index baa1e14..3ec4bac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN pacman -S --noconfirm --needed --overwrite '*' \ git fakeroot binutils gcc awk binutils xz \ libarchive bzip2 coreutils file findutils \ gettext grep gzip sed ncurses util-linux \ - pacman-contrib + pacman-contrib base-devel COPY entrypoint.sh /entrypoint.sh COPY build.sh /build.sh diff --git a/action.yml b/action.yml index 6ce6b01..f7d8e0c 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,9 @@ inputs: description: 'Command line flags for makepkg to build the package (if `test` is enabled)' required: false default: '--clean --cleanbuild --nodeps' + run_command: + description: 'Command to run after installing the package' + required: false commit_username: description: 'The username to use when creating the new commit' required: true diff --git a/build.sh b/build.sh index dcd6db5..f8ab704 100755 --- a/build.sh +++ b/build.sh @@ -9,6 +9,7 @@ assets=$INPUT_ASSETS updpkgsums=$INPUT_UPDPKGSUMS test=$INPUT_TEST read -r -a test_flags <<< "$INPUT_TEST_FLAGS" +run_command=$INPUT_RUN_COMMAND commit_username=$INPUT_COMMIT_USERNAME commit_email=$INPUT_COMMIT_EMAIL ssh_private_key=$INPUT_SSH_PRIVATE_KEY @@ -92,6 +93,16 @@ cd /tmp/local-repo makepkg --printsrcinfo >.SRCINFO echo '::endgroup::' +if [ -n "$run_command" ]; then + echo '::group::Installing package with makepkg and run command' + git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si --noconfirm + cd /tmp/local-repo/ + grep -E 'depends' .SRCINFO | cut -f 3 -d ' '| sed -e 's/://' | xargs yay -S --noconfirm + makepkg -si --noconfirm + eval "$run_command" + echo '::endgroup::' +fi + echo '::group::Committing files to the repository' if [[ -z "$assets" ]]; then # When $assets are not set, we can add just PKGBUILD and .SRCINFO From 1433afb97332e554d98e1edd0335967762d8a06e Mon Sep 17 00:00:00 2001 From: susurri Date: Fri, 17 Mar 2023 02:11:29 +0900 Subject: [PATCH 2/3] doc: update README.md describing the "run_command" input --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 56464ac..0369c05 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ Glob patterns will be expanded by bash when copying the files to the repository. **Optional** Command line flags for makepkg to build the package (if `test` is enabled). The default flags are `--clean --cleanbuild --nodeps`. +### `run_command` + +**Optional** Install the package and run the specified command to make sure the installed package works. + ### `commit_username` **Required** The username to use when creating the new commit. From ab00d5a4440e255d4c0cd6d7d8178b04b1c66b5c Mon Sep 17 00:00:00 2001 From: susurri Date: Sat, 18 Mar 2023 08:42:29 +0900 Subject: [PATCH 3/3] rename run_command to post_process following the suggestions https://github.com/KSXGitHub/github-actions-deploy-aur/pull/33#issuecomment-1473498385 - no extra package is installed --- Dockerfile | 2 +- README.md | 4 ++-- action.yml | 5 +++-- build.sh | 11 ++++------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ec4bac..baa1e14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN pacman -S --noconfirm --needed --overwrite '*' \ git fakeroot binutils gcc awk binutils xz \ libarchive bzip2 coreutils file findutils \ gettext grep gzip sed ncurses util-linux \ - pacman-contrib base-devel + pacman-contrib COPY entrypoint.sh /entrypoint.sh COPY build.sh /build.sh diff --git a/README.md b/README.md index 0369c05..90c7fbc 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ Glob patterns will be expanded by bash when copying the files to the repository. **Optional** Command line flags for makepkg to build the package (if `test` is enabled). The default flags are `--clean --cleanbuild --nodeps`. -### `run_command` +### `post_process` -**Optional** Install the package and run the specified command to make sure the installed package works. +**Optional** A line of commands to execute after processing the package. ### `commit_username` diff --git a/action.yml b/action.yml index f7d8e0c..80aa20f 100644 --- a/action.yml +++ b/action.yml @@ -27,9 +27,10 @@ inputs: description: 'Command line flags for makepkg to build the package (if `test` is enabled)' required: false default: '--clean --cleanbuild --nodeps' - run_command: - description: 'Command to run after installing the package' + post_process: + description: 'A line of commands to execute after processing the package' required: false + default: '' commit_username: description: 'The username to use when creating the new commit' required: true diff --git a/build.sh b/build.sh index f8ab704..334f319 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ assets=$INPUT_ASSETS updpkgsums=$INPUT_UPDPKGSUMS test=$INPUT_TEST read -r -a test_flags <<< "$INPUT_TEST_FLAGS" -run_command=$INPUT_RUN_COMMAND +post_process=$INPUT_POST_PROCESS commit_username=$INPUT_COMMIT_USERNAME commit_email=$INPUT_COMMIT_EMAIL ssh_private_key=$INPUT_SSH_PRIVATE_KEY @@ -93,13 +93,10 @@ cd /tmp/local-repo makepkg --printsrcinfo >.SRCINFO echo '::endgroup::' -if [ -n "$run_command" ]; then - echo '::group::Installing package with makepkg and run command' - git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -si --noconfirm +if [ -n "$post_process" ]; then + echo '::group::Executing post process commands' cd /tmp/local-repo/ - grep -E 'depends' .SRCINFO | cut -f 3 -d ' '| sed -e 's/://' | xargs yay -S --noconfirm - makepkg -si --noconfirm - eval "$run_command" + eval "$post_process" echo '::endgroup::' fi