-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (129 loc) · 4.21 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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