Add Store support and unsigned app releases
This commit is contained in:
40
templates/rust-app/.gitea/workflows/release.yml
Normal file
40
templates/rust-app/.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
# Gitea / Forgejo (Codeberg): on a tag (v1.2.3), build, sign and publish a
|
||||
# release with the three store assets. Secret: SF_SIGNING_KEY (base64 of
|
||||
# key.pem on one line). The job token creates the release.
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:trixie
|
||||
env:
|
||||
SF_PACK_GIT: https://gitea.bluefox.support/bluefox/fox-in-the-box
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends build-essential pkg-config curl ca-certificates git jq \
|
||||
libfontconfig1-dev libfreetype-dev libxkbcommon-dev >/dev/null
|
||||
git clone --depth 1 --branch "$GITHUB_REF_NAME" \
|
||||
"${GITHUB_SERVER_URL%%://*}://oauth2:${{ secrets.GITHUB_TOKEN }}@${GITHUB_SERVER_URL#*://}/${GITHUB_REPOSITORY}.git" src
|
||||
- name: Build and sign
|
||||
env:
|
||||
SF_SIGNING_KEY: ${{ secrets.SF_SIGNING_KEY }}
|
||||
run: |
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y -q --profile minimal
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
cargo install -q --locked --git "$SF_PACK_GIT" sf-pack
|
||||
cd src && ./package.sh
|
||||
- name: Release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases"
|
||||
id=$(curl -fsS -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$GITHUB_REF_NAME\",\"name\":\"$GITHUB_REF_NAME\"}" "$api" | jq -r .id)
|
||||
for f in src/dist/*; do
|
||||
curl -fsS -H "Authorization: token $TOKEN" -F "attachment=@$f" "$api/$id/assets?name=$(basename "$f")" >/dev/null
|
||||
done
|
||||
36
templates/rust-app/.github/workflows/release.yml
vendored
Normal file
36
templates/rust-app/.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# GitHub: on a tag (v1.2.3), build in Debian trixie, sign, and publish a
|
||||
# release with the three store assets. Secret: SF_SIGNING_KEY (base64 of
|
||||
# key.pem on one line: `base64 -w0 key.pem`).
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:trixie
|
||||
env:
|
||||
SF_PACK_GIT: https://gitea.bluefox.support/bluefox/fox-in-the-box
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Toolchain
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends build-essential pkg-config curl ca-certificates git \
|
||||
libfontconfig1-dev libfreetype-dev libxkbcommon-dev gh >/dev/null
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y -q --profile minimal
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
- name: sf-pack
|
||||
run: cargo install -q --locked --git "$SF_PACK_GIT" sf-pack
|
||||
- name: Build and sign
|
||||
env:
|
||||
SF_SIGNING_KEY: ${{ secrets.SF_SIGNING_KEY }}
|
||||
run: ./package.sh
|
||||
- name: Release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
git config --global --add safe.directory "$PWD"
|
||||
gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --notes "Fennec OS store release"
|
||||
4
templates/rust-app/.gitignore
vendored
Normal file
4
templates/rust-app/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/target
|
||||
/pkg
|
||||
/dist
|
||||
key.pem
|
||||
30
templates/rust-app/.gitlab-ci.yml
Normal file
30
templates/rust-app/.gitlab-ci.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
# GitLab: on a tag (v1.2.3), build, sign, put the three store assets into the
|
||||
# project's generic package registry and make a release that links them.
|
||||
# CI/CD variable: SF_SIGNING_KEY (base64 of key.pem on one line, masked).
|
||||
# The project must be public, so TVs can download without a login.
|
||||
release:
|
||||
image: debian:trixie
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG =~ /^v/
|
||||
variables:
|
||||
SF_PACK_GIT: https://gitea.bluefox.support/bluefox/fox-in-the-box
|
||||
script:
|
||||
- apt-get update -qq
|
||||
- apt-get install -y -qq --no-install-recommends build-essential pkg-config curl ca-certificates git jq libfontconfig1-dev libfreetype-dev libxkbcommon-dev >/dev/null
|
||||
- curl -sSf https://sh.rustup.rs | sh -s -- -y -q --profile minimal
|
||||
- export PATH="$HOME/.cargo/bin:$PATH"
|
||||
- cargo install -q --locked --git "$SF_PACK_GIT" sf-pack
|
||||
- ./package.sh
|
||||
- VERSION="${CI_COMMIT_TAG#v}"
|
||||
- PKG="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/smartfox/$VERSION"
|
||||
- links="[]"
|
||||
- |
|
||||
for f in dist/*; do
|
||||
n=$(basename "$f")
|
||||
curl -fsS --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "$f" "$PKG/$n" >/dev/null
|
||||
links=$(echo "$links" | jq --arg n "$n" --arg u "$PKG/$n" '. + [{name: $n, url: $u, link_type: "package"}]')
|
||||
done
|
||||
- |
|
||||
jq -n --arg t "$CI_COMMIT_TAG" --argjson l "$links" '{tag_name: $t, name: $t, assets: {links: $l}}' |
|
||||
curl -fsS --header "JOB-TOKEN: $CI_JOB_TOKEN" --header "Content-Type: application/json" --data @- \
|
||||
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/releases" >/dev/null
|
||||
5768
templates/rust-app/Cargo.lock
generated
Normal file
5768
templates/rust-app/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
templates/rust-app/Cargo.toml
Normal file
18
templates/rust-app/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "hello-fennec"
|
||||
version = "1.0.0"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
# Any toolkit that speaks Wayland works (Slint, egui/eframe, iced, winit...).
|
||||
# The sandbox only has the Wayland socket: no X11.
|
||||
slint = "1.18"
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
strip = true
|
||||
|
||||
# Not part of the Fennec OS workspace: this folder is a template to copy.
|
||||
[workspace]
|
||||
29
templates/rust-app/app.toml
Normal file
29
templates/rust-app/app.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
# Fennec OS store app manifest (docs/store.md in the Fennec OS repo).
|
||||
# The id is a reverse domain name you control: io.github.<user>.<app>,
|
||||
# io.gitlab.<user>.<app>, org.codeberg.<user>.<app>, or your own domain.
|
||||
id = "io.github.example.hello"
|
||||
name = "Hello"
|
||||
# Release versions only (1.2.3). Bump it for every release.
|
||||
version = "1.0.0"
|
||||
kind = "exec"
|
||||
category = "Példa"
|
||||
description = "Egy Fennec OS app Rustban: a távirányító nyilaival lépkedsz, a középső gombbal kattintasz."
|
||||
author = "Example"
|
||||
license = "MIT"
|
||||
homepage = "https://github.com/example/hello-fennec"
|
||||
# Relative to the package: bin/ holds the binary built by the release job.
|
||||
exec = ["bin/hello-fennec"]
|
||||
# Your own icon (PNG, square, 256x256 or more) in the package, or leave it out.
|
||||
# icon = "icon.png"
|
||||
accent = "#FF9A5C"
|
||||
palette = ["#ffb27a", "#8a3d12", "#120805"]
|
||||
|
||||
# Your signing key's public half: `sf-pack keygen` prints it. Every release
|
||||
# must be signed with the same key, or TVs won't update.
|
||||
|
||||
[sandbox]
|
||||
# What the app may use besides its own files and the screen. The TV shows
|
||||
# this list before installing; an update that asks for more waits for the
|
||||
# user to approve it. network, gpu, audio, gamepad, dbus-session,
|
||||
# dbus-system, devices.
|
||||
permissions = ["gpu"]
|
||||
18
templates/rust-app/package.sh
Normal file
18
templates/rust-app/package.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the release assets into dist/: app.toml and <id>-<version>.tar.zst.
|
||||
# Upload both files to a release of this repo; that's all the
|
||||
# store needs. The CI files here do it on every tag.
|
||||
#
|
||||
# Build on Debian trixie (what the TV runs) or older, so the binary's glibc
|
||||
# isn't newer than the TV's.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
cargo build --release --locked
|
||||
rm -rf pkg dist
|
||||
mkdir -p pkg/bin
|
||||
cp app.toml pkg/
|
||||
[ -f icon.png ] && cp icon.png pkg/
|
||||
install -m755 target/release/hello-fennec pkg/bin/hello-fennec
|
||||
sf-pack build pkg dist
|
||||
sf-pack verify dist
|
||||
60
templates/rust-app/src/main.rs
Normal file
60
templates/rust-app/src/main.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
//! A Fennec OS store app in Rust: full screen, driven by the remote.
|
||||
//!
|
||||
//! The Siri Remote arrives as keys: arrows, Enter (click), Escape (Back).
|
||||
//! Home is handled by the TV itself (the app is paused in the background).
|
||||
//! Files: $HOME is the app's own data folder and the only writable place
|
||||
//! that lasts; the app's own files are read-only in $SMARTFOX_APP_DIR (/app).
|
||||
|
||||
slint::slint! {
|
||||
export component Main inherits Window {
|
||||
in-out property <int> selected: 0;
|
||||
in-out property <int> clicks: 0;
|
||||
callback quit();
|
||||
property <[string]> items: ["Hello", "Fennec OS", "Rust"];
|
||||
background: #0b0d12;
|
||||
default-font-size: 40px;
|
||||
|
||||
FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == Key.LeftArrow { root.selected = max(0, root.selected - 1); return accept; }
|
||||
if event.text == Key.RightArrow { root.selected = min(root.items.length - 1, root.selected + 1); return accept; }
|
||||
if event.text == Key.Return { root.clicks += 1; return accept; }
|
||||
if event.text == Key.Escape { root.quit(); return accept; }
|
||||
reject
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
spacing: 40px;
|
||||
for item[i] in root.items: Rectangle {
|
||||
width: 360px;
|
||||
height: 220px;
|
||||
y: (root.height - self.height) / 2;
|
||||
border-radius: 32px;
|
||||
background: i == root.selected ? #ffffff : #ffffff18;
|
||||
animate background { duration: 150ms; }
|
||||
Text {
|
||||
text: item;
|
||||
color: i == root.selected ? #121317 : #ffffff;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
y: root.height - 140px;
|
||||
text: "Enter: " + root.clicks + " · Back: exit";
|
||||
color: #ffffff99;
|
||||
font-size: 28px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), slint::PlatformError> {
|
||||
let ui = Main::new()?;
|
||||
ui.window().set_fullscreen(true);
|
||||
// Back on the remote = Escape: leave the app (the launcher comes back).
|
||||
ui.on_quit(|| {
|
||||
let _ = slint::quit_event_loop();
|
||||
});
|
||||
ui.run()
|
||||
}
|
||||
Reference in New Issue
Block a user