WORKFLOW: revamped push_flathub_main [skip ci]

This commit is contained in:
XargonWan 2025-02-03 10:10:33 +09:00
parent f722e256ed
commit 287780c5a5
3 changed files with 91 additions and 81 deletions

View file

@ -12,84 +12,4 @@ jobs:
steps:
- name: Pushing
shell: bash
run: |
# EDITABLES:
rd_branch=${GITHUB_REF_NAME} # should be main
echo $rd_branch
gits_folder="${GITHUB_WORKSPACE}/gits" # without last /
mkdir -vp $gits_folder
cd $gits_folder
if [ -d flathub ]; then
rm -rf flathub
fi
git clone --recursive https://github.com/flathub/net.retrodeck.retrodeck.git flathub
cd $gits_folder
git clone --recursive https://github.com/RetroDECK/RetroDECK RetroDECK
cd $gits_folder/RetroDECK
relname="main-"$(git rev-parse --short HEAD)
git checkout $rd_branch
cd $gits_folder/flathub
git checkout -b $relname
git rm -rf *
git clean -fxd # restroing git index
# Copying only a few files as the others are cloned by git in retrodeck.sh
cd $gits_folder/RetroDECK
cp -rf \
'LICENSE' \
'README.md' \
$gits_folder/flathub/
cd $gits_folder/flathub
ls -lah
# Creating the manifest for flathub
manifest='net.retrodeck.retrodeck.yml'
sed -n '/cleanup/q;p' $gits_folder/RetroDECK/net.retrodeck.retrodeck.yml > $manifest
sed -i '/^[[:space:]]*#/d' $manifest
sed -i 's/[[:space:]]*#.*$//' $manifest
cat << EOF >> $manifest
modules:
- name: retrodeck
buildsystem: simple
build-commands:
- cp -rn files/* /app
sources:
- type: archive
url: https://artifacts.retrodeck.net/artifacts/RetroDECK-Artifact.tar.gz
sha256: __SHA__
EOF
cat << EOF >> flathub.json
{
"only-arches": ["x86_64"]
}
EOF
# Getting latest release name
# version=$(\
# curl -sL \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.TRIGGER_BUILD_TOKEN }}" \
# https://api.github.com/repos/RetroDECK/Cooker/releases \
# | jq .[0].tag_name \
# | tr -d \" \
# )
sha=$(curl -sL https://artifacts.retrodeck.net/artifacts/RetroDECK-Artifact.sha)
sed -i "s#__SHA__#$sha#g" net.retrodeck.retrodeck.yml
git config --global user.name "${{ secrets.GITNAME }}"
git config --global user.email "${{ secrets.GITMAIL }}"
git add *
git commit -m "Updated flathub/net.retrodeck.retrodeck from RetroDECK/$rd_branch"
git push --force https://${{ secrets.TRIGGER_BUILD_TOKEN }}@github.com/flathub/net.retrodeck.retrodeck.git $relname
run: automation_tools/flathub_push_main.sh

2
.gitignore vendored
View file

@ -26,6 +26,8 @@ incconfigs/
net.retrodeck.retrodeck.cached.yml
placeholders.cache
RetroDECK*Artifact.tar.gz
./gits
flathub.json
# Components artifacts #
############################

View file

@ -0,0 +1,88 @@
#!/bin/bash
# EDITABLES:
#rd_branch=${GITHUB_REF_NAME} # should be main
gits_folder="/tmp/${GITHUB_WORKSPACE}/gits" # without last /
rd_branch="main"
flathub_target_repo='flathub/net.retrodeck.retrodeck'
retrodeck_repo='RetroDECK/RetroDECK'
artifacts_sha_link="https://artifacts.retrodeck.net/artifacts/RetroDECK-Artifact.sha"
artifacts_link="https://artifacts.retrodeck.net/artifacts/RetroDECK-Artifact.tar.gz"
mkdir -vp "$gits_folder"
cd "$gits_folder" || exit 1
if [ -d flathub ]; then
rm -rf flathub
fi
git clone --depth=1 --recursive "https://github.com/$flathub_target_repo.git" flathub
cd "$gits_folder" || exit 1
git clone --depth=1 --recursive "https://github.com/$retrodeck_repo.git" RetroDECK
cd "$gits_folder/RetroDECK" || exit 1
relname=$(curl -s https://api.github.com/repos/$retrodeck_repo/releases | jq -r '[.[] | select(.prerelease == true)][0].tag_name // empty')
if [ -z "$relname" ]; then
relname=$(curl -s https://api.github.com/repos/$retrodeck_repo/releases/latest | jq -r .tag_name)
fi
echo "Using release: $relname"
git checkout "$rd_branch"
cd "$gits_folder/flathub" || exit 1
git checkout -b "$relname"
git rm -rf *
git clean -fxd # restroing git index
# Copying only a few files as the others are cloned by git in retrodeck.sh
cd "$gits_folder/RetroDECK" || exit 1
cp -rf \
'LICENSE' \
'README.md' \
'other_licenses.txt' \
"$gits_folder/flathub/"
cd "$gits_folder/flathub" || exit 1
ls -lah
# Creating the manifest for flathub
manifest='net.retrodeck.retrodeck.yml'
sed -n '/cleanup/q;p' $gits_folder/RetroDECK/net.retrodeck.retrodeck.yml > $manifest
sed -i '/^[[:space:]]*#/d' $manifest
sed -i 's/[[:space:]]*#.*$//' $manifest
cat << EOF >> $manifest
modules:
- name: retrodeck
buildsystem: simple
build-commands:
- cp -rn files/* /app
sources:
- type: archive
url: $artifacts_link
sha256: $(curl -sL "$artifacts_sha_link")
EOF
cat << EOF >> flathub.json
{
"only-arches": ["x86_64"]
}
EOF
if [ -n "${GITHUB_WORKFLOW}" ]; then
git config user.name "${{ secrets.GITNAME }}"
git config user.email "${{ secrets.GITMAIL }}"
elif [[ -z $(git config --get user.name) || -z $(git config --get user.email) ]]; then
read -p "No git user.name set, please enter your name: " git_username
git config --global user.name "$git_username"
read -p "No git user.email set, please enter your email: " git_email
git config --global user.email "$git_email"
fi
if [ -n "${GITHUB_WORKFLOW}" ]; then
secret="${{ secrets.TRIGGER_BUILD_TOKEN }}@"
fi
git add *
git commit -m "Updated flathub/net.retrodeck.retrodeck to v$relname from RetroDECK/$rd_branch"
git push --force https://"$secret"github.com/"$flathub_target_repo.git" "$relname"