diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..be8035b --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# 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. + +#================================================= +# 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/tags" | jq -r '.[] | select( .prerelease != true ) | select( .name | contains("7.x-")) | .name' | sort -V | tail -1 | cut -d "-" -f2) +assets=("https://download.civicrm.org/civicrm-$version-drupal.tar.gz" "https://download.civicrm.org/civicrm-$version-l10n.tar.gz") + +# 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" +echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $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 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 0 +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. + +# 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 + *"drupal"*) + src="civicrm-drupal" + ;; + *"l10n"*) + src="civicrm-l10n" + ;; + *) + 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= +SOURCE_EXTRACT=true +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. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..a56d7cb --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,49 @@ +# 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, and fetch this Action from the YunoHost-Apps organization. +# 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@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + 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 updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false diff --git a/README.md b/README.md index 0da233f..9fe4581 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Open source constituent relationship management (CRM) for non-profits, NGOs and advocacy organizations. -**Shipped version:** 5.52.2~ynh1 +**Shipped version:** 5.63.2~ynh1 **Demo:** https://civicrm.org/demo diff --git a/README_fr.md b/README_fr.md index 51e9a22..f844949 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Gestion des relations avec les constituants (GRC/CRM) pour les organisations à but non lucratif, les ONG et les organisations de défense des droits. -**Version incluse :** 5.52.2~ynh1 +**Version incluse :** 5.63.2~ynh1 **Démo :** https://civicrm.org/demo diff --git a/check_process b/check_process index 02484f9..8205349 100644 --- a/check_process +++ b/check_process @@ -16,13 +16,15 @@ setup_public=1 upgrade=1 # 7 - upgrade=1 from_commit=b90ed18d3309d1124171a02934c4d0ae9b53a087 + #upgrade=1 from_commit=b90ed18d3309d1124171a02934c4d0ae9b53a087 # 5.30.1-7.0~ynh1 - upgrade=1 from_commit=a9d902b58a2114d6983fe84c3c0d3f6371335287 + #upgrade=1 from_commit=a9d902b58a2114d6983fe84c3c0d3f6371335287 # 5.34.0-7.0~ynh1 - upgrade=1 from_commit=df23950de037d65d55c4d3d8fef7eb651c02b7ba + #upgrade=1 from_commit=df23950de037d65d55c4d3d8fef7eb651c02b7ba # 5.34.0-7.0~ynh2 - upgrade=1 from_commit=836c3bf7101301340fa197851994ba898eafd293 + #upgrade=1 from_commit=836c3bf7101301340fa197851994ba898eafd293 + # 5.52.2~ynh1 + upgrade=1 from_commit=e5263194b69560d48338fe94d111afb460b047ee backup_restore=1 multi_instance=1 port_already_use=0 @@ -39,3 +41,5 @@ Notification=all name=5.34.0-7.0~ynh1 ; commit=836c3bf7101301340fa197851994ba898eafd293 name=5.34.0-7.0~ynh2 + ; commit=e5263194b69560d48338fe94d111afb460b047ee + name=5.52.2~ynh1 diff --git a/conf/civicrm-drupal.src b/conf/civicrm-drupal.src index d278e39..1d4548e 100644 --- a/conf/civicrm-drupal.src +++ b/conf/civicrm-drupal.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://storage.googleapis.com/civicrm/civicrm-stable/5.52.2/civicrm-5.52.2-drupal.tar.gz -SOURCE_SUM=39be21dcbde98b51a05b04c753477f9ea74eb30e3c45f73a00f5e6b3988ab1b8 +SOURCE_URL=https://download.civicrm.org/civicrm-5.63.2-drupal.tar.gz +SOURCE_SUM=5c485c416e80f6bb1a19ae0975ec23ecd4106b7ed7dbbe05b0feb7665d35cdf7 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/civicrm-l10n.src b/conf/civicrm-l10n.src index a55e5ed..1234aef 100644 --- a/conf/civicrm-l10n.src +++ b/conf/civicrm-l10n.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://storage.googleapis.com/civicrm/civicrm-stable/5.52.2/civicrm-5.52.2-l10n.tar.gz -SOURCE_SUM=b857dfd08e30153a8485cefd3650e3c72769de093d0f691bb873007cf65bd1ec +SOURCE_URL=https://download.civicrm.org/civicrm-5.63.2-l10n.tar.gz +SOURCE_SUM=59714185505e7098c2e41ac0513c559a2c5258c1349d8d54320c7fe44f4de165 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 4358471..1995e09 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CRM for non-profits, NGOs and advocacy organizations", "fr": "CRM pour organisations à but non lucratif et ONG" }, - "version": "5.52.2~ynh1", + "version": "5.63.2~ynh1", "url": "https://civicrm.org", "upstream": { "license": "AGPL-3.0-or-later", diff --git a/scripts/_common.sh b/scripts/_common.sh index 5deec2d..a0088fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,9 @@ # PHP APP SPECIFIC #================================================= -php_dependencies="php$YNH_DEFAULT_PHP_VERSION-fpm php$YNH_DEFAULT_PHP_VERSION-cli php$YNH_DEFAULT_PHP_VERSION-gd php$YNH_DEFAULT_PHP_VERSION-mysql php$YNH_DEFAULT_PHP_VERSION-xml php$YNH_DEFAULT_PHP_VERSION-ldap php$YNH_DEFAULT_PHP_VERSION-mbstring php$YNH_DEFAULT_PHP_VERSION-curl php$YNH_DEFAULT_PHP_VERSION-soap" +YNH_PHP_VERSION="8.1" + +php_dependencies="php$YNH_PHP_VERSION-fpm php$YNH_PHP_VERSION-cli php$YNH_PHP_VERSION-gd php$YNH_PHP_VERSION-mysql php$YNH_PHP_VERSION-xml php$YNH_PHP_VERSION-ldap php$YNH_PHP_VERSION-mbstring php$YNH_PHP_VERSION-curl php$YNH_PHP_VERSION-soap php$YNH_PHP_VERSION-intl" # dependencies used by the app (must be on a single line) pkg_dependencies="curl libzip-dev $php_dependencies" diff --git a/scripts/install b/scripts/install index 06cfbe8..66e6f70 100644 --- a/scripts/install +++ b/scripts/install @@ -177,7 +177,7 @@ pushd "$final_path" ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH drush --include="$final_path/$app/sites/all/modules/civicrm/drupal/drush" @$app civicrm-install --dbhost="localhost" --dbname="$db_name" --dbpass="$db_pwd" --dbuser="$db_user" --destination="sites/all/modules" --site_url="$domain$path_url" --ssl=on popd -update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} +# update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" ynh_store_file_checksum --file="$final_path/$app/sites/default/civicrm.settings.php" diff --git a/scripts/upgrade b/scripts/upgrade index 48d6dbd..4e6d9b9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -160,7 +160,7 @@ pushd "$final_path" chown -R $app:www-data "$final_path" popd -update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} +# update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" ynh_store_file_checksum --file="$final_path/$app/sites/default/civicrm.settings.php"