Skip to content

Commit

Permalink
ci(flatpak): sync with flathub
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 3, 2024
1 parent 024bd8f commit da07468
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 44 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ jobs:

- name: Setup Dependencies Linux Flatpak
env:
PLATFORM_VERSION: "22.08"
PLATFORM_VERSION: "23.08"
NODE_VERSION: "20"
run: |
sudo apt-get update -y
sudo apt-get install -y \
Expand All @@ -114,8 +115,7 @@ jobs:
org.flatpak.Builder \
org.freedesktop.Platform/${{ matrix.arch }}/${PLATFORM_VERSION} \
org.freedesktop.Sdk/${{ matrix.arch }}/${PLATFORM_VERSION} \
org.freedesktop.Sdk.Extension.node18/${{ matrix.arch }}/${PLATFORM_VERSION} \
org.freedesktop.Sdk.Extension.vala/${{ matrix.arch }}/${PLATFORM_VERSION} \
org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${{ matrix.arch }}/${PLATFORM_VERSION} \
"
- name: Cache Flatpak build
Expand Down Expand Up @@ -229,6 +229,20 @@ jobs:
# exit with the correct code
exit $exit_code
- name: Package Flathub repo archive
# copy files required to generate the Flathub repo
run: |
mkdir -p flathub/modules
cp ./build/${APP_ID}.yml ./flathub/
cp ./build/${APP_ID}.metainfo.xml ./flathub/
cp ./packaging/linux/flatpak/README.md ./flathub/
cp ./packaging/linux/flatpak/flathub.json ./flathub/
cp -r ./packaging/linux/flatpak/modules/. ./flathub/modules/
# submodules will need to be handled in the workflow that creates the PR
# create the archive
tar -czf ./artifacts/flathub.tar.gz -C ./flathub .
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
213 changes: 213 additions & 0 deletions .github/workflows/update-flathub-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
---
# This action is a candidate to centrally manage in https://github.com/<organization>/.github/
# If more Flathub applications are developed, consider moving this action to the organization's .github repository,
# using the `flathub-pkg` repository label to identify repositories that should trigger this workflow.

# Update Flathub on release events.

name: Update flathub repo

on:
release:
types: [edited]

concurrency:
group: "${{ github.workflow }}-${{ github.event.release.tag_name }}"
cancel-in-progress: true

jobs:
update-flathub-repo:
env:
FLATHUB_PKG: app.lizardbyte.dev.${{ github.event.repository.name }}
if: >-
github.repository_owner == 'LizardByte' &&
!github.event.release.draft && !github.event.release.prerelease
runs-on: ubuntu-latest
steps:
- name: Check if flathub repo
env:
TOPIC: flathub-pkg
id: check
uses: actions/github-script@v7
with:
script: |
const topic = process.env.TOPIC;
console.log(`Checking if repo has topic: ${topic}`);
const repoTopics = await github.rest.repos.getAllTopics({
owner: context.repo.owner,
repo: context.repo.repo
});
console.log(`Repo topics: ${repoTopics.data.names}`);
const hasTopic = repoTopics.data.names.includes(topic);
console.log(`Has topic: ${hasTopic}`);
core.setOutput('hasTopic', hasTopic);
- name: Check if edited release is latest GitHub release
id: check
if: >-
github.event_name == 'release' &&
github.event.action == 'edited'
uses: actions/github-script@v7
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
core.setOutput('isLatestRelease', latestRelease.data.tag_name === context.payload.release.tag_name);
- name: Checkout
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true'
uses: actions/checkout@v4

- name: Checkout flathub-repo
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true'
uses: actions/checkout@v4
with:
repository: "flathub/${{ env.FLATHUB_PKG }}"
path: "flathub/${{ env.FLATHUB_PKG }}"

