1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pleroma_ynh.git synced 2024-09-03 20:15:59 +02:00

Fix updater

This commit is contained in:
yalh76 2022-10-14 04:40:55 +02:00
parent 45d59f85c5
commit 34a985aef8
4 changed files with 34 additions and 35 deletions

View file

@ -28,7 +28,7 @@ pipeline_id=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/pipeli
# Sometimes the release name starts with a "v", so let's filter it out. # Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions. # You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1} version=${version:1}
fi fi
# Setting up the environment variables # Setting up the environment variables
@ -42,17 +42,14 @@ echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one # Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available" echo "::warning ::No new version available"
exit 0 exit 0
# Proceed only if a PR for this new version does not already exist # Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update" echo "::warning ::A branch already exists for this update"
exit 0 exit 0
fi fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#================================================= #=================================================
# UPDATE SOURCE FILES # UPDATE SOURCE FILES
#================================================= #=================================================
@ -61,29 +58,31 @@ echo "${#assets[@]} available asset(s)"
architectures=("amd64" "arm64" "arm") architectures=("amd64" "arm64" "arm")
for arch in ${architectures[@]}; do for arch in ${architectures[@]}; do
echo "Processing $arch release" echo "Processing $arch release"
artifact=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/pipelines/$pipeline_id/jobs" | jq -r '[ .[] | select((.status=="success") and (.stage=="release") and (.name=="'$arch'")).id|tostring ] | join(" ") ' | tr -d "'") job_url=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/pipelines/$pipeline_id/jobs" | jq -r '.[] | select((.status=="success") and (.stage=="release") and (.name=="'$arch'")) | .web_url')
if [ ! -z "$artifact" ]; then if [ ! -z "$job_url" ]; then
# Create the temporary directory asset_url="$job_url/artifacts/download?file_type=archive"
tempdir="$(mktemp -d)"
# Download sources and calculate checksum # Create the temporary directory
filename=${asset_url##*/} tempdir="$(mktemp -d)"
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory # Download sources and calculate checksum
rm -rf $tempdir filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
if [ $arch == "arm" ]; then # Delete temporary directory
arch="armhf" rm -rf $tempdir
fi
# Rewrite source file if [ $arch == "arm" ]; then
cat <<EOT > conf/$arch.src arch="armhf"
fi
# Rewrite source file
cat <<EOT > conf/$arch.src
SOURCE_URL=$asset_url SOURCE_URL=$asset_url
SOURCE_SUM=$checksum SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
@ -91,12 +90,12 @@ SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=
EOT EOT
echo "... conf/$arch.src updated" echo "... conf/$arch.src updated"
else else
echo "... artifact ignored" echo "... artifact ignored"
echo "::warning ::Artifact for $arch was not updated" echo "::warning ::Artifact for $arch was not updated"
fi fi
done done

View file

@ -1,5 +1,5 @@
SOURCE_URL= SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/220705/artifacts/download?file_type=archive
SOURCE_SUM= SOURCE_SUM=8b4e2ab17362c7b0ed3ca685e19d578ad842ac00cde2db7d8c54dfd5a4e05891
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,5 +1,5 @@
SOURCE_URL= SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/220709/artifacts/download?file_type=archive
SOURCE_SUM= SOURCE_SUM=e432310df95ae4d915a02082252df0346ca7e112ffa4484b6a05075778c71338
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,5 +1,5 @@
SOURCE_URL= SOURCE_URL=https://git.pleroma.social/pleroma/pleroma/-/jobs/220707/artifacts/download?file_type=archive
SOURCE_SUM= SOURCE_SUM=c31dd8bb62728887cfe5488ef5818dc5e57e90f6443fbcfd501ea12044d0a94c
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true