From a3e8f0f6c43ff91af1d6179b1f1f4bba26238e93 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 4 Sep 2021 19:52:31 +0200 Subject: [PATCH 01/10] Implement GitHub Action to automatically upgrade from upstream --- .github/workflows/updater.sh | 104 ++++++++++++++++++++++++++++++++++ .github/workflows/updater.yml | 81 ++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100755 .github/workflows/updater.sh create mode 100644 .github/workflows/updater.yml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100755 index 0000000..f7949a7 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub actions: check out .github/workflows/updater.yml +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +# GitHub Actions should have made available the following environment variables: +# $ASSETS: +# The ASSETS environment variable is a space-separated list of urls +# of assets published with the latest upstream release. +# $VERSION: +# The new version of the app + +# Let's convert $ASSETS into an array. +eval "ASSETS=($ASSETS)" +echo "${#ASSETS[@]} available asset(s)" + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Here we use the $ASSETS variable to get the resources published +# in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with +# how the upstream releases look like. + +# Let's loop over the array of assets URLs +for asset_url in ${ASSETS[@]}; do + +echo "Handling asset at $asset_url" + +# Assign the asset to a source file in conf/ directory +# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) +# Leave $src empty to ignore the asset +case $asset_url in + *"admin"*) + src="app" + ;; + *"update"*) + src="app-upgrade" + ;; + *) + src="" + ;; +esac + +# If $src is not empty, let's process the asset +if [ ! -z "$src" ]; then + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +EOT +echo "... conf/$src.src updated" + +else +echo "... asset ignored" +fi + +done + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes +# after this script ends. + +# Note that there should be no need to tune manifest.json or the READMEs, since +# the GitHub Action workflow and yunohost-bot take care of them, respectively. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +echo "Done!" diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..684f7ba --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,81 @@ +# This workflow allows GitHub Actions to automagically update your app +# whenever a new upstream release is detected. +# You need to enable Actions in your repository settings. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Check if newer version is available upstream + id: check_version + run: | + # Install moreutils, needed for sponge + sudo apt-get install moreutils + # Fetching information + current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') + repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') + version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | .tag_name' | sort -V | tail -1) + assets=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'") + # Setting up the environment variables + echo ::set-output name=current_version::$current_version + echo "Current version: $current_version" + echo ::set-output name=latest_version::$version + echo "Latest release from upstream: $version" + echo "VERSION=$version" >> $GITHUB_ENV + echo "ASSETS=$assets" >> $GITHUB_ENV + if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo ::set-output name=to_update::false + echo "::warning ::No new version available" + elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo ::set-output name=to_update::false + echo "::warning ::A branch already exists for that" + else + echo ::set-output name=to_update::true + fi + - name: Update package files + id: update_files + if: steps.check_version.outputs.to_update == 'true' + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the version updater script + ./.github/workflows/updater.sh + # Replace new version in manifest + jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json + # Commit + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v3 + if: steps.check_version.outputs.to_update == 'true' + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false + - name: Check outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + echo "Current version - ${{ steps.check_version.outputs.current_version }}" + echo "New version - ${{ steps.check_version.outputs.latest_version }}" From d16f07529a89777b69fe6ce9c8bc6ba5808ff4af Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 6 Sep 2021 21:50:03 +0200 Subject: [PATCH 02/10] Improve GitHub Action to not fail if no update is needed --- .github/workflows/updater.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 684f7ba..5d02621 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -36,31 +36,37 @@ jobs: echo "VERSION=$version" >> $GITHUB_ENV echo "ASSETS=$assets" >> $GITHUB_ENV if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo ::set-output name=to_update::false + echo "PROCEED=false" >> $GITHUB_ENV echo "::warning ::No new version available" elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo ::set-output name=to_update::false - echo "::warning ::A branch already exists for that" + echo "PROCEED=false" >> $GITHUB_ENV + echo "::warning ::A branch already exists for this update" else - echo ::set-output name=to_update::true + echo "PROCEED=true" >> $GITHUB_ENV fi - name: Update package files id: update_files - if: steps.check_version.outputs.to_update == 'true' + if: ${{ env.PROCEED == 'true' }} run: | # Setting up Git user git config --global user.name 'yunohost-bot' git config --global user.email 'yunohost-bot@users.noreply.github.com' # Run the version updater script ./.github/workflows/updater.sh + retval=$? + # Check + if [ $retval -neq 0 ]; then + echo "PROCEED=false" >> $GITHUB_ENV + echo "::warning ::The updater script failed (exit code $retval)" + fi # Replace new version in manifest jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json # Commit git commit -am "Upgrade to v$VERSION" - name: Create Pull Request id: cpr + if: ${{ env.PROCEED == 'true' }} uses: peter-evans/create-pull-request@v3 - if: steps.check_version.outputs.to_update == 'true' with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Update to version ${{ env.VERSION }} @@ -74,6 +80,7 @@ jobs: Upgrade to v${{ env.VERSION }} draft: false - name: Check outputs + if: ${{ env.PROCEED == 'true' }} run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" From 12d34c6ee885df2c1e9f486f9df2ea6a377c8c17 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 11 Sep 2021 21:51:11 +0200 Subject: [PATCH 03/10] Improve GitHub Action to rely on the organization's workflow --- .github/workflows/updater.sh | 62 +++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index f7949a7..21b6abb 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -4,7 +4,8 @@ # PACKAGE UPDATING HELPER #================================================= -# This script is meant to be run by GitHub actions: check out .github/workflows/updater.yml +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically # Since each app is different, maintainers can adapt its contents so as to perform # automatic actions when a new upstream release is detected. @@ -15,21 +16,47 @@ # $VERSION: # The new version of the app -# Let's convert $ASSETS into an array. -eval "ASSETS=($ASSETS)" -echo "${#ASSETS[@]} available asset(s)" +# Remove this exit command when you are ready to run this Action +exit 1 + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | .tag_name' | sort -V | tail -1) +assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 1 +# 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 + echo "::warning ::A branch already exists for this update" + exit 1 +fi + +# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) +echo "${#assets[@]} available asset(s)" #================================================= # UPDATE SOURCE FILES #================================================= -# Here we use the $ASSETS variable to get the resources published -# in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with -# how the upstream releases look like. +# Here we use the $assets variable to get the resources published in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. # Let's loop over the array of assets URLs -for asset_url in ${ASSETS[@]}; do +for asset_url in ${assets[@]}; do echo "Handling asset at $asset_url" @@ -91,14 +118,19 @@ done #================================================= # Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes -# after this script ends. - -# Note that there should be no need to tune manifest.json or the READMEs, since -# the GitHub Action workflow and yunohost-bot take care of them, respectively. +# The GitHub Action workflow takes care of committing all changes after this script ends. #================================================= # GENERIC FINALIZATION #================================================= -echo "Done!" +# Install moreutils, needed for sponge +sudo apt-get install moreutils + +# Replace new version in manifest +jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if a 0 exit code is returned +exit 0 From 786ebb58871c620d87de4a7e4ff468be5b232be2 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 11 Sep 2021 21:58:28 +0200 Subject: [PATCH 04/10] Update comments in updater.sh --- .github/workflows/updater.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 21b6abb..323cdb2 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -9,13 +9,6 @@ # Since each app is different, maintainers can adapt its contents so as to perform # automatic actions when a new upstream release is detected. -# GitHub Actions should have made available the following environment variables: -# $ASSETS: -# The ASSETS environment variable is a space-separated list of urls -# of assets published with the latest upstream release. -# $VERSION: -# The new version of the app - # Remove this exit command when you are ready to run this Action exit 1 From 33a1d90082f22df716099f743aeedea61e21a5b1 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 11 Sep 2021 21:58:48 +0200 Subject: [PATCH 05/10] Now the Action comes from the organization --- .github/workflows/updater.yml | 88 ----------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 .github/workflows/updater.yml diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index 5d02621..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,88 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app -# whenever a new upstream release is detected. -# You need to enable Actions in your repository settings. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Check if newer version is available upstream - id: check_version - run: | - # Install moreutils, needed for sponge - sudo apt-get install moreutils - # Fetching information - current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') - repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') - version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | .tag_name' | sort -V | tail -1) - assets=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'") - # Setting up the environment variables - echo ::set-output name=current_version::$current_version - echo "Current version: $current_version" - echo ::set-output name=latest_version::$version - echo "Latest release from upstream: $version" - echo "VERSION=$version" >> $GITHUB_ENV - echo "ASSETS=$assets" >> $GITHUB_ENV - if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "PROCEED=false" >> $GITHUB_ENV - echo "::warning ::No new version available" - elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "PROCEED=false" >> $GITHUB_ENV - echo "::warning ::A branch already exists for this update" - else - echo "PROCEED=true" >> $GITHUB_ENV - fi - - name: Update package files - id: update_files - if: ${{ env.PROCEED == 'true' }} - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the version updater script - ./.github/workflows/updater.sh - retval=$? - # Check - if [ $retval -neq 0 ]; then - echo "PROCEED=false" >> $GITHUB_ENV - echo "::warning ::The updater script failed (exit code $retval)" - fi - # Replace new version in manifest - jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json - # Commit - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false - - name: Check outputs - if: ${{ env.PROCEED == 'true' }} - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" - echo "Current version - ${{ steps.check_version.outputs.current_version }}" - echo "New version - ${{ steps.check_version.outputs.latest_version }}" From e7a97667e71faf2f91cc6f9cfd5b2a223c2b44be Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 11 Sep 2021 22:11:35 +0200 Subject: [PATCH 06/10] Fix updater logics --- .github/workflows/updater.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 323cdb2..71c3762 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -27,15 +27,17 @@ assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ echo "Current version: $current_version" echo "Latest release from upstream: $version" echo "VERSION=$version" >> $GITHUB_ENV +# 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 if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then echo "::warning ::No new version available" - exit 1 + exit 0 # 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 echo "::warning ::A branch already exists for this update" - exit 1 + exit 0 fi # Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) @@ -125,5 +127,6 @@ jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge man # No need to update the README, yunohost-bot takes care of it -# The Action will proceed only if a 0 exit code is returned +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV exit 0 From 81d58fd97ddeaccc59676788b81ddffd10712fb0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Sep 2021 09:13:21 +0200 Subject: [PATCH 07/10] Fix version variable name in updater script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- .github/workflows/updater.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 71c3762..6823407 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -123,7 +123,7 @@ done sudo apt-get install moreutils # Replace new version in manifest -jq -s --indent 4 ".[] | .version = \"$VERSION~ynh1\"" manifest.json | sponge manifest.json +jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json | sponge manifest.json # No need to update the README, yunohost-bot takes care of it From ff501e44842e9e9a64c10fd3944d909460bde812 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Sep 2021 09:28:28 +0200 Subject: [PATCH 08/10] Ignore pre-releases in updater script --- .github/workflows/updater.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 6823407..891be20 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -20,7 +20,7 @@ exit 1 current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | .tag_name' | sort -V | tail -1) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) # Setting up the environment variables From ecc2d84031c38545560683afc27067f9325a145e Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Sep 2021 09:40:02 +0200 Subject: [PATCH 09/10] Rework manifest update to avoid relying on sponge Co-authored-by: Kayou --- .github/workflows/updater.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 891be20..c901b7e 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -119,11 +119,8 @@ done # GENERIC FINALIZATION #================================================= -# Install moreutils, needed for sponge -sudo apt-get install moreutils - # Replace new version in manifest -jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json | sponge manifest.json +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json # No need to update the README, yunohost-bot takes care of it From 404a64ef9796b9c569b47bd6a58dbb957e010efb Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 16 Sep 2021 20:46:34 +0200 Subject: [PATCH 10/10] Drop any leading V in the version tag and encourage maintainers to add more tweaks on that variable, if needed --- .github/workflows/updater.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index c901b7e..c4d53fc 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -23,6 +23,13 @@ repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1] version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +# Later down the script, we assume the version has only digits and dots +# 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. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version"