-
Notifications
You must be signed in to change notification settings - Fork 9
145 lines (125 loc) · 6.22 KB
/
Copy pathupdate-flatpak-runtime.yml
File metadata and controls
145 lines (125 loc) · 6.22 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
name: Update Flatpak Runtime
on:
schedule:
# Run nightly at 3:00 UTC
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
check-runtime-update:
name: Check for Flatpak Runtime Updates
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Flatpak
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Check for runtime updates
id: check
run: |
# Get current runtime version from manifest
CURRENT_VERSION=$(grep -oP "runtime-version:\s*'\K[^']+" io.github.cosmic_utils.camera.yml)
CURRENT_LLVM=$(grep -oP 'org\.freedesktop\.Sdk\.Extension\.llvm\K[0-9]+' io.github.cosmic_utils.camera.yml)
echo "Current runtime version: $CURRENT_VERSION"
echo "Current LLVM extension: $CURRENT_LLVM"
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "current_llvm=$CURRENT_LLVM" >> $GITHUB_OUTPUT
# Query Flathub for available Freedesktop Platform versions
# Get list of available runtime versions
AVAILABLE_VERSIONS=$(flatpak remote-ls --user flathub --columns=application,branch \
| grep "org.freedesktop.Platform" \
| grep -v "Locale\|Debug\|Docs\|GL\|Compat\|ffmpeg\|openh264" \
| awk '{print $2}' \
| grep -E "^[0-9]+\.[0-9]+$" \
| sort -t. -k1,1n -k2,2n \
| tail -5)
echo "Available versions:"
echo "$AVAILABLE_VERSIONS"
# Get the latest stable version (highest version number)
LATEST_VERSION=$(echo "$AVAILABLE_VERSIONS" | tail -1)
echo "Latest runtime version: $LATEST_VERSION"
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
# Select the newest LLVM SDK extension published for that runtime.
LATEST_LLVM=$(flatpak remote-ls --user flathub --runtime --columns=application,branch \
| awk -v version="$LATEST_VERSION" \
'$2 == version && $1 ~ /^org\.freedesktop\.Sdk\.Extension\.llvm[0-9]+$/ { print $1 }' \
| sed 's/.*llvm//' \
| sort -nu \
| tail -1)
if [ -z "$LATEST_LLVM" ]; then
echo "No LLVM SDK extension is available for runtime $LATEST_VERSION" >&2
exit 1
fi
flatpak remote-info --user flathub \
org.freedesktop.Sdk.Extension.rust-stable//$LATEST_VERSION >/dev/null
echo "Latest LLVM extension: $LATEST_LLVM"
echo "latest_llvm=$LATEST_LLVM" >> $GITHUB_OUTPUT
# Compare the runtime and its coupled LLVM extension.
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ] || [ "$CURRENT_LLVM" != "$LATEST_LLVM" ]; then
echo "Update available: runtime $CURRENT_VERSION -> $LATEST_VERSION, LLVM $CURRENT_LLVM -> $LATEST_LLVM"
echo "update_available=true" >> $GITHUB_OUTPUT
else
echo "Already on latest version"
echo "update_available=false" >> $GITHUB_OUTPUT
fi
- name: Update manifest
if: steps.check.outputs.update_available == 'true'
run: |
CURRENT="${{ steps.check.outputs.current }}"
LATEST="${{ steps.check.outputs.latest }}"
CURRENT_LLVM="${{ steps.check.outputs.current_llvm }}"
LATEST_LLVM="${{ steps.check.outputs.latest_llvm }}"
# Update the runtime and every coupled LLVM extension/path reference.
sed -i "s/runtime-version: '$CURRENT'/runtime-version: '$LATEST'/" io.github.cosmic_utils.camera.yml
sed -i "s/llvm${CURRENT_LLVM}/llvm${LATEST_LLVM}/g" io.github.cosmic_utils.camera.yml justfile
sed -i "s#/clang/${CURRENT_LLVM}/#/clang/${LATEST_LLVM}/#g" io.github.cosmic_utils.camera.yml
grep "runtime-version\|Sdk.Extension.llvm\|LIBCLANG_PATH\|BINDGEN_EXTRA_CLANG_ARGS" \
io.github.cosmic_utils.camera.yml
if [ "$CURRENT_LLVM" != "$LATEST_LLVM" ] && \
grep -q "llvm${CURRENT_LLVM}\|/clang/${CURRENT_LLVM}/" \
io.github.cosmic_utils.camera.yml justfile; then
echo "Stale LLVM ${CURRENT_LLVM} reference remains" >&2
exit 1
fi
- name: Install just
if: steps.check.outputs.update_available == 'true'
uses: extractions/setup-just@v4
- name: Build updated Flatpak
if: steps.check.outputs.update_available == 'true'
run: |
just flatpak-deps x86_64
just flatpak-bundle x86_64
rm -rf build-dir .flatpak-builder repo camera-x86_64.flatpak .flatpak-version
- name: Create Pull Request
id: cpr
if: steps.check.outputs.update_available == 'true'
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "deps(flatpak): update runtime to ${{ steps.check.outputs.latest }}"
title: "deps(flatpak): update Freedesktop runtime to ${{ steps.check.outputs.latest }}"
body: |
## Flatpak Runtime Update
Updates `org.freedesktop.Platform` and `org.freedesktop.Sdk` from `${{ steps.check.outputs.current }}` to `${{ steps.check.outputs.latest }}`.
### Changes
- Updated `runtime-version` in `io.github.cosmic_utils.camera.yml`
- Updated the LLVM SDK extension and paths where required
### Testing
- [x] Built the x86_64 Flatpak in the update workflow
- [ ] Verify app runs correctly
---
*This PR was automatically created by the Update Flatpak Runtime workflow.*
branch: deps/flatpak-runtime-${{ steps.check.outputs.latest }}
delete-branch: true
labels: dependencies
- name: Run CI on pull request branch
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' || steps.cpr.outputs.pull-request-operation == 'updated' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run ci.yml --ref "${{ steps.cpr.outputs.pull-request-branch }}"