- name: Clean up legacy files
working-directory: flathub/${{ env.FLATHUB_PKG }}
run: |
rm -rf ./*
- name: Download release asset
id: download
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true'
uses: robinraju/[email protected]
with:
repository: "${{ github.repository }}"
tag: "${{ github.event.release.tag_name }}"
fileName: "flathub.tar.gz"
tarBall: false
zipBall: false
out-file-path: "flathub/${{ env.FLATHUB_PKG }}"
extract: true

- name: Fetch GitHub releases
id: releases
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true'
uses: actions/github-script@v7
env:
MINIMUM_VERSION: 0.19.1
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
with:
script: |
// Function to compare version strings
function compareVersions(v1, v2) {
const v1Parts = v1.split('.').map(Number);
const v2Parts = v2.split('.').map(Number);
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
const v1Part = v1Parts[i] || 0;
const v2Part = v2Parts[i] || 0;
if (v1Part > v2Part) return 1;
if (v1Part < v2Part) return -1;
}
return 0;
}
// get all releases and sort by date created, page if required
let releases = [];
let page = 1;
let per_page = 100;
let total = 0;
do {
const response = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: per_page,
page: page
});
releases = releases.concat(response.data);
total = response.data.length;
page++;
} while (total == per_page);
// filter out pre-releases, drafts, and versions below MINIMUM_VERSION
releases = releases.filter(release => {
const version = release.tag_name.startsWith('v') ? release.tag_name.slice(1) : release.tag_name;
return !release.prerelease && !release.draft && compareVersions(version, process.env.MINIMUM_VERSION) >= 0;
});
// sort releases by date created
releases.sort((a, b) => {
return new Date(a.created_at) - new Date(b.created_at);
});
return releases;
- name: Update metainfo.xml
id: update_metainfo
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true'
run: |
releases=$(jq -c '.[]' <<< "${{ steps.releases.outputs.result }}")
xml_file="flathub/${{ env.FLATHUB_PKG }}/dev.lizardbyte.app.Sunshine.metainfo.xml"
# Start the new releases section
echo "<releases>" > new_releases.xml
# Append each release to the new releases section
for release in $releases; do
version=$(jq -r '.tag_name' <<< "$release" | sed 's/^v//')
date=$(jq -r '.published_at' <<< "$release" | cut -d'T' -f1)
changelog=$(jq -r '.body' <<< "$release" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')
echo " <release version=\"$version\" date=\"$date\">" >> new_releases.xml
echo " <description><p>$changelog</p></description>" >> new_releases.xml
echo " </release>" >> new_releases.xml
done
# End the new releases section
echo " </releases>" >> new_releases.xml
# Replace the content within the <releases></releases> tags
sed -i '/<releases>/,/<\/releases>/c\'"$(cat new_releases.xml)" $xml_file
# remove the temporary file
rm new_releases.xml
- name: Ensure submodule commit in flathub matches submodule from here
working-directory: flathub/${{ env.FLATHUB_PKG }}
run: |
# Get the current commit of the submodule in the main repository
main_commit=$(git ls-tree HEAD ${{ github.workspace }}/packaging/linux/flatpak/deps/shared-modules | \
awk '{print $3}')
# add submodules
git submodule add https://github.com/flathub/shared-modules.git deps/shared-modules
git submodule update --init --recursive
cd deps/shared-modules
git checkout $main_commit
- name: Create/Update Pull Request
if: >-
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true' &&
fromJson(steps.download.outputs.downloaded_files)[0]
uses: peter-evans/create-pull-request@v7
with:
path: "flathub/${{ env.FLATHUB_PKG }}"
token: ${{ secrets.GH_BOT_TOKEN }}
commit-message: Update ${{ env.FLATHUB_PKG }} to ${{ github.event.release.tag_name }}
branch: bot/bump-${{ env.FLATHUB_PKG }}-${{ github.event.release.tag_name }}
delete-branch: true
title: "chore: Update ${{ env.FLATHUB_PKG }} to ${{ github.event.release.tag_name }}"
body: ${{ github.event.release.body }}
5 changes: 2 additions & 3 deletions .github/workflows/update-pacman-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:

- name: Create/Update Pull Request
if: >-
steps.check.outputs.hasTopic == 'true'&&
steps.check.outputs.hasTopic == 'true' &&
steps.check.outputs.isLatestRelease == 'true' &&
fromJson(steps.download.outputs.downloaded_files)[0]
uses: peter-evans/create-pull-request@v7
Expand All @@ -102,8 +102,7 @@ jobs:
commit-message: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}
branch: bot/bump-${{ github.repository }}-${{ github.event.release.tag_name }}
delete-branch: true
base: master
title: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}
title: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}"
body: ${{ github.event.release.body }}
labels: |
auto-approve
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
[![GitHub stars](https://img.shields.io/github/stars/lizardbyte/sunshine.svg?logo=github&style=for-the-badge)](https://github.com/LizardByte/Sunshine)
[![GitHub Releases](https://img.shields.io/github/downloads/lizardbyte/sunshine/total.svg?style=for-the-badge&logo=github)](https://github.com/LizardByte/Sunshine/releases/latest)
[![Docker](https://img.shields.io/docker/pulls/lizardbyte/sunshine.svg?style=for-the-badge&logo=docker)](https://hub.docker.com/r/lizardbyte/sunshine)
[![Flathub installs](https://img.shields.io/flathub/downloads/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub)](https://flathub.org/apps/dev.lizardbyte.app.Sunshine)
[![Flathub Version](https://img.shields.io/flathub/v/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub)](https://flathub.org/apps/dev.lizardbyte.app.Sunshine)
[![GHCR](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2FSunshine%2Fsunshine.json&query=%24.downloads&label=ghcr%20pulls&style=for-the-badge&logo=github)](https://github.com/LizardByte/Sunshine/pkgs/container/sunshine)
[![Winget Version](https://img.shields.io/badge/dynamic/json.svg?color=orange&label=Winget&style=for-the-badge&prefix=v&query=$[-1:].name&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmicrosoft%2Fwinget-pkgs%2Fcontents%2Fmanifests%2Fl%2FLizardByte%2FSunshine&logo=microsoft)](https://github.com/microsoft/winget-pkgs/tree/master/manifests/l/LizardByte/Sunshine)
[![Winget Version](https://img.shields.io/badge/dynamic/json.svg?color=orange&label=Winget&style=for-the-badge&prefix=v&query=$[-1:].name&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fmicrosoft%2Fwinget-pkgs%2Fcontents%2Fmanifests%2Fl%2FLizardByte%2FSunshine&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHuSURBVFhH7ZfNTtRQGIYZiMDwN/IrCAqIhMSNKxcmymVwG+5dcDVsWHgDrtxwCYQVl+BChzDEwSnPY+eQ0sxoOz1mQuBNnpyvTdvz9jun5/SrjfxnJUkyQbMEz2ELduF1l0YUA3QyTrMAa2AnPtyOXsELeAYNyKtV2EC3k3lYgTOwg09ghy/BTp7CKBRV844BOpmmMV2+ySb4BmInG7AKY7AHH+EYqqhZo9PPBG/BVDlOizAD/XQFmnoPXzxRQX8M/CCYS48L6RIc4ygGHK9WGg9HZSZMUNRPVwNJGg5Hg2Qgqh4N3FsDsb6EmgYm07iwwvUxstdxJTwgmILf4CfZ6bb5OHANX8GN5x20IVxnG8ge94pt2xpwU3GnCwayF4Q2G2vgFLzHndFzQdk4q77nNfCdwL28qNyMtmEf3A1/QV5FjDiPWo5jrwf8TWZChTlgJvL4F9QL50/A43qVidTvLcuoM2wDQ1+IkgefgUpLcYwMVBqCKNJA2b0gKNocOIITOIef8C/F/CdMbh/GklynsSawKLHS8d9/B1x2LUqsfFyy3TMsWj5A1cLkotDbYO4JjWWZlZEGv8EbOIR1CAVN2eG8W5oNKgxaeC6DmTJjZs7ixUxpznLPLT+v4sXpoMLcLI3mzFSonDXIEI/M3QCIO4YuimBJ/gAAAABJRU5ErkJggg==)](https://github.com/microsoft/winget-pkgs/tree/master/manifests/l/LizardByte/Sunshine)
[![GitHub Workflow Status (CI)](https://img.shields.io/github/actions/workflow/status/lizardbyte/sunshine/CI.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/Sunshine/actions/workflows/CI.yml?query=branch%3Amaster)
[![GitHub Workflow Status (localize)](https://img.shields.io/github/actions/workflow/status/lizardbyte/sunshine/localize.yml.svg?branch=master&label=localize%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/Sunshine/actions/workflows/localize.yml?query=branch%3Amaster)
[![Read the Docs](https://img.shields.io/readthedocs/sunshinestream.svg?label=Docs&style=for-the-badge&logo=readthedocs)](http://sunshinestream.readthedocs.io)
Expand Down
2 changes: 2 additions & 0 deletions cmake/prep/special_package_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ elseif(UNIX)
# configure the flatpak manifest
if(${SUNSHINE_CONFIGURE_FLATPAK_MAN})
configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.yml ${PROJECT_FQDN}.yml @ONLY)
configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.metainfo.xml
${PROJECT_FQDN}.metainfo.xml @ONLY)
file(COPY packaging/linux/flatpak/deps/ DESTINATION ${CMAKE_BINARY_DIR})
file(COPY packaging/linux/flatpak/modules DESTINATION ${CMAKE_BINARY_DIR})
endif()
Expand Down
16 changes: 9 additions & 7 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,24 @@ CUDA is used for NVFBC capture.
<td>sunshine-ubuntu-24.04-{arch}.deb</td>
</tr>
<tr>
<td rowspan="2">12.0.0</td>
<td rowspan="4">525.60.13</td>
<td rowspan="1">12.0.0</td>
<td rowspan="3">525.60.13</td>
<td rowspan="4">50;52;60;61;62;70;72;75;80;86;87;89;90</td>
<td>sunshine_{arch}.flatpak</td>
</tr>
<tr>
<td>sunshine-debian-bookworm-{arch}.deb</td>
</tr>
<tr>
<td>12.4.0</td>
<td rowspan="1">12.4.0</td>
<td>sunshine-fedora-39-{arch}.rpm</td>
</tr>
<tr>
<td>12.5.1</td>
<td rowspan="1">12.5.1</td>
<td>sunshine.pkg.tar.zst</td>
</tr>
<tr>
<td rowspan="1">12.6.2</td>
<td rowspan="1">560.35.03</td>
<td>sunshine_{arch}.flatpak</td>
</tr>
<tr>
<td>n/a</td>
<td>n/a</td>
Expand Down
13 changes: 13 additions & 0 deletions packaging/linux/flatpak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Overview

[![Flathub installs](https://img.shields.io/flathub/downloads/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub)](https://flathub.org/apps/dev.lizardbyte.app.Sunshine)
[![Flathub Version](https://img.shields.io/flathub/v/dev.lizardbyte.app.Sunshine?style=for-the-badge&logo=flathub)](https://flathub.org/apps/dev.lizardbyte.app.Sunshine)

LizardByte has the full documentation hosted on [Read the Docs](https://sunshinestream.readthedocs.io).

## About

Sunshine is a self-hosted game stream host for Moonlight.

This repo is synced from the upstream [Sunshine](https://github.com/LizardByte/Sunshine) repo.
Please report issues and contribute to the upstream repo.
11 changes: 1 addition & 10 deletions packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@
flatpak run @PROJECT_FQDN@</p>
</description>

<releases>
<release version="0.23.1" date="2024-04-21"/>
<release version="0.23.0" date="2024-04-06"/>
<release version="0.22.2" date="2024-03-15"/>
<release version="0.22.1" date="2024-03-13"/>
<release version="0.22.0" date="2024-03-04"/>
<release version="0.21.0" date="2023-10-15"/>
<release version="0.20.0" date="2023-05-29"/>
<release version="0.19.1" date="2023-03-30"/>
</releases>
<releases></releases>

<developer_name>LizardByte</developer_name>
<screenshots>
Expand Down
Loading

0 comments on commit da07468

Please sign in to comment.