Skip to content

build

build #856

Workflow file for this run

name: build
on:
push:
workflow_dispatch:
schedule:
- cron: '45 15 * * *'
concurrency:
group: packages
cancel-in-progress: true
jobs:
build-packages:
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
permissions:
contents: write
actions: write
steps:
- name: Cache packages
uses: actions/cache/restore@v4
id: packages-cache
with:
key: packages
path: |
/var/cache/pacman
~/.cache/paru
- name: Upgrade system
run: |
pacman-key --init
pacman -Sy --needed --noconfirm archlinux-keyring
pacman -Syu --noconfirm --needed reflector git ccache github-cli pacman-contrib
sed -i '/E_ROOT/d' /usr/bin/makepkg
- name: Add unofficial user repositories
run: |
cat << _EOF >> /etc/pacman.conf
[archlinuxcn]
Server = ${{ vars.ALCN_MIRROR || 'https://repo.archlinuxcn.org' }}/\$arch
_EOF
pacman-key --lsign-key '[email protected]'
pacman -Sy --noconfirm && pacman -S --noconfirm archlinuxcn-keyring
pacman -Syu --noconfirm
- name: Update mirrorlist
run: |
reflector --protocol https --latest 10 --save /etc/pacman.d/mirrorlist || exit 0
- name: Enable ccache for makepkg
run: |
sed -i 's/!ccache/ccache/g' /etc/makepkg.conf
echo 'MAKEFLAGS="-j$(nproc --all)"' >> /etc/makepkg.conf
- uses: actions/cache/restore@v4
id: ccache-restore
with:
path: ~/.cache/ccache
key: arch-ccache
- uses: actions/checkout@v4
- name: Install aur helper
run: |
pacman -S --noconfirm paru && exit 0
git clone https://aur.archlinux.org/paru.git
pushd paru
makepkg --noconfirm --rmdeps -si
popd
rm -rf paru
- name: Skip paru uid check
run: |
cat << _EOF | gcc -Wall -fPIC -shared -o /tmp/libuid.so -x c -
#include <bits/types.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
__uid_t getuid(void) {
char buf[1024];
realpath("/proc/self/exe", buf);
if (strcmp(buf, "/usr/bin/paru") == 0) return 1000;
return syscall(SYS_getuid);
}
_EOF
- name: Build packages
run: |
paru -Su --noconfirm --skipreview ${{ vars.PRE_INSTALL }}
for dir in *${{ github.event_name == 'schedule' && '-git' || '' }}/; do
echo ::group::$dir
pushd "$dir"
LD_PRELOAD=/tmp/libuid.so paru -U --noconfirm --skipreview
popd
echo ::endgroup::
done
- name: Clear GitHub action cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory '*'
gh extension install actions/gh-actions-cache
if ${{ steps.ccache-restore.outputs.cache-hit == 'true' }}; then
gh actions-cache delete arch-ccache --confirm
fi
if ${{ steps.packages-cache.outputs.cache-hit == 'true' }}; then
gh actions-cache delete packages --confirm
fi
- name: Clean cache
run: |
paccache -rvvv -k 1
shopt -s nullglob
aurs=$(pacman -Qmq) || exit 0
for fn in ~/.cache/paru/clone/*; do
if [ $(comm -12 <(grep 'pkgname' "$fn"/.SRCINFO | cut -d \ -f 3 | sort) <(echo "$aurs") | wc -l) -eq 0 ]; then
echo removing "$fn"
rm -rf "$fn"
fi
done
- name: Save package cache
if: always()
uses: actions/cache/save@v4
with:
key: packages
path: |
/var/cache/pacman
~/.cache/paru
- uses: actions/cache/save@v4
if: always()
with:
path: ~/.cache/ccache
key: arch-ccache
- uses: softprops/action-gh-release@v1
if: ${{ github.ref_name == 'master' }}
with:
tag_name: latest
files: |
*/*.pkg.tar.zst