2024-08-27 08:01:15 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FETCHING LATEST SHA256SUM
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Fetching information
|
|
|
|
version_current=$(cat manifest.toml | tomlq -j '.version')
|
|
|
|
version_app=$(cat manifest.toml | tomlq -j '.version|split("~ynh")[0]')
|
|
|
|
version_ynh=$(cat manifest.toml | tomlq -j '.version|split("~ynh")[1]')
|
2024-08-27 17:38:53 +02:00
|
|
|
version_next="$version_app~ynh$(($version_ynh+1))"
|
2024-08-27 22:22:48 +02:00
|
|
|
version=$(echo "$version_next" | 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-27 08:01:15 +02:00
|
|
|
amd64_sha_last=$(curl --silent "$amd64_url" | sha256sum)
|
|
|
|
|
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-27 08:01:15 +02:00
|
|
|
arm64_sha_last=$(curl --silent "$arm64_url" | sha256sum)
|
|
|
|
# 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:17:56 +02:00
|
|
|
if [ "$amd64_sha_current" == "$amd64_sha_last" ] && [ "$arm64_sha_current" == "$amd64_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 22:14:48 +02:00
|
|
|
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$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-27 21:53:23 +02:00
|
|
|
# Setting up the environment variables
|
|
|
|
echo "Current version: $version_current"
|
|
|
|
echo "Latest version: $version_next"
|
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
|
|
|
|
sed -i "s/^version = .*/version = \"$version_next\"/" manifest.toml
|
|
|
|
|
|
|
|
# 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
|