-
-
Notifications
You must be signed in to change notification settings - Fork 168
260 lines (227 loc) · 9.86 KB
/
Copy pathaur.yml
File metadata and controls
260 lines (227 loc) · 9.86 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: AUR Package
on:
push:
paths:
- 'aur/**'
pull_request:
paths:
- 'aur/**'
workflow_run:
workflows: ["Build and Release"]
types: [completed]
# Publish to the AUR without cutting a full release. The PKGBUILD and .SRCINFO are
# pushed exactly as committed, so their checksums must already match the published
# release assets.
workflow_dispatch:
inputs:
package:
description: 'AUR package to publish'
type: choice
options:
- lcl-gui-bin
- lcl-bin
- both
default: lcl-gui-bin
jobs:
validate:
name: Validate PKGBUILDs
if: github.event_name != 'workflow_run'
runs-on: ubuntu-latest
container: archlinux:base-devel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup build user
run: |
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
chown -R builder:builder .
- name: Install namcap
run: pacman -Sy --noconfirm namcap
- name: Lint lcl-bin PKGBUILD
working-directory: aur/lcl-bin
run: namcap PKGBUILD
- name: Validate lcl-bin .SRCINFO
working-directory: aur/lcl-bin
run: |
su builder -c "makepkg --printsrcinfo" > .SRCINFO.generated
diff -u .SRCINFO .SRCINFO.generated
- name: Lint lcl-gui-bin PKGBUILD
working-directory: aur/lcl-gui-bin
run: namcap PKGBUILD
- name: Validate lcl-gui-bin .SRCINFO
working-directory: aur/lcl-gui-bin
run: |
su builder -c "makepkg --printsrcinfo" > .SRCINFO.generated
diff -u .SRCINFO .SRCINFO.generated
publish:
name: Publish to AUR
if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
container: archlinux:base-devel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup build user
run: |
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
- name: Install dependencies
run: pacman -Sy --noconfirm openssh git
- name: Get version from release
id: version
run: echo "version=$(echo '${{ github.event.workflow_run.head_branch }}' | sed 's/^v//')" >> $GITHUB_OUTPUT
- name: Update PKGBUILDs and checksums
run: |
VERSION="${{ steps.version.outputs.version }}"
BASE="https://github.com/SimonSchubert/LinuxCommandLibrary/releases/download/v${VERSION}"
fetch_sha() {
local url=$1 dest=$2
echo "fetching $url" >&2
curl -fL --retry 5 --retry-delay 10 -o "$dest" "$url"
sha256sum "$dest" | cut -d' ' -f1
rm -f "$dest"
}
CLI_SHA256=$(fetch_sha "$BASE/LinuxCommandLibrary-${VERSION}-cli-linux-x64.zip" /tmp/cli.zip)
GUI_X64_SHA256=$(fetch_sha "$BASE/LinuxCommandLibrary-${VERSION}-linux-gui-x86_64.tar.gz" /tmp/gui-x64.tar.gz)
GUI_ARM_SHA256=$(fetch_sha "$BASE/LinuxCommandLibrary-${VERSION}-linux-gui-aarch64.tar.gz" /tmp/gui-arm.tar.gz)
# Update lcl-bin PKGBUILD (x86_64 CLI zip)
cd aur/lcl-bin
sed -i "s|^pkgver=.*|pkgver=${VERSION}|" PKGBUILD
sed -i "s|^pkgrel=.*|pkgrel=1|" PKGBUILD
sed -i "s|^sha256sums=.*|sha256sums=('${CLI_SHA256}')|" PKGBUILD
chown -R builder:builder .
su builder -c "makepkg --printsrcinfo" > .SRCINFO
echo "=== lcl-bin PKGBUILD ==="
cat PKGBUILD
# Update lcl-gui-bin PKGBUILD (Qt tarballs, per-arch checksums).
# 4.7.1 used a linux-gui-v* tag so it would not fire this workflow; full
# releases publish those tarballs on the v* GitHub release.
cd ../lcl-gui-bin
sed -i "s|^pkgver=.*|pkgver=${VERSION}|" PKGBUILD
sed -i "s|^pkgrel=.*|pkgrel=1|" PKGBUILD
sed -i 's|/download/linux-gui-v${pkgver}|/download/v${pkgver}|' PKGBUILD
sed -i "s|^sha256sums_x86_64=.*|sha256sums_x86_64=('${GUI_X64_SHA256}')|" PKGBUILD
sed -i "s|^sha256sums_aarch64=.*|sha256sums_aarch64=('${GUI_ARM_SHA256}')|" PKGBUILD
grep -q "sha256sums_x86_64=('${GUI_X64_SHA256}')" PKGBUILD
grep -q "sha256sums_aarch64=('${GUI_ARM_SHA256}')" PKGBUILD
grep -q "/download/v\${pkgver}" PKGBUILD
chown -R builder:builder .
su builder -c "makepkg --printsrcinfo" > .SRCINFO
echo "=== lcl-gui-bin PKGBUILD ==="
cat PKGBUILD
- name: Push to AUR
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
# Setup SSH - use system-wide known_hosts to avoid HOME mismatch in containers
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> /etc/ssh/ssh_known_hosts
for dir in "$HOME" "/root"; do
mkdir -p "$dir/.ssh"
echo "$AUR_SSH_KEY" > "$dir/.ssh/aur"
chmod 600 "$dir/.ssh/aur"
printf "Host aur.archlinux.org\n IdentityFile %s/.ssh/aur\n User aur\n" "$dir" > "$dir/.ssh/config"
chmod 700 "$dir/.ssh"
chmod 600 "$dir/.ssh/config"
done
git config --global user.name "Simon Schubert"
git config --global user.email "sschubert89@gmail.com"
VERSION="${{ steps.version.outputs.version }}"
# Push lcl-bin
cd /tmp
git clone ssh://aur@aur.archlinux.org/lcl-bin.git
cp $GITHUB_WORKSPACE/aur/lcl-bin/PKGBUILD lcl-bin/
cp $GITHUB_WORKSPACE/aur/lcl-bin/.SRCINFO lcl-bin/
cd lcl-bin
git add PKGBUILD .SRCINFO
git commit -m "Update to ${VERSION}"
git push
# Push lcl-gui-bin
cd /tmp
git clone ssh://aur@aur.archlinux.org/lcl-gui-bin.git
cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/PKGBUILD lcl-gui-bin/
cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/.SRCINFO lcl-gui-bin/
cd lcl-gui-bin
git add PKGBUILD .SRCINFO
git commit -m "Update to ${VERSION}"
git push
- name: Update repo PKGBUILDs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
cd /tmp
git clone --depth 1 https://x-access-token:${GITHUB_TOKEN}@github.com/SimonSchubert/LinuxCommandLibrary.git lcl-repo
cd lcl-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
cp $GITHUB_WORKSPACE/aur/lcl-bin/PKGBUILD aur/lcl-bin/PKGBUILD
cp $GITHUB_WORKSPACE/aur/lcl-bin/.SRCINFO aur/lcl-bin/.SRCINFO
cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/PKGBUILD aur/lcl-gui-bin/PKGBUILD
cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/.SRCINFO aur/lcl-gui-bin/.SRCINFO
git add aur/
git commit -m "Update AUR packages to ${VERSION}" || exit 0
git push
publish-manual:
name: Publish to AUR (manual)
if: github.event_name == 'workflow_dispatch'
needs: validate
runs-on: ubuntu-latest
container: archlinux:base-devel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: pacman -Sy --noconfirm openssh git
- name: Verify sources are reachable and checksums match
run: |
pacman -Sy --noconfirm curl
for pkg in lcl-bin lcl-gui-bin; do
[ "${{ inputs.package }}" = "both" ] || [ "${{ inputs.package }}" = "$pkg" ] || continue
echo "== $pkg =="
# .SRCINFO carries fully resolved URLs; the PKGBUILD builds them from a
# variable, so its source lines are not literal URLs. Sources and their
# checksums appear in matching order, including the per-arch pairs.
srcinfo="aur/$pkg/.SRCINFO"
while read -r url want; do
[ "$want" = "SKIP" ] && { echo " skipping $url"; continue; }
echo " fetching $url"
curl -fsSL -o /tmp/asset "$url"
got=$(sha256sum /tmp/asset | cut -d' ' -f1)
if [ "$got" != "$want" ]; then
echo " MISMATCH: expected $want, got $got"
exit 1
fi
echo " ok $got"
done < <(paste <(grep -E '^[[:space:]]+source' "$srcinfo" | sed 's/.*:://') \
<(grep -E '^[[:space:]]+sha256sums' "$srcinfo" | awk '{print $3}'))
done
- name: Push to AUR
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> /etc/ssh/ssh_known_hosts
for dir in "$HOME" "/root"; do
mkdir -p "$dir/.ssh"
echo "$AUR_SSH_KEY" > "$dir/.ssh/aur"
chmod 600 "$dir/.ssh/aur"
printf "Host aur.archlinux.org\n IdentityFile %s/.ssh/aur\n User aur\n" "$dir" > "$dir/.ssh/config"
chmod 700 "$dir/.ssh"
chmod 600 "$dir/.ssh/config"
done
git config --global user.name "Simon Schubert"
git config --global user.email "sschubert89@gmail.com"
for pkg in lcl-bin lcl-gui-bin; do
[ "${{ inputs.package }}" = "both" ] || [ "${{ inputs.package }}" = "$pkg" ] || continue
version=$(grep -oP '^pkgver=\K.*' "$GITHUB_WORKSPACE/aur/$pkg/PKGBUILD")
cd /tmp
rm -rf "$pkg"
git clone "ssh://aur@aur.archlinux.org/$pkg.git"
cp "$GITHUB_WORKSPACE/aur/$pkg/PKGBUILD" "$pkg/"
cp "$GITHUB_WORKSPACE/aur/$pkg/.SRCINFO" "$pkg/"
cd "$pkg"
git add PKGBUILD .SRCINFO
git diff --cached --quiet && { echo "$pkg unchanged, skipping"; continue; }
git commit -m "Update to $version"
git push
done