2025-02-03 01:10:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# EDITABLES:
|
|
|
|
#rd_branch=${GITHUB_REF_NAME} # should be main
|
|
|
|
|
2025-02-03 02:11:48 +00:00
|
|
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
|
|
|
GITHUB_WORKSPACE="."
|
|
|
|
fi
|
|
|
|
|
|
|
|
gits_folder="${GITHUB_WORKSPACE}/tmp/gits" # without last /
|
2025-02-03 01:10:33 +00:00
|
|
|
|
|
|
|
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
|
2025-02-03 02:32:44 +00:00
|
|
|
if [ -d flathub ]; then
|
|
|
|
rm -rf RetroDECK
|
|
|
|
fi
|
2025-02-03 01:10:33 +00:00
|
|
|
git clone --depth=1 --recursive "https://github.com/$flathub_target_repo.git" flathub
|
|
|
|
git clone --depth=1 --recursive "https://github.com/$retrodeck_repo.git" RetroDECK
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
2025-02-03 02:32:44 +00:00
|
|
|
cd "$gits_folder/RetroDECK" && echo "Moving in $gits_folder/RetroDECK" && git checkout "$rd_branch"
|
2025-02-03 01:10:33 +00:00
|
|
|
|
2025-02-03 02:32:44 +00:00
|
|
|
cd "$gits_folder/flathub" && echo "Moving in $gits_folder/flathub" || exit 1
|
2025-02-03 01:10:33 +00:00
|
|
|
git checkout -b "$relname"
|
2025-02-03 02:32:44 +00:00
|
|
|
echo "Current directory: $(pwd)"
|
|
|
|
ls -lah
|
2025-02-03 02:35:35 +00:00
|
|
|
git rm -rf *
|
2025-02-03 01:10:33 +00:00
|
|
|
git clean -fxd # restroing git index
|
|
|
|
|
|
|
|
# Copying only a few files as the others are cloned by git in retrodeck.sh
|
2025-02-03 02:42:11 +00:00
|
|
|
files_to_copy=('LICENSE' 'README.md' 'other_licenses.txt' 'net.retrodeck.retrodeck.yml' 'net.retrodeck.retrodeck.metainfo.xml')
|
2025-02-03 01:26:14 +00:00
|
|
|
for file in "${files_to_copy[@]}"; do
|
2025-02-03 02:32:44 +00:00
|
|
|
if ! cp -fv "$gits_folder/RetroDECK/$file" "$gits_folder/flathub"; then
|
2025-02-03 01:26:14 +00:00
|
|
|
echo "Warning: $file not found in $gits_folder/RetroDECK"
|
|
|
|
fi
|
|
|
|
done
|
2025-02-03 01:10:33 +00:00
|
|
|
|
2025-02-03 02:41:31 +00:00
|
|
|
cd "$gits_folder/flathub" && echo "Moving in $gits_folder/flathub" || exit 1
|
2025-02-03 01:10:33 +00:00
|
|
|
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
|
|
|
|
|
2025-02-03 04:30:05 +00:00
|
|
|
# If we are in a GitHub workflow...
|
2025-02-03 01:10:33 +00:00
|
|
|
if [ -n "${GITHUB_WORKFLOW}" ]; then
|
2025-02-03 05:11:36 +00:00
|
|
|
git config --global user.name "$GIT_NAME"
|
|
|
|
git config --global user.email "$GIT_MAIL"
|
|
|
|
git config --global credential.helper store
|
|
|
|
gh auth login
|
2025-02-03 01:10:33 +00:00
|
|
|
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
|
2025-02-03 02:24:30 +00:00
|
|
|
git config --local user.name "$git_username"
|
2025-02-03 01:10:33 +00:00
|
|
|
read -p "No git user.email set, please enter your email: " git_email
|
2025-02-03 02:24:30 +00:00
|
|
|
git config --local user.email "$git_email"
|
2025-02-03 01:10:33 +00:00
|
|
|
fi
|
|
|
|
|
2025-02-03 04:30:05 +00:00
|
|
|
git add .
|
|
|
|
git commit -m "Update RetroDECK to v$relname from RetroDECK/$rd_branch"
|
2025-02-03 05:00:02 +00:00
|
|
|
|
|
|
|
if [ -n "${GITHUB_WORKFLOW}" ]; then
|
|
|
|
git push --force "https://${GITHUB_TOKEN}@github.com/${flathub_target_repo}" "$relname"
|
|
|
|
else
|
|
|
|
git push --force "https://github.com/${flathub_target_repo}" "$relname"
|
|
|
|
fi
|
|
|
|
|