Skip to content

Commit 8ad3969

Browse files
committed
metadata
1 parent f2922e9 commit 8ad3969

File tree

3 files changed

+200
-2
lines changed

3 files changed

+200
-2
lines changed

.github/workflows/build-on-change.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ jobs:
104104
uses: ./.github/workflows/matrix_builds.yaml
105105
with:
106106
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ matrix.recipe.path }}"
107-
ghcr-url: ${{ contains(matrix.recipe.path, 'packages/') && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test' }}
107+
# Uses the repo owner's GHCR namespace for proper permissions
108+
ghcr-url: ${{ contains(matrix.recipe.path, 'packages/') && format('ghcr.io/{0}/pkgcache', github.repository_owner) || format('ghcr.io/{0}/bincache', github.repository_owner) }}
108109
pkg-family: ${{ github.event.repository.name }}
109110
rebuild: true
110111
logs: true

.github/workflows/manual-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
host: ${{ inputs.host }}
3636
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ inputs.recipe }}"
37-
ghcr-url: ${{ inputs.cache_type == 'auto' && (contains(inputs.recipe, 'packages/') && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test') || (inputs.cache_type == 'pkgcache' && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test') }}
37+
ghcr-url: ${{ inputs.cache_type == 'auto' && (contains(inputs.recipe, 'packages/') && 'ghcr.io/pkgforge/pkgcache' || 'ghcr.io/pkgforge/bincache') || (inputs.cache_type == 'pkgcache' && 'ghcr.io/pkgforge/pkgcache' || 'ghcr.io/pkgforge/bincache') }}
3838
pkg-family: ${{ github.event.repository.name }}
3939
rebuild: true
4040
logs: true
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Release Metadata
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
force:
7+
description: 'Force regeneration of all metadata'
8+
type: boolean
9+
default: false
10+
11+
concurrency:
12+
group: release-metadata
13+
cancel-in-progress: false
14+
15+
jobs:
16+
generate:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- arch: x86_64-Linux
22+
runner: ubuntu-latest
23+
- arch: aarch64-Linux
24+
runner: ubuntu-24.04-arm
25+
runs-on: ${{ matrix.runner }}
26+
permissions:
27+
contents: read
28+
packages: read
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Install tools
34+
run: |
35+
ARCH="$(uname -m)-linux"
36+
sudo apt-get update
37+
sudo apt-get install -y zstd xz-utils jq
38+
39+
# Download sbuild-meta
40+
curl -fsSL "https://github.com/pkgforge/sbuilder/releases/download/latest/sbuild-meta-${ARCH}" \
41+
-o /usr/local/bin/sbuild-meta || {
42+
echo "::error::Failed to download sbuild-meta"
43+
exit 1
44+
}
45+
chmod +x /usr/local/bin/sbuild-meta
46+
47+
sbuild-meta --version
48+
49+
- name: Generate bincache metadata
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
mkdir -p /tmp/output
54+
55+
# Note: For test repo, the packages are pushed to bincache-test
56+
# sbuild-meta will look for ghcr.io/pkgforge/bincache-test/<pkg>
57+
sbuild-meta generate \
58+
--arch "${{ matrix.arch }}" \
59+
--recipes ./binaries \
60+
--output /tmp/output \
61+
--cache-type bincache \
62+
--parallel 4 \
63+
--github-token "$GITHUB_TOKEN" || {
64+
echo "::warning::bincache metadata generation failed or no packages found"
65+
}
66+
67+
# Rename to include cache type
68+
if [ -f "/tmp/output/bincache/${{ matrix.arch }}.json" ]; then
69+
mv "/tmp/output/bincache/${{ matrix.arch }}.json" "/tmp/output/bincache-${{ matrix.arch }}.json"
70+
echo "::notice::bincache metadata generated"
71+
jq 'length' "/tmp/output/bincache-${{ matrix.arch }}.json"
72+
else
73+
echo "::warning::No bincache metadata generated"
74+
fi
75+
76+
- name: Generate pkgcache metadata
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: |
80+
sbuild-meta generate \
81+
--arch "${{ matrix.arch }}" \
82+
--recipes ./packages \
83+
--output /tmp/output \
84+
--cache-type pkgcache \
85+
--parallel 4 \
86+
--github-token "$GITHUB_TOKEN" || {
87+
echo "::warning::pkgcache metadata generation failed or no packages found"
88+
}
89+
90+
# Rename to include cache type
91+
if [ -f "/tmp/output/pkgcache/${{ matrix.arch }}.json" ]; then
92+
mv "/tmp/output/pkgcache/${{ matrix.arch }}.json" "/tmp/output/pkgcache-${{ matrix.arch }}.json"
93+
echo "::notice::pkgcache metadata generated"
94+
jq 'length' "/tmp/output/pkgcache-${{ matrix.arch }}.json"
95+
else
96+
echo "::warning::No pkgcache metadata generated"
97+
fi
98+
99+
- name: List outputs
100+
run: |
101+
echo "=== Generated files ==="
102+
ls -lah /tmp/output/ || echo "No files"
103+
104+
for f in /tmp/output/*.json; do
105+
if [ -f "$f" ]; then
106+
echo "=== $(basename $f) ==="
107+
jq '.[0:2]' "$f" 2>/dev/null || cat "$f"
108+
fi
109+
done
110+
111+
- name: Compress outputs
112+
run: |
113+
cd /tmp/output
114+
115+
for file in *.json; do
116+
if [ -f "$file" ]; then
117+
# Compress with zstd
118+
zstd -19 "$file" -o "${file}.zstd"
119+
fi
120+
done
121+
122+
ls -lah
123+
124+
- name: Upload artifacts
125+
uses: actions/upload-artifact@v4
126+
with:
127+
name: metadata-${{ matrix.arch }}
128+
path: |
129+
/tmp/output/*.json
130+
/tmp/output/*.json.zstd
131+
retention-days: 7
132+
133+
release:
134+
needs: generate
135+
runs-on: ubuntu-latest
136+
permissions:
137+
contents: write
138+
steps:
139+
- name: Download all artifacts
140+
uses: actions/download-artifact@v4
141+
with:
142+
path: /tmp/artifacts
143+
merge-multiple: true
144+
145+
- name: List artifacts
146+
run: |
147+
echo "=== Downloaded artifacts ==="
148+
ls -lah /tmp/artifacts/ || echo "No artifacts"
149+
150+
- name: Create release
151+
env:
152+
GH_TOKEN: ${{ github.token }}
153+
run: |
154+
VERSION="v$(date -u '+%Y%m%d.%H%M%S')"
155+
156+
# Check if we have any files
157+
if [ -z "$(ls -A /tmp/artifacts/ 2>/dev/null)" ]; then
158+
echo "::warning::No artifacts to release"
159+
exit 0
160+
fi
161+
162+
# Generate release notes
163+
cat > /tmp/release_notes.md << EOF
164+
## Metadata Release
165+
166+
**Generated**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
167+
168+
### Contents
169+
170+
| File | Size |
171+
|------|------|
172+
EOF
173+
174+
for f in /tmp/artifacts/*; do
175+
if [ -f "$f" ]; then
176+
size=$(ls -lh "$f" | awk '{print $5}')
177+
echo "| $(basename $f) | $size |" >> /tmp/release_notes.md
178+
fi
179+
done
180+
181+
cat >> /tmp/release_notes.md << EOF
182+
183+
---
184+
*This release was generated automatically from test repository.*
185+
EOF
186+
187+
# Create the release
188+
gh release create "$VERSION" \
189+
--title "Metadata $VERSION" \
190+
--notes-file /tmp/release_notes.md \
191+
--repo "${{ github.repository }}" \
192+
/tmp/artifacts/* || {
193+
echo "::error::Failed to create release"
194+
exit 1
195+
}
196+
197+
echo "::notice::Created release $VERSION"

0 commit comments

Comments
 (0)