-
Notifications
You must be signed in to change notification settings - Fork 15
197 lines (167 loc) · 7.07 KB
/
Copy pathanylinux-packages.yaml
File metadata and controls
197 lines (167 loc) · 7.07 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
name: Add AnyLinux Packages
on:
schedule:
- cron: '0 10 * * 1' # Weekly on Monday
workflow_dispatch:
inputs:
repo:
description: 'Specific Anylinux-AppImages repo (e.g. htop-AppImage); empty = all missing'
type: string
default: ''
limit:
description: 'Max PRs to create per run'
type: string
default: '5'
dry_run:
description: 'Dry run (no PRs created)'
type: boolean
default: false
concurrency:
group: anylinux-packages
cancel-in-progress: true
jobs:
add-packages:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install sbuild
run: |
curl -fsSL "https://github.com/pkgforge/sbuilder/releases/download/nightly/sbuild-$(uname -m)-linux" \
-o /usr/local/bin/sbuild
chmod +x /usr/local/bin/sbuild
sbuild --version
- name: Find missing packages
id: missing
run: |
# Repos advertised by Anylinux-AppImages, minus the ones already
# packaged. Only the marked application table counts: the surrounding
# prose links tooling repos such as sharun and appimagetool, which are
# not AppImages and must not be packaged as if they were.
curl -sSL "https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/main/README.md" \
| awk '/APPS_LIST_START/,/APPS_LIST_END/' \
| grep -oP '^\|\s*\[[^]]+\]\(https://github\.com/pkgforge-dev/\K[A-Za-z0-9_.-]+(?=\))' \
| sort -u > /tmp/upstream.txt
if [ ! -s /tmp/upstream.txt ]; then
echo "::error::No applications found; the README layout may have changed"
exit 1
fi
grep -rhoP 'pkgforge-dev/\K[A-Za-z0-9_-]+' packages/*/pkg.toml 2>/dev/null \
| sort -u > /tmp/existing.txt
: > /tmp/missing.txt
while read -r repo; do
[ -n "$repo" ] || continue
grep -qix "$repo" /tmp/existing.txt && continue
# An enhanced build is the same application, so it keeps the
# plain name rather than carrying the variant into the package.
case "$repo" in
*-[Aa]pp[Ii]mage-[Ee]nhanced)
pkg=$(printf '%s' "${repo%-*-*}" | tr '[:upper:]' '[:lower:]') ;;
*-[Aa]pp[Ii]mage)
pkg=$(printf '%s' "${repo%-*}" | tr '[:upper:]' '[:lower:]') ;;
*)
pkg=$(printf '%s' "$repo" | tr '[:upper:]' '[:lower:]') ;;
esac
# Dropping the -enhanced suffix can land on a name already taken
# by the plain build of the same application.
if [ -d "packages/${pkg}" ]; then
echo "::notice::${repo} maps to ${pkg}, which is already packaged"
continue
fi
echo "$repo $pkg" >> /tmp/missing.txt
done < /tmp/upstream.txt
if [ -n "${{ inputs.repo }}" ]; then
grep -i "^${{ inputs.repo }} " /tmp/missing.txt > /tmp/missing-filtered.txt || {
echo "::warning::${{ inputs.repo }} is not in the missing list (already packaged or unknown)"
: > /tmp/missing-filtered.txt
}
mv /tmp/missing-filtered.txt /tmp/missing.txt
fi
COUNT=$(grep -c . /tmp/missing.txt || true)
echo "count=${COUNT}" >> $GITHUB_OUTPUT
if [ "$COUNT" -gt 0 ]; then
echo "::notice::Found ${COUNT} missing AnyLinux packages"
cat /tmp/missing.txt
else
echo "::notice::No missing packages"
fi
- name: Create package PRs
if: steps.missing.outputs.count > 0 && inputs.dry_run != true
env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
LIMIT='${{ inputs.limit }}'
LIMIT="${LIMIT:-5}"
created=0
while read -r repo pkg; do
[ -z "$repo" ] && continue
if [ "$created" -ge "$LIMIT" ]; then
echo "::notice::Reached limit of ${LIMIT} PRs, stopping"
break
fi
branch="bot/add-${pkg}"
# Skip if a PR (open or previously rejected) already exists
if gh pr list --head "$branch" --state all --json number | jq -e 'length > 0' > /dev/null 2>&1; then
echo "::notice::PR already exists for ${pkg}, skipping"
continue
fi
if git ls-remote --heads origin "$branch" | grep -q "$branch"; then
echo "::notice::Branch ${branch} already exists, skipping"
continue
fi
echo "::group::Creating PR for ${pkg} (${repo})"
git checkout main
git checkout -b "$branch"
# Scaffold, then pin. Resolve is what records the URL and hash;
# the scaffold deliberately leaves the human fields as TODO.
if ! sbuild new "$pkg" "pkgforge-dev/${repo}" --tag-suffix-strip \
|| ! sbuild resolve . "$pkg" \
|| ! sbuild hashfill; then
echo "::warning::Failed to generate package for ${pkg}"
git checkout main
git branch -D "$branch"
continue
fi
recipe_path="packages/${pkg}/pkg.toml"
git add "packages/${pkg}"
git commit -m "${pkg}: init"
git push origin "$branch"
PR_BODY=$(cat << EOF
## 📦 New AnyLinux Package
| Field | Value |
|-------|-------|
| **Package** | \`${pkg}\` |
| **Upstream** | [pkgforge-dev/${repo}](https://github.com/pkgforge-dev/${repo}) |
| **Recipe** | [\`${recipe_path}\`](https://github.com/${{ github.repository }}/blob/${branch}/${recipe_path}) |
### TODO before merge
- [ ] \`category\`: pick from [freedesktop menu spec](https://specifications.freedesktop.org/menu-spec/latest/apa.html)
- [ ] \`repology\`: verify at https://repology.org/projects/
- [ ] Review description/license/homepage
- [ ] `license`: verify upstream license
- [ ] Confirm the pinned hash matches upstream
---
<sub>🤖 This PR was automatically created from [Anylinux-AppImages](https://github.com/pkgforge-dev/Anylinux-AppImages)</sub>
EOF
)
gh pr create \
--draft \
--title "${pkg}: init" \
--body "$PR_BODY" \
--label "bot" \
--head "$branch" \
--base main
created=$((created + 1))
echo "::endgroup::"
git checkout main
# Rate limiting - avoid hitting GitHub API limits
sleep 2
done < /tmp/missing.txt
echo "::notice::Created ${created} PRs"