diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..c3d5a7a --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,134 @@ +#!/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]') +# 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://framagit.org/api/v4/projects/20125/releases" | jq -r '.[] | select( .tag_name | contains("rc") or contains("beta") | not ) | .tag_name' | sort -V | tail -1) +assets=($(curl --silent "https://framagit.org/api/v4/projects/20125/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets.links[].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" +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 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 + *"amd64"*) + src="amd64" + ;; + *"arm64"*) + src="arm64" + ;; + *"arm"*) + src="arm" + ;; + *) + 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. + +#================================================= +# 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..6f3c1b9 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,52 @@ +# 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@v2 + 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@v3 + 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 }} + [See upstream release page](${{ env.RELEASE }}) + Provided description: + ${{ env.DESCRIPTION }} + draft: false diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6133a24..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: python - -before_install: - - git clone https://github.com/YunoHost/package_linter /tmp/package_linter - -script: -- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/README.md b/README.md index 1be2d24..8743859 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Mobilizon for YunoHost -[![Integration level](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) ![Working status](https://ci-apps.yunohost.org/ci/badges/mobilizon.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mobilizon.maintain.svg) [![Install Mobilizon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mobilizon) *[Lire ce readme en français.](./README_fr.md)* @@ -23,13 +23,13 @@ A decentralized and federated platform to organize events -**Shipped version:** 2.0.2~ynh1 +**Shipped version:** 2.0.2~ynh2 **Demo:** https://demo.mobilizon.org ## Screenshots -![](./doc/screenshots/screenshot1.jpg) +![Screenshot of Mobilizon](./doc/screenshots/screenshot1.jpg) ## Disclaimers / important information @@ -42,21 +42,22 @@ A decentralized and federated platform to organize events ## Documentation and resources -* Official app website: https://joinmobilizon.org/ -* Official user documentation: https://docs.joinmobilizon.org -* Upstream app code repository: https://framagit.org/framasoft/mobilizon/ -* YunoHost documentation for this app: https://yunohost.org/app_mobilizon -* Report a bug: https://github.com/YunoHost-Apps/mobilizon_ynh/issues +* Official app website: +* Official user documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug or sudo yunohost app upgrade mobilizon -u https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index efb011b..d052fed 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Mobilizon pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mobilizon.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/mobilizon.svg)](https://dash.yunohost.org/appci/app/mobilizon) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mobilizon.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mobilizon.maintain.svg) [![Installer Mobilizon avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mobilizon) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer Mobilizon rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* @@ -19,13 +23,13 @@ A decentralized and federated platform to organize events -**Version incluse :** 2.0.2~ynh1 +**Version incluse :** 2.0.2~ynh2 **Démo :** https://demo.mobilizon.org ## Captures d'écran -![](./doc/screenshots/screenshot1.jpg) +![Capture d'écran de Mobilizon](./doc/screenshots/screenshot1.jpg) ## Avertissements / informations importantes @@ -38,21 +42,22 @@ A decentralized and federated platform to organize events ## Documentations et ressources -* Site officiel de l'app : https://joinmobilizon.org/ -* Documentation officielle utilisateur : https://docs.joinmobilizon.org -* Dépôt de code officiel de l'app : https://framagit.org/framasoft/mobilizon/ -* Documentation YunoHost pour cette app : https://yunohost.org/app_mobilizon -* Signaler un bug : https://github.com/YunoHost-Apps/mobilizon_ynh/issues +* Site officiel de l'app : +* Documentation officielle utilisateur : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug ou sudo yunohost app upgrade mobilizon -u https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** diff --git a/check_process b/check_process index 65980fe..10611c5 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,9 @@ ;; Test complet ; Manifest domain="domain.tld" - admin="john" - language="fr" is_public=1 + language="fr" + admin="john" password="password" name="My_Mobilizon" ; Checks @@ -17,13 +17,15 @@ # 1.1.3~ynh1 # upgrade=1 from_commit=87d34001dd0b77aed4fa7be2911bc04f58b069ee # 1.1.4~ynh1 - upgrade=1 from_commit=215b20b0d35178a2c3405a7e3239eba81e22c060 + # upgrade=1 from_commit=215b20b0d35178a2c3405a7e3239eba81e22c060 # 1.2.2~ynh1 - upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc + # upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc # 1.2.3~ynh1 - upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea + # upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea # 1.3.2~ynh1 - upgrade=1 from_commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4 + # upgrade=1 from_commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4 + # 2.0.2~ynh1 + upgrade=1 from_commit=0159fc6123536cdf2929b4617d89753283f6946d backup_restore=1 multi_instance=0 port_already_use=0 @@ -31,14 +33,3 @@ ;;; Options Email=yalh@yahoo.com Notification=all -;;; Upgrade options - ; commit=87d34001dd0b77aed4fa7be2911bc04f58b069ee - name=1.1.3~ynh1 - ; commit=215b20b0d35178a2c3405a7e3239eba81e22c060 - name=1.1.4~ynh1 - ; commit=b63c7833f80de56bbc4a255ddda3b865a5637afc - name=1.2.2~ynh1 - ; commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea - name=1.2.3~ynh1 - ; commit=e3c0b208c0b76a55e8df2a3947f57bb762b017d4 - name=1.3.2~ynh1 diff --git a/manifest.json b/manifest.json index 7cb471e..e73cec2 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A decentralized and federated platform to organize events", "fr": "Une plateforme décentralisée et fédérée pour organiser des événements" }, - "version": "2.0.2~ynh1", + "version": "2.0.2~ynh2", "url": "https://joinmobilizon.org/", "upstream": { "license": "AGPL-3.0-or-later", @@ -27,15 +27,11 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", @@ -50,6 +46,10 @@ }, "choices": ["fr", "en"], "default": "fr" + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/change_url b/scripts/change_url index ac2b095..2c59d1d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -42,6 +42,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" diff --git a/scripts/install b/scripts/install index d0f09eb..58ca943 100644 --- a/scripts/install +++ b/scripts/install @@ -25,9 +25,9 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE +admin=$YNH_APP_ARG_ADMIN admin_email=$(ynh_user_get_info $admin 'mail') ynh_user_password=$(ynh_string_random --length=30) architecture=$YNH_ARCH @@ -54,8 +54,8 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password diff --git a/scripts/upgrade b/scripts/upgrade index 5628f18..ef896c6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,9 +19,9 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +language=$(ynh_app_setting_get --app=$app --key=language) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) @@ -161,8 +161,6 @@ if ynh_version_gt "1.2.3~ynh1" "${previous_version}" ; then ynh_store_file_checksum --file="$final_path/live/config/runtime.exs" fi -ynh_remove_nodejs - if ynh_version_gt "2.0.2~ynh1" "${previous_version}" ; then mkdir -p /etc/$app if [ -f "$final_path/live/config/prod.secret.exs" ]; then @@ -224,7 +222,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DATADIR FOLDER #================================================= - ynh_script_progression --message="Create datadir folder..." mkdir -p $datadir