-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
024bd8f
commit da07468
Showing
11 changed files
with
277 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/&/\&/g; s/</\</g; s/>/\>/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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.