Alpine package builder action

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-07 14:53:08 +03:00
commit 4dc26f87b5
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
3 changed files with 77 additions and 0 deletions

61
action.yaml Normal file
View file

@ -0,0 +1,61 @@
name: "Build alpine package"
description: "Build alpine package using pmbootstrap"
inputs:
name:
description: "aport name to build"
required: true
aports:
description: "directory containing the APKBUILD file"
required: true
arch:
description: "arch to build"
required: true
default: aarch64
src:
description: "source dir"
required: true
outputs:
packages:
description: "Built files"
value: ${{steps.built-packages.outputs.packages}}
runs:
using: "composite"
steps:
- name: Set up dirrectories
shell: sh
run: >
mkdir -p {{env.PMB_WORK}}/packages/edge/${{inputs.arch}} &&
mkdir -p ${{env.PMB_PMAPORTS}}/nekocwd &&
rm -rf ${{env.PMB_PMAPORTS}}/nekocwd/${{inputs.name}}
- name: List packages
id: old-packages
shell: sh
run: ${{ github.action_path }}/get_packages
env:
PKGDIR: ${{env.PMB_WORK}}/packages/edge/${{inputs.arch}}
- name: Copy APKBUILD to this dir
run: cp -rfpv ${{inputs.aports}} ${{env.PMB_PMAPORTS}}/nekocwd/${{inputs.name}}
shell: sh
- name: Run PostmarketOS build
run: pmbootstrap build --force ${{inputs.name}} --src ${{inputs.src}} --arch ${{inputs.arch}}
shell: sh
- name: List packages
id: new-packages
shell: sh
run: ${{ github.action_path }}/get_packages
env:
PKGDIR: ${{env.PMB_WORK}}/packages/edge/${{inputs.arch}}
- name: Get built packages
id: built-packages
shell: sh
run: ${{ github.action_path }}/get_exclusive
env:
OLD_PACKAGES: ${{steps.old-packages.outputs.packages}}
NEW_PACKAGES: ${{steps.new-packages.outputs.packages}}

15
get_exclusive Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
main_list=($NEW_PACKAGES)
remove_list=($OLD_PACKAGES)
temp_file=$(mktemp)
for line in "${main_list[@]}"; do
if ! printf '%s\n' "${remove_list[@]}" | grep -qx "$line"; then
echo "$line" >> "$temp_file"
fi
done
echo packages=$(cat $temp_file) >> $GITHUB_OUTPUT
rm "$temp_file"

1
get_packages Executable file
View file

@ -0,0 +1 @@
echo packages=$(ls ${PKGDIR}/*.apk 2> /dev/null || true) >> $GITHUB_OUTPUT