generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 2
195 lines (165 loc) · 6.46 KB
/
build-repo.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
---
name: Build Pacman Repo
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
schedule:
- cron: "0 0 * * *"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build-pacman-repo:
runs-on: ubuntu-latest
container:
image: archlinux/archlinux:base-devel
env:
DISPLAY: ":1"
CONTAINER_DIR: pkgbuilds
strategy:
fail-fast: false
matrix:
include:
- repo: lizardbyte
release_name: stable
- repo: lizardbyte-beta
release_name: beta
steps:
- name: Container Setup
run: |
pacman -Syy --disable-download-timeout --needed --noconfirm \
archlinux-keyring
pacman -Syu --disable-download-timeout --needed --noconfirm \
base-devel \
cmake \
cuda \
git \
jq \
wget \
xorg-server-xvfb
pacman -Scc --noconfirm
- name: Download Pacman Repo Builder
run: |
wget \
"https://github.com/LizardByte/pacman-repo-builder/releases/latest/download/build-pacman-repo" \
-O /usr/bin/build-pacman-repo
chmod +x /usr/bin/build-pacman-repo
# patch makepkg to allow running as root
build-pacman-repo patch-makepkg --replace
- name: Checkout
uses: actions/checkout@v4
- name: Configure Git directory
# prevent fatal error when building stable matrix
if: matrix.release_name == 'stable'
run: git config --global --add safe.directory /__w/pacman-repo/pacman-repo
- name: Download and Patch beta PKGBUILDs
if: matrix.release_name == 'beta'
run: |
# we don't want any stable packages to be built, so remove them
rm -rf ${CONTAINER_DIR}
mkdir -p ${CONTAINER_DIR}
cd ${CONTAINER_DIR}
while IFS=' ' read -r repo og_pkg_name updated_pkg_name release_asset; do
# Skip lines that start with #
[[ $repo =~ ^#.*$ ]] && continue
echo "repo: ${repo}"
echo "og_pkg_name: ${og_pkg_name}"
echo "updated_pkg_name: ${updated_pkg_name}"
echo "release_asset: ${release_asset}"
# get the first release with the specified asset (pre-releases first, followed by stable)
latest_release=$(
curl -s "https://api.github.com/repos/${repo}/releases" | \
jq -r --arg release_asset "${release_asset}" '
map(.assets[] | select(.name == $release_asset) | .browser_download_url) |
first
'
)
echo "latest_release: ${latest_release}"
if [[ -z "${latest_release}" ]]; then
echo "::warning:: No pre-release found for ${repo} with asset ${release_asset}"
continue
fi
mkdir -p ${updated_pkg_name}
pushd ${updated_pkg_name}
wget "${latest_release}" -O "${updated_pkg_name}.pkg.tar.gz"
# extract the package
tar -xvf "${updated_pkg_name}.pkg.tar.gz"
rm "${updated_pkg_name}.pkg.tar.gz"
# sed PKGBUILD
sed -i "s/pkgname='${og_pkg_name}'/pkgname='${updated_pkg_name}'/" PKGBUILD
sed -i "s/provides=(.*)/provides=('${og_pkg_name}')/" PKGBUILD
sed -i "s/conflicts=(.*)/conflicts=('${og_pkg_name}')/" PKGBUILD
# Check if provides is missing and append if necessary
if ! grep -q "^provides=" PKGBUILD; then
echo "provides=('${og_pkg_name}')" >> PKGBUILD
fi
# Check if conflicts is missing and append if necessary
if ! grep -q "^conflicts=" PKGBUILD; then
echo "conflicts=('${og_pkg_name}')" >> PKGBUILD
fi
echo "new PKGBUILD:"
cat PKGBUILD
# re-generate .SRCINFO
makepkg --printsrcinfo > .SRCINFO
# list files
echo "files in ${updated_pkg_name}:"
ls -a
popd
done < ../beta-repos.conf
- name: Init
run: |
# create the destination directory for built packages
mkdir -p repo
# patch the build flags
sed -i 's,#MAKEFLAGS="-j2",MAKEFLAGS="-j$(nproc)",g' /etc/makepkg.conf
# start Xvfb which may be used for unit tests
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
- name: Build Pacman Repo
run: |
source /etc/profile # ensure cuda is in the PATH
# generate build-pacman-repo.yaml
build-pacman-repo print-config \
--repository repo/${{ matrix.repo }}.db.tar.gz \
--container ${CONTAINER_DIR} \
--require-pkgbuild \
--require-srcinfo \
--with-record-failed-builds repo/failed-build-records.yaml \
--with-install-missing-dependencies true \
--with-clean-before-build false \
--with-clean-after-build false \
--with-force-rebuild true \
--with-pacman pacman \
--with-arch-filter x86_64 \
--with-check inherit \
--with-packager "${{ secrets.GH_BOT_NAME }} <${{ secrets.GH_BOT_EMAIL }}>" \
--with-allow-failure false \
--with-dereference-database-symlinks true \
> build-pacman-repo.yaml
# validate .SRCINFO files
build-pacman-repo sync-srcinfo || \
echo "::warning:: .SRCINFO files mismatch" >> $GITHUB_STEP_SUMMARY && \
build-pacman-repo sync-srcinfo -u
# build the packages and create the repo
build-pacman-repo build
# ensure files are present in the repo
repo_files=$(ls repo)
if [[ -z "${repo_files}" ]]; then
echo "::error:: No files found in repo"
exit 1
fi
- name: Create/Update GitHub Release
if: github.event_name == 'schedule' || github.event_name == 'push'
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: repo/*
bodyFile: README.md
commit: master
makeLatest: ${{ matrix.release_name == 'stable' || false }}
name: ${{ matrix.release_name }}
prerelease: ${{ matrix.release_name == 'beta' || false }}
tag: ${{ matrix.release_name }}
token: ${{ secrets.GH_BOT_TOKEN }}