-
Notifications
You must be signed in to change notification settings - Fork 15
199 lines (167 loc) · 5.38 KB
/
Copy pathrelease-metadata.yaml
File metadata and controls
199 lines (167 loc) · 5.38 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
name: Release Metadata
on:
schedule:
- cron: '0 5 * * 1/3' # At 5:00am on Monday and Thursday
workflow_dispatch:
inputs:
force:
description: 'Force regeneration of all metadata'
type: boolean
default: false
concurrency:
group: release-metadata
cancel-in-progress: false
jobs:
generate:
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64-linux
runner: ubuntu-latest
- arch: aarch64-linux
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install tools
run: |
ARCH="$(uname -m)-linux"
sudo apt-get update
sudo apt-get install -y zstd xz-utils jq
# Download sbuild
curl -fsSL "https://github.com/pkgforge/sbuilder/releases/download/nightly/sbuild-${ARCH}" \
-o /usr/local/bin/sbuild || {
echo "::error::Failed to download sbuild"
exit 1
}
chmod +x /usr/local/bin/sbuild
sbuild --version
# Download soar for SDB generation
curl -fsSL "https://github.com/pkgforge/soar/releases/download/nightly/soar-${ARCH}" \
-o /usr/local/bin/soar || {
echo "::error::Failed to download soar"
exit 1
}
chmod +x /usr/local/bin/soar
- name: Generate metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p /tmp/output
sbuild meta generate \
-a "${{ matrix.arch }}" \
-r ./packages/ \
-o /tmp/output/metadata.json \
|| {
echo "::warning::metadata generation failed or no packages found"
}
if [ -f "/tmp/output/metadata.json" ]; then
mv "/tmp/output/metadata.json" "/tmp/output/metadata-${{ matrix.arch }}.json"
echo "::notice::metadata generated"
jq 'length' "/tmp/output/metadata-${{ matrix.arch }}.json"
else
echo "::warning::No metadata generated"
fi
- name: List outputs
run: |
echo "=== Generated files ==="
ls -lah /tmp/output/ || echo "No files"
for f in /tmp/output/*.json; do
if [ -f "$f" ]; then
echo "=== $(basename $f) ==="
jq '.[0:2]' "$f" 2>/dev/null || cat "$f"
fi
done
- name: Generate SDB metadata
run: |
cd /tmp/output
for json_file in *.json; do
if [ -f "$json_file" ]; then
sdb_file="${json_file%.json}.sdb"
echo "Converting $json_file to $sdb_file"
soar json2db "$json_file" "$sdb_file" -r "soarpkgs" || {
echo "::warning::Failed to convert $json_file to SDB"
continue
}
fi
done
echo "=== SDB files generated ==="
ls -lah *.sdb 2>/dev/null || echo "No SDB files"
- name: Compress outputs
run: |
cd /tmp/output
for file in *.json *.sdb; do
if [ -f "$file" ]; then
# Compress with zstd
zstd -19 "$file" -o "${file}.zstd"
fi
done
ls -lah
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: metadata-${{ matrix.arch }}
path: |
/tmp/output/*.json
/tmp/output/*.json.zstd
/tmp/output/*.sdb
/tmp/output/*.sdb.zstd
retention-days: 7
release:
needs: generate
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: /tmp/artifacts
merge-multiple: true
- name: List artifacts
run: |
echo "=== Downloaded artifacts ==="
ls -lah /tmp/artifacts/ || echo "No artifacts"
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="$(date -u '+%Y%m%d.%H%M%S')"
# Check if we have any files
if [ -z "$(ls -A /tmp/artifacts/ 2>/dev/null)" ]; then
echo "::warning::No artifacts to release"
exit 0
fi
# Generate release notes
cat > /tmp/release_notes.md << EOF
## Metadata Release
**Generated**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
### Contents
| File | Size |
|------|------|
EOF
for f in /tmp/artifacts/*; do
if [ -f "$f" ]; then
size=$(ls -lh "$f" | awk '{print $5}')
echo "| $(basename $f) | $size |" >> /tmp/release_notes.md
fi
done
cat >> /tmp/release_notes.md << EOF
---
*This release was generated automatically.*
EOF
# Create the release
gh release create "$VERSION" \
--title "Metadata $VERSION" \
--notes-file /tmp/release_notes.md \
--repo "${{ github.repository }}" \
/tmp/artifacts/* || {
echo "::error::Failed to create release"
exit 1
}
echo "::notice::Created release $VERSION"