Skip to content

Commit 3ea54ea

Browse files
committed
fix: disable flatpak, fixup brews
1 parent 9cfc1d4 commit 3ea54ea

2 files changed

Lines changed: 315 additions & 2 deletions

File tree

Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
name: Flatpak Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag_name:
7+
description: "The tag name for the release"
8+
required: true
9+
type: string
10+
version:
11+
description: "The version number"
12+
required: true
13+
type: string
14+
release_id:
15+
description: "The release ID to upload to (optional, for existing releases)"
16+
required: false
17+
type: string
18+
19+
jobs:
20+
flatpak:
21+
name: Build Flatpak for ${{ matrix.arch }}
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
arch: [amd64, arm64]
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: stable
36+
cache: true
37+
38+
- name: Vendor Go modules
39+
run: |
40+
echo "=== Vendoring Go modules ==="
41+
go mod tidy
42+
go mod vendor
43+
44+
echo "=== Vendor directory contents ==="
45+
ls -la vendor/ || echo "No vendor directory created"
46+
47+
echo "=== Creating vendor archive ==="
48+
tar -czf vendor.tar.gz vendor/
49+
ls -la vendor.tar.gz
50+
51+
- name: Calculate vendor archive hash
52+
id: vendor-hash
53+
run: |
54+
VENDOR_SHA256=$(sha256sum vendor.tar.gz | cut -d' ' -f1)
55+
echo "VENDOR_SHA256=${VENDOR_SHA256}" >> $GITHUB_OUTPUT
56+
echo "Vendor archive SHA256: ${VENDOR_SHA256}"
57+
58+
- name: Calculate git commit hash
59+
id: git-info
60+
run: |
61+
COMMIT_HASH=$(git rev-parse --short HEAD)
62+
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
63+
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_OUTPUT
64+
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
65+
echo "Git commit hash: ${COMMIT_HASH}"
66+
echo "Build date: ${BUILD_DATE}"
67+
68+
- name: Install jq for JSON processing
69+
run: sudo apt-get update && sudo apt-get install -y jq
70+
71+
- name: Generate metainfo.xml with GitHub releases
72+
uses: actions/github-script@v7
73+
with:
74+
script: |
75+
const fs = require('fs');
76+
77+
// Fetch all releases (excluding prereleases)
78+
const releases = await github.rest.repos.listReleases({
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
per_page: 100
82+
});
83+
84+
const validReleases = releases.data.filter(release => !release.prerelease);
85+
86+
// Generate metainfo.xml content
87+
let metainfoContent = `<?xml version="1.0" encoding="UTF-8"?>
88+
<component type="desktop-application">
89+
<id>io.github.jmylchreest.keylightd</id>
90+
<name>Keylight Control</name>
91+
<summary>Control Elgato Key Lights and similar HTTP-based lighting devices</summary>
92+
<metadata_license>MIT</metadata_license>
93+
<project_license>MIT</project_license>
94+
<description>
95+
<p>
96+
Keylight Control provides a daemon and command-line interface for managing Elgato Key Lights and similar HTTP-based lighting devices on your local network.
97+
</p>
98+
<p>
99+
Features:
100+
</p>
101+
<ul>
102+
<li>Automatic discovery of Elgato Key Lights via mDNS</li>
103+
<li>Grouping of lights for batch control</li>
104+
<li>HTTP REST API for remote control</li>
105+
<li>Unix socket and CLI interface for local control</li>
106+
<li>Configurable discovery interval and logging</li>
107+
</ul>
108+
</description>
109+
<launchable type="desktop-id">io.github.jmylchreest.keylightd.desktop</launchable>
110+
<icon type="stock">io.github.jmylchreest.keylightd</icon>
111+
<url type="homepage">https://github.com/jmylchreest/keylightd</url>
112+
<url type="bugtracker">https://github.com/jmylchreest/keylightd/issues</url>
113+
<developer_name>John Mylchreest</developer_name>
114+
<content_rating type="oars-1.1" />
115+
<releases>
116+
`;
117+
118+
// Add releases
119+
for (const release of validReleases) {
120+
const version = release.tag_name.replace(/^v/, '');
121+
const date = release.published_at.split('T')[0];
122+
const name = release.name || `Release ${version}`;
123+
124+
metainfoContent += ` <release version="${version}" date="${date}">
125+
<description>
126+
<p>${name.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')}</p>`;
127+
128+
if (release.body && release.body.trim()) {
129+
// Clean and truncate release body
130+
const cleanBody = release.body
131+
.replace(/&/g, '&amp;')
132+
.replace(/</g, '&lt;')
133+
.replace(/>/g, '&gt;')
134+
.replace(/"/g, '&quot;')
135+
.replace(/'/g, '&#39;')
136+
.split('\n')
137+
.slice(0, 5)
138+
.join(' ')
139+
.substring(0, 300);
140+
141+
if (cleanBody.trim()) {
142+
metainfoContent += `
143+
<p>${cleanBody.trim()}</p>`;
144+
}
145+
}
146+
147+
metainfoContent += `
148+
</description>
149+
</release>
150+
`;
151+
}
152+
153+
metainfoContent += ` </releases>
154+
<screenshots>
155+
<screenshot type="default">
156+
<caption>Controlling Key Lights via CLI</caption>
157+
<image>https://raw.githubusercontent.com/jmylchreest/keylightd/main/docs/assets/screenshot.png</image>
158+
</screenshot>
159+
</screenshots>
160+
</component>`;
161+
162+
// Write to file
163+
fs.writeFileSync('io.github.jmylchreest.keylightd.metainfo.xml', metainfoContent);
164+
console.log('Generated metainfo.xml with releases:', validReleases.length);
165+
166+
- name: Create source archive
167+
run: |
168+
echo "=== Creating source archive ==="
169+
# Create a clean source archive without .git, including the generated metainfo.xml
170+
git config --global --add safe.directory "$(pwd)"
171+
git archive --format=tar --prefix=keylightd-${{ inputs.version }}/ HEAD > source.tar
172+
173+
# Add the generated metainfo.xml to the uncompressed archive
174+
tar --transform 's,^,keylightd-${{ inputs.version }}/,' -rf source.tar io.github.jmylchreest.keylightd.metainfo.xml
175+
176+
# Now compress the archive
177+
gzip source.tar
178+
ls -la source.tar.gz
179+
180+
- name: Calculate source archive hash
181+
id: source-hash
182+
run: |
183+
SOURCE_SHA256=$(sha256sum source.tar.gz | cut -d' ' -f1)
184+
echo "SOURCE_SHA256=${SOURCE_SHA256}" >> $GITHUB_OUTPUT
185+
echo "Source archive SHA256: ${SOURCE_SHA256}"
186+
187+
- name: Generate Flatpak manifest
188+
run: |
189+
cat > io.github.jmylchreest.keylightd.yml << 'EOF'
190+
app-id: io.github.jmylchreest.keylightd
191+
runtime: org.freedesktop.Platform
192+
runtime-version: "23.08"
193+
sdk: org.freedesktop.Sdk
194+
sdk-extensions:
195+
- org.freedesktop.Sdk.Extension.golang
196+
command: keylightctl
197+
finish-args:
198+
- --share=network
199+
- --socket=x11
200+
- --socket=wayland
201+
- --own-name=io.github.jmylchreest.keylightd
202+
- --filesystem=home
203+
- --talk-name=org.freedesktop.systemd1
204+
205+
modules:
206+
- name: keylightd
207+
buildsystem: simple
208+
build-options:
209+
env:
210+
- CGO_ENABLED=0
211+
- GOPROXY=off
212+
- GOFLAGS=-mod=vendor
213+
append-path: /usr/lib/sdk/golang/bin
214+
build-commands:
215+
# Extract vendor dependencies
216+
- tar -xzf vendor.tar.gz
217+
218+
# Build keylightd binary
219+
- |
220+
go build \
221+
-ldflags="-s -w \
222+
-X github.com/jmylchreest/keylightd/cmd/keylightd.version=${{ inputs.version }} \
223+
-X github.com/jmylchreest/keylightd/cmd/keylightd.commit=${{ steps.git-info.outputs.COMMIT_HASH }} \
224+
-X github.com/jmylchreest/keylightd/cmd/keylightd.buildDate=${{ steps.git-info.outputs.BUILD_DATE }}" \
225+
-o keylightd ./cmd/keylightd
226+
227+
# Build keylightctl binary
228+
- |
229+
go build \
230+
-ldflags="-s -w \
231+
-X github.com/jmylchreest/keylightd/cmd/keylightctl.version=${{ inputs.version }} \
232+
-X github.com/jmylchreest/keylightd/cmd/keylightctl.commit=${{ steps.git-info.outputs.COMMIT_HASH }} \
233+
-X github.com/jmylchreest/keylightd/cmd/keylightctl.buildDate=${{ steps.git-info.outputs.BUILD_DATE }}" \
234+
-o keylightctl ./cmd/keylightctl
235+
236+
# Install binaries
237+
- install -Dm755 keylightd /app/bin/keylightd
238+
- install -Dm755 keylightctl /app/bin/keylightctl
239+
240+
# Create default configuration directory
241+
- mkdir -p /app/share/keylightd
242+
243+
# Install systemd user service file
244+
- install -Dm644 contrib/flatpak/io.github.jmylchreest.keylightd.service /app/share/systemd/user/io.github.jmylchreest.keylightd.service
245+
246+
# Install desktop autostart file
247+
- install -Dm644 contrib/flatpak/io.github.jmylchreest.keylightd-autostart.desktop /app/share/applications/io.github.jmylchreest.keylightd-autostart.desktop
248+
249+
# Install desktop entry
250+
- install -Dm644 contrib/flatpak/io.github.jmylchreest.keylightd.desktop /app/share/applications/io.github.jmylchreest.keylightd.desktop
251+
252+
# Install icon
253+
- install -Dm644 contrib/gnome-extension/keylightd-control@jmylchreest.github.io/icons/hicolor/scalable/actions/light-enabled.svg /app/share/icons/hicolor/scalable/apps/io.github.jmylchreest.keylightd.svg
254+
255+
# Install appstream metadata (using generated version)
256+
- install -Dm644 io.github.jmylchreest.keylightd.metainfo.xml /app/share/metainfo/io.github.jmylchreest.keylightd.metainfo.xml
257+
sources:
258+
- type: file
259+
path: source.tar.gz
260+
dest-filename: source.tar.gz
261+
- type: file
262+
path: vendor.tar.gz
263+
dest-filename: vendor.tar.gz
264+
- type: shell
265+
commands:
266+
- tar -xzf source.tar.gz --strip-components=1
267+
EOF
268+
269+
- name: Install Flatpak and dependencies
270+
run: |
271+
sudo apt-get update
272+
sudo apt-get install -y flatpak flatpak-builder
273+
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
274+
sudo flatpak install -y flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08
275+
sudo flatpak install -y flathub org.freedesktop.Sdk.Extension.golang//23.08
276+
277+
- name: Build Flatpak
278+
run: |
279+
echo "=== Building Flatpak ==="
280+
flatpak-builder --force-clean --repo=repo build-dir io.github.jmylchreest.keylightd.yml
281+
282+
echo "=== Creating bundle ==="
283+
flatpak build-bundle repo io.github.jmylchreest.keylightd-${{ matrix.arch }}-${{ inputs.version }}.flatpak io.github.jmylchreest.keylightd
284+
285+
- name: Upload Flatpak artifact
286+
uses: actions/upload-artifact@v4
287+
with:
288+
name: flatpak-${{ matrix.arch }}-${{ inputs.version }}
289+
path: io.github.jmylchreest.keylightd-${{ matrix.arch }}-${{ inputs.version }}.flatpak
290+
retention-days: 30
291+
292+
- name: Upload to existing release
293+
if: inputs.release_id != ''
294+
run: |
295+
echo "Uploading to existing release ID: ${{ inputs.release_id }}"
296+
gh release upload ${{ inputs.tag_name }} \
297+
io.github.jmylchreest.keylightd-${{ matrix.arch }}-${{ inputs.version }}.flatpak \
298+
io.github.jmylchreest.keylightd.yml \
299+
--clobber
300+
env:
301+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
302+
303+
- name: Create new release (snapshots only)
304+
if: inputs.release_id == ''
305+
uses: softprops/action-gh-release@v2
306+
with:
307+
tag_name: ${{ inputs.tag_name }}
308+
files: |
309+
io.github.jmylchreest.keylightd-${{ matrix.arch }}-${{ inputs.version }}.flatpak
310+
io.github.jmylchreest.keylightd.yml
311+
make_latest: "false"
312+
fail_on_unmatched_files: true
313+
env:
314+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ brews:
7272
owner: jmylchreest
7373
name: homebrew-keylightd
7474
branch: main
75+
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
7576
commit_author:
7677
name: goreleaserbot
7778
email: bot@goreleaser.com
@@ -82,5 +83,3 @@ brews:
8283
system "#{bin}/keylightd", "--version"
8384
system "#{bin}/keylightctl", "--version"
8485
skip_upload: "{{ .IsSnapshot }}"
85-
86-

0 commit comments

Comments
 (0)