1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/immich_ynh.git synced 2024-09-03 20:36:24 +02:00
immich_ynh/.github/workflows/updater_ffmpeg-static.sh

64 lines
2.7 KiB
Bash
Raw Normal View History

2024-08-27 08:01:15 +02:00
#!/bin/bash
#=================================================
# FETCHING LATEST SHA256SUM
#=================================================
# Fetching information
version_current=$(cat manifest.toml | tomlq -j '.version')
2024-08-27 23:12:59 +02:00
# version_app=$(cat manifest.toml | tomlq -j '.version|split("~ynh")[0]')
# version_ynh=$(cat manifest.toml | tomlq -j '.version|split("~ynh")[1]')
# version_next="$version_app~ynh$(($version_ynh+1))"
# version=$(echo "$version_next" | tr '~' '-')
version=$(echo "$version_current" | tr '~' '-')
2024-08-27 08:01:15 +02:00
repo=$(cat manifest.toml | tomlq -j '.upstream.code|split("https://github.com/")[1]')
2024-08-27 17:38:53 +02:00
amd64_url=$(cat manifest.toml | tomlq -j '.resources.sources."ffmpeg-static".amd64.url')
amd64_sha_current=$(cat manifest.toml | tomlq -j '.resources.sources."ffmpeg-static".amd64.sha256')
2024-08-29 13:17:26 +02:00
amd64_sha_last=$(curl --silent "$amd64_url" | sha256sum - | cut -d " " -f1)
2024-08-27 08:01:15 +02:00
2024-08-27 17:38:53 +02:00
arm64_url=$(cat manifest.toml | tomlq -j '.resources.sources."ffmpeg-static".arm64.url')
arm64_sha_current=$(cat manifest.toml | tomlq -j '.resources.sources."ffmpeg-static".arm64.sha256')
2024-08-29 13:17:26 +02:00
arm64_sha_last=$(curl --silent "$arm64_url" | sha256sum - | cut -d " " -f1)
2024-08-27 08:01:15 +02:00
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
2024-08-27 22:25:44 +02:00
if [ "$amd64_sha_current" == "$amd64_sha_last" ] && [ "$arm64_sha_current" == "$arm64_sha_last" ]
2024-08-27 08:01:15 +02:00
then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
2024-08-27 23:12:59 +02:00
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-ffmpeg-static-sha-$version
2024-08-27 21:55:24 +02:00
then
2024-08-27 08:01:15 +02:00
echo "::warning ::A branch already exists for this update"
exit 0
fi
2024-08-29 13:13:20 +02:00
# Print some infos
2024-08-27 21:53:23 +02:00
echo "Current version: $version_current"
2024-08-29 13:13:20 +02:00
echo "Current ffmpeg-static amd64 sha : $amd64_sha_current"
2024-08-29 13:17:26 +02:00
echo "Last ffmpeg-static amd64 sha : $amd64_sha_last"
2024-08-29 13:13:20 +02:00
echo "Current ffmpeg-static arm64 sha : $arm64_sha_current"
2024-08-29 13:17:26 +02:00
echo "Last ffmpeg-static arm64 sha : $arm64_sha_last"
2024-08-27 23:12:59 +02:00
# echo "Latest version: $version_next"
2024-08-29 13:13:20 +02:00
# Setting up the environment variables
2024-08-27 22:14:48 +02:00
echo "VERSION=$version" >> $GITHUB_ENV
2024-08-27 21:53:23 +02:00
echo "REPO=$repo" >> $GITHUB_ENV
2024-08-27 08:01:15 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
2024-08-27 23:12:59 +02:00
# sed -i "s/^version = .*/version = \"$version_next\"/" manifest.toml
2024-08-27 08:01:15 +02:00
# Replace sha356sum in manifest
sed -i "s@^\"amd64.sha256\" = .*@\"amd64.sha256\" = \"$amd64_sha_last\"@" manifest.toml
sed -i "s@^\"arm64.sha256\" = .*@\"arm64.sha256\" = \"$arm64_sha_last\"@" manifest.toml
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0