-
Notifications
You must be signed in to change notification settings - Fork 2
196 lines (172 loc) · 6.92 KB
/
build-aur.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Build AUR packages
on:
workflow_dispatch:
inputs:
run_description:
description: 'Custom description for this run'
required: true
default: 'Build AUR packages'
aur_package:
description: 'Base package name'
required: true
default: 'wine-osu-spectator'
env:
AUR_PACKAGE: ${{ github.event.inputs.aur_package || 'wine-osu-spectator' }}
PARU_CACHE: /home/builder/.cache/paru
PACKAGE_CACHE: /home/builder/package_cache
CACHE_KEY: stable-v1
_CCACHE_DIR: /home/builder/.cache/ccache
jobs:
build:
name: ${{ github.event.inputs.run_description }}
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create build user and directories
run: |
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
sudo -u builder mkdir -p ${{ env.PARU_CACHE }}/clone ${{ env.PACKAGE_CACHE }} ${{ env._CCACHE_DIR }}
- name: Initial system update and Node.js installation
run: |
pacman -Syu --noconfirm git nodejs npm
- name: Restore pacman setup and package cache
id: cache-restore
uses: actions/cache/restore@v3
with:
path: |
/etc/pacman.conf
/etc/pacman.d/chaotic-mirrorlist
/etc/pacman.d/gnupg
/etc/makepkg.conf
${{ env.PACKAGE_CACHE }}
${{ env._CCACHE_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_KEY }}
# Adding chaotic-aur for more prebuilt dependencies
- name: Set up system (if cache miss)
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
pacman-key --init
pacman-key --populate archlinux
echo -e "\n[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf
pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
pacman-key --lsign-key 3056513887B78AEB
pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst'
pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" >> /etc/pacman.conf
echo -e 'MAKEFLAGS="-j$(nproc)"' >> /etc/makepkg.conf
echo -e 'NINJAFLAGS="-j$(nproc)"' >> /etc/makepkg.conf
- name: Update package repositories
run: pacman -Syu --noconfirm
- name: Install cached packages
if: steps.cache-restore.outputs.cache-hit == 'true'
run: |
find ${{ env.PACKAGE_CACHE }} -name "*.pkg.tar.zst" -exec pacman -U --noconfirm {} +
- name: Setup and build paru
run: |
sudo -u builder bash << EOF
if ! paru --version 1>/dev/null; then
cd ${{ env.PARU_CACHE }}/clone
if [ ! -d "paru-bin" ]; then
git clone https://aur.archlinux.org/paru-bin.git
fi
cd paru-bin
makepkg -si --noconfirm --nocheck
else
echo "paru already installed, skipping build"
fi
EOF
- name: Install and configure customizepkg
run: |
sudo -u builder bash << EOF
if ! paru -Qiq customizepkg-git 1>/dev/null; then
paru -S --noconfirm customizepkg-git
else
echo "customizepkg-git already installed, skipping build"
fi
mkdir -p ~/.customizepkg
echo "replace#global#_generic_release=false#_generic_release=true" > ~/.customizepkg/${AUR_PACKAGE}
echo "replace#global#_generic_release=false#_generic_release=true" > ~/.customizepkg/${AUR_PACKAGE}-wow64
echo "replace#global#pkgver=3.5#pkgver=3.6" > ~/.customizepkg/lib32-x265
EOF
echo -e "\n[bin]\nPreBuildCommand = customizepkg --modify" >> /etc/paru.conf
- name: Build newer lib32-x265 manually for lib32-ffmpeg
run: |
sudo -u builder bash << EOF
if ! paru -Qq "lib32-x265>=3.6" 1>/dev/null; then
paru -S --noconfirm --nocheck lib32-x265
else
echo "lib32-x265>=3.6 already installed, skipping build"
fi
EOF
# Their git repo was down when I made this workflow...
- name: Build lib32-ffmpeg manually
run: |
rm -rf ${{ env.PARU_CACHE }}/clone/lib32-ffmpeg/pkg || true
sudo -u builder bash << EOF
if ! paru -Qiq lib32-ffmpeg 1>/dev/null; then
cd ${{ env.PARU_CACHE }}/clone
if [ ! -d "lib32-ffmpeg" ]; then
paru -G lib32-ffmpeg
fi
cd lib32-ffmpeg
sed -i 's|git+https://git.ffmpeg.org/ffmpeg.git?signed#tag=${_tag}|ffmpeg::git+https://github.com/FFmpeg/FFmpeg.git?signed#tag=${_tag}|' PKGBUILD
sed -i 's|enable-cuda|disable-cuda|' PKGBUILD
paru -B --install --noconfirm --nocheck --mflags "--skippgpcheck" .
else
echo "lib32-ffmpeg already installed, skipping build"
fi
EOF
- name: Build AUR packages
run: |
sudo -u builder bash << EOF
cd ~
paru -S --nocheck --noconfirm ${AUR_PACKAGE} --assume-installed=ntsync-dkms
paru -S --nocheck --noconfirm ${AUR_PACKAGE}-wow64 --assume-installed=ntsync-dkms
EOF
- name: Prepare artifacts
id: prepare_artifacts
run: |
sudo -u builder bash << EOF
mkdir -p /tmp/artifact/${AUR_PACKAGE}
mkdir -p /tmp/artifact/${AUR_PACKAGE}-wow64
mv ${{ env.PARU_CACHE }}/clone/${AUR_PACKAGE}/*.pkg.tar.xz /tmp/artifact/${AUR_PACKAGE}/
mv ${{ env.PARU_CACHE }}/clone/${AUR_PACKAGE}-wow64/*.pkg.tar.xz /tmp/artifact/${AUR_PACKAGE}-wow64/
rm -rf ${{ env.PARU_CACHE }}/clone/${AUR_PACKAGE}
rm -rf ${{ env.PARU_CACHE }}/clone/${AUR_PACKAGE}-wow64
EOF
- name: Upload regular package
uses: actions/upload-artifact@v4
with:
name: ${{ env.AUR_PACKAGE }}
path: /tmp/artifact/${{ env.AUR_PACKAGE }}
- name: Upload wow64 package
uses: actions/upload-artifact@v4
with:
name: ${{ env.AUR_PACKAGE }}-wow64
path: /tmp/artifact/${{ env.AUR_PACKAGE }}-wow64
- name: Consolidate intermediate compiled dependencies for caching
run: |
sudo -u builder bash << EOF
find ${{ env.PARU_CACHE }}/clone -name "*.pkg.tar.zst" -exec mv {} ${{ env.PACKAGE_CACHE }} \;
EOF
- name: Invalidate cache on failure (rerun action manually)
if: failure()
run: |
echo "Build process failed. Clearing cache (besides ccache)."
rm -rf /etc/pacman.conf /etc/pacman.d/chaotic-mirrorlist /etc/pacman.d/gnupg /etc/makepkg.conf ${{ env.PACKAGE_CACHE }}
- name: Save cache
if: always()
uses: actions/cache/save@v3
with:
path: |
/etc/pacman.conf
/etc/pacman.d/chaotic-mirrorlist
/etc/pacman.d/gnupg
/etc/makepkg.conf
${{ env.PACKAGE_CACHE }}
${{ env._CCACHE_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_KEY }}