-
Notifications
You must be signed in to change notification settings - Fork 2
254 lines (218 loc) · 8.1 KB
/
flatpak-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
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
name: Update Flatpak Repository
on:
workflow_run:
workflows: ["Flatpak Tagged Release", "Flatpak Build and Release"]
types:
- completed
# Add concurrency to prevent multiple runs from interfering with each other
concurrency:
group: "flatpak-repo-${{ github.ref }}"
cancel-in-progress: true
permissions:
contents: write
pages: write
id-token: write
actions: read
jobs:
update-repo:
permissions:
pages: write
id-token: write
contents: write
actions: read
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout main repo
uses: actions/checkout@v4
with:
repository: futrnostr/futr
path: futr
- name: Checkout flatpak repo
uses: actions/checkout@v4
with:
repository: futrnostr/futr-flatpak
ref: gh-pages
token: ${{ secrets.TOKEN }}
fetch-depth: 0
path: flatpak-repo
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
workdir: flatpak-repo
- name: Setup Flatpak and ostree
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder ostree
- name: Download Flatpak Bundle
uses: dawidd6/action-download-artifact@v2
with:
name: flatpak-bundle
path: .
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
- name: Create/Update Repository
env:
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
run: |
cd flatpak-repo
TARGET_REPO=""
if [[ "$WORKFLOW_NAME" == "Flatpak Tagged Release" ]]; then
TARGET_REPO="repo-stable"
else
TARGET_REPO="repo-continuous"
fi
# Remove existing repo if it exists
rm -rf "$TARGET_REPO"
# Initialize fresh repository
ostree init --mode=archive-z2 --repo=$TARGET_REPO
# Trust the key in the repository
echo "Setting up repository GPG trust..."
ostree remote --repo="$TARGET_REPO" add-gpg-key futr-continuous --gpg-import=<(gpg --export $GPG_KEY_ID)
if [ -f "../futr.flatpak" ]; then
# Import the Flatpak bundle
echo "Importing bundle to $TARGET_REPO..."
flatpak build-import-bundle \
--no-update-summary \
--gpg-sign="$GPG_KEY_ID" \
"$TARGET_REPO" ../futr.flatpak || exit 1
# Update the repository properly
echo "Updating repository..."
flatpak build-update-repo "$TARGET_REPO" \
--gpg-sign="$GPG_KEY_ID" \
--generate-static-deltas \
--prune \
--prune-depth=20 \
--static-delta-jobs=4 || exit 1
# Debug: Check if commits are signed
echo "Checking repository signatures..."
ostree show --repo="$TARGET_REPO" app/com.futrnostr.futr/x86_64/master
# Verify repository contents
echo "Verifying repository structure..."
ostree summary --view --repo="$TARGET_REPO"
ls -la "$TARGET_REPO"
fi
- name: Create .flatpakrepo files
run: |
cd flatpak-repo
# Get public key in raw base64 format (no ASCII armor)
GPG_KEY=$(gpg --export --no-armor ${{ secrets.GPG_KEY_ID }} | base64 -w 0)
# Copy and update the repo files
for TYPE in continuous stable; do
cp "../futr/flatpak/futr-${TYPE}.flatpakrepo.template" "futr-${TYPE}.flatpakrepo"
sed -i "s|GPGKEY_PLACEHOLDER|${GPG_KEY}|g" "futr-${TYPE}.flatpakrepo"
done
- name: Commit Repository Updates
run: |
cd flatpak-repo
git add repo-stable repo-continuous *.flatpakrepo
if ! git commit -m "Update Flatpak repositories"; then
echo "::warning::No changes to commit"
fi
if ! git push origin gh-pages; then
echo "::error::Failed to push to gh-pages branch"
exit 1
fi
- name: Setup Pages
uses: actions/configure-pages@v5
with:
enablement: true
token: ${{ secrets.TOKEN }}
- name: Upload Repository
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.TOKEN }}
- name: Create index.html
run: |
cd flatpak-repo
cat > index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>Futr Flatpak Repository</title>
</head>
<body>
<h1>Futr Flatpak Repository</h1>
<h2>Stable Repository</h2>
<p>To add the stable repository:</p>
<pre>flatpak remote-add --if-not-exists futr-stable https://futrnostr.github.io/futr-flatpak/repo-stable</pre>
<p>Or download the <a href="futr-stable.flatpakrepo">repository file</a>.</p>
<h2>Development Repository</h2>
<p>To add the development repository:</p>
<pre>flatpak remote-add --if-not-exists futr-continuous https://futrnostr.github.io/futr-flatpak/repo-continuous</pre>
<p>Or download the <a href="futr-continuous.flatpakrepo">repository file</a>.</p>
</body>
</html>
EOF
git add index.html
- name: Commit index.html
run: |
cd flatpak-repo
if ! git commit -m "Update index.html"; then
echo "::warning::No changes to index.html"
fi
if ! git push origin gh-pages; then
echo "::error::Failed to push index.html to gh-pages branch"
exit 1
fi
- name: Download appdata.xml
uses: dawidd6/action-download-artifact@v2
with:
name: appdata-xml
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
path: temp
- name: Update Repository appdata.xml
run: |
cd flatpak-repo
REPO_TYPE="${{ github.event.workflow_run.name == 'Flatpak Tagged Release' && 'stable' || 'continuous' }}"
APPDATA="repo-${REPO_TYPE}/appstream/x86_64/appdata.xml"
# Create directory if it doesn't exist
mkdir -p "repo-${REPO_TYPE}/appstream/x86_64"
# Copy template if appdata.xml doesn't exist
if [ ! -f "$APPDATA" ]; then
cp "../futr/flatpak/com.futrnostr.futr.appdata.xml.template" "$APPDATA"
fi
# Get new release info from the artifact
NEW_RELEASE=$(grep -A 4 '<release' temp/flatpak/com.futrnostr.futr.appdata.xml | head -n 5)
# Create temporary file
TEMP_FILE=$(mktemp)
# Insert new release at the top of the releases section
awk -v new="$NEW_RELEASE" '
/<releases>/ {
print $0
print new
next
}
{print}
' "$APPDATA" > "$TEMP_FILE"
# Replace original file
mv "$TEMP_FILE" "$APPDATA"
# Add to git
git add "$APPDATA"
- name: Commit appdata changes
run: |
cd flatpak-repo
if ! git commit -m "Update appdata.xml"; then
echo "::warning::No changes to appdata.xml"
fi
if ! git push origin gh-pages; then
echo "::error::Failed to push appdata.xml to gh-pages branch"
exit 1
fi