-
Notifications
You must be signed in to change notification settings - Fork 2
231 lines (201 loc) · 8.41 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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'
push:
tags:
- '*'
branches:
- master
paths-ignore:
- '**'
env:
AUR_PACKAGE: ${{ github.event.inputs.aur_package || 'wine-osu-spectator' }}
PARU_CACHE: /home/builder/.cache/paru
PACKAGE_CACHE: /home/builder/package_cache
_CCACHE_DIR: /home/builder/.cache/ccache
PUBKEY: 0B47490955565BD2
GNUPGHOME: /home/builder/.gnupg
jobs:
build:
name: ${{ github.event.inputs.run_description }}
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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: Import GPG Key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5
with:
gpg_private_key: ${{ secrets.GPG_PRIV }}
passphrase: ${{ secrets.GPG_PASS }}
- name: Restore package cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
${{ env.PACKAGE_CACHE }}
${{ env._CCACHE_DIR }}
key: ${{ runner.os }}-${{ hashFiles('**pkg.tar.zst') }}
restore-keys: |
${{ runner.os }}
# Adding chaotic-aur for more prebuilt dependencies
- name: Set up system
run: |
chown -R builder:builder ${{ env.GNUPGHOME }}
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
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
env:
CURRENT_TAG: ${{ github.ref_name }}
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#^_patchbase_tag=.*#_patchbase_tag=${CURRENT_TAG}" >> ~/.customizepkg/${AUR_PACKAGE}
echo "replace#global#sha512sums+=.*#sha512sums+=('SKIP')" >> ~/.customizepkg/${AUR_PACKAGE}
echo "replace#global#_generic_release=false#_generic_release=true" > ~/.customizepkg/${AUR_PACKAGE}-wow64
echo "replace#global#^_patchbase_tag=.*#_patchbase_tag=${CURRENT_TAG}" >> ~/.customizepkg/${AUR_PACKAGE}-wow64
echo "replace#global#sha512sums+=.*#sha512sums+=('SKIP')" >> ~/.customizepkg/${AUR_PACKAGE}-wow64
EOF
echo -e "\n[bin]\nPreBuildCommand = customizepkg --modify" >> /etc/paru.conf
- name: Install llvm-mingw-w64-toolchain-msvcrt-bin
run: |
sudo -u builder bash << EOF
if ! paru -Qiq llvm-mingw-w64-toolchain-msvcrt-bin 1>/dev/null; then
paru -S --noconfirm llvm-mingw-w64-toolchain-msvcrt-bin
else
echo "llvm-mingw-w64-toolchain-msvcrt-bin already installed, skipping build"
fi
EOF
- name: Build AUR packages
run: |
sudo -u builder bash << EOF
cd ~
sleep 240
paru -S --nocheck --noconfirm --mflags "--skipinteg" ${AUR_PACKAGE} --assume-installed=ntsync-dkms
paru -S --nocheck --noconfirm --mflags "--skipinteg" ${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/
echo "${{ secrets.GPG_PASS }}" | gpg --batch --yes --passphrase-fd 0 --detach-sign --no-armor /tmp/artifact/${AUR_PACKAGE}/*.pkg.tar.xz
echo "${{ secrets.GPG_PASS }}" | gpg --batch --yes --passphrase-fd 0 --detach-sign --no-armor /tmp/artifact/${AUR_PACKAGE}-wow64/*.pkg.tar.xz
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@v4
with:
path: |
${{ env.PACKAGE_CACHE }}
${{ env._CCACHE_DIR }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
create-release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Extract version from package name
id: get_version
run: |
PKGFILE=$(ls artifacts/${{ env.AUR_PACKAGE }}/*.pkg.tar.xz | head -n1)
# from e.g. wine-osu-spectator-9.20.w1.s5a1b9d5-1-x86_64.pkg.tar.xz
# get VERSION=9.20 and RELEASE=1
VERSION=$(basename "$PKGFILE" | sed -E 's/.*-([0-9]+\.[0-9]+)\..*-([0-9]+)-.*pkg\.tar\.xz/\1/')
RELEASE=$(basename "$PKGFILE" | sed -E 's/.*-([0-9]+\.[0-9]+)\..*-([0-9]+)-.*pkg\.tar\.xz/\2/')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "RELEASE=$RELEASE" >> $GITHUB_OUTPUT
echo "FULL_VERSION=$VERSION-$RELEASE" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.AUR_PACKAGE }}-${{ steps.get_version.outputs.FULL_VERSION }}
draft: false
prerelease: false
files: |
artifacts/${{ env.AUR_PACKAGE }}/*.pkg.tar.xz*
artifacts/${{ env.AUR_PACKAGE }}-wow64/*.pkg.tar.xz*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}