diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..9488298 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,137 @@ +#!/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 --location --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets=($(curl --location --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" +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 + *"linux_amd64"*) + src="amd64" + ;; + *"linux_arm64"*) + src="arm64" + ;; + *"linux_arm7"*) + src="amhf" + ;; + *) + 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..fb72ba0 --- /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@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 }} + draft: false diff --git a/README.md b/README.md index 5500291..faf7dbd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # WriteFreely for YunoHost -[![Integration level](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) ![Working status](https://ci-apps.yunohost.org/ci/badges/writefreely.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/writefreely.maintain.svg) [![Install WriteFreely with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=writefreely) *[Lire ce readme en français.](./README_fr.md)* @@ -21,14 +21,14 @@ Can be run as Single User Blog or Multi User Instance. Each User can be limited from 1 to unlimited blogs. -**Shipped version:** 0.13.1~ynh2 +**Shipped version:** 0.13.1~ynh3 **Demo:** https://write.as/new ## Screenshots -![](./doc/screenshots/screenshots2.png) -![](./doc/screenshots/screenshots1.png) +![Screenshot of WriteFreely](./doc/screenshots/screenshots2.png) +![Screenshot of WriteFreely](./doc/screenshots/screenshots1.png) ## Disclaimers / important information @@ -41,21 +41,22 @@ Each User can be limited from 1 to unlimited blogs. ## Documentation and resources -* Official app website: https://writefreely.org -* Official user documentation: https://writefreely.org/start -* Upstream app code repository: https://github.com/writeas/writefreely -* YunoHost documentation for this app: https://yunohost.org/app_writefreely -* Report a bug: https://github.com/YunoHost-Apps/writefreely_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/writefreely_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/writefreely_ynh/tree/testing --debug or sudo yunohost app upgrade writefreely -u https://github.com/YunoHost-Apps/writefreely_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 99838f4..81cfe6d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # WriteFreely pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/writefreely.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/writefreely.maintain.svg) [![Installer WriteFreely avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=writefreely) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer WriteFreely 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.* @@ -17,14 +21,14 @@ Can be run as Single User Blog or Multi User Instance. Each User can be limited from 1 to unlimited blogs. -**Version incluse :** 0.13.1~ynh2 +**Version incluse :** 0.13.1~ynh3 **Démo :** https://write.as/new ## Captures d'écran -![](./doc/screenshots/screenshots2.png) -![](./doc/screenshots/screenshots1.png) +![Capture d'écran de WriteFreely](./doc/screenshots/screenshots2.png) +![Capture d'écran de WriteFreely](./doc/screenshots/screenshots1.png) ## Avertissements / informations importantes @@ -37,21 +41,22 @@ Each User can be limited from 1 to unlimited blogs. ## Documentations et ressources -* Site officiel de l'app : https://writefreely.org -* Documentation officielle utilisateur : https://writefreely.org/start -* Dépôt de code officiel de l'app : https://github.com/writeas/writefreely -* Documentation YunoHost pour cette app : https://yunohost.org/app_writefreely -* Signaler un bug : https://github.com/YunoHost-Apps/writefreely_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/writefreely_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/writefreely_ynh/tree/testing --debug ou sudo yunohost app upgrade writefreely -u https://github.com/YunoHost-Apps/writefreely_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 58ecacd..65e22ba 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,9 @@ ;; Test complet ; Manifest domain="domain.tld" - admin="john" is_public=1 - password="pass" + admin="john" + password="1Strong-Password" single_user=1 ; Checks pkg_linter=1 @@ -34,22 +34,5 @@ port_already_use=0 change_url=1 ;;; Options -Email=yalh@yahoo.com -Notification=all -;;; Upgrade options - ; commit=093ec18f9f5282e1a137c0ac5444a414ee2b83bc - name=0.8.1~ynh4 - ; commit=45584b220e911c573643cb1e213e75fc42547818 - name=0.11.2~ynh1 - ; commit=4b7c851074c4e785c414944905a8cfb2a0d19ff1 - name=0.12.0~ynh1 - ; commit=5ac207e14985bda77dc797353902548696622b41 - name=0.12.0~ynh3 - ; commit=d75ccbc460b04ef95f3d8b1a72ee77fc7815c6a2 - name=0.12.0~ynh4 - ; commit=b387e4186a02c387d734cf25f4fed9283c01d55f - name=0.12.0~ynh6 - ; commit=06afb5c5a1896185eec6e63ffcb929f0216db2ec - name=0.13.0~ynh1 - ; commit=e30ec378dc703227fcfe542d19f35e2838192094 - name=0.13.1~ynh1 +Email= +Notification=none diff --git a/conf/armel.src b/conf/armhf.src similarity index 100% rename from conf/armel.src rename to conf/armhf.src diff --git a/manifest.json b/manifest.json index bae4b45..9e7c4f0 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "For starting a minimalist, federated blog or an entire community.", "fr": "Permet de créer un blog fédéré minimaliste ou une communauté entière." }, - "version": "0.13.1~ynh2", + "version": "0.13.1~ynh3", "url": "https://writefreely.org", "upstream": { "license": "AGPL-3.0-or-later", @@ -33,15 +33,15 @@ "name": "domain", "type": "domain" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", "default": true }, + { + "name": "admin", + "type": "user" + }, { "name": "password", "type": "password" diff --git a/scripts/change_url b/scripts/change_url index dcc7c61..49b583c 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 ff323db..15a892e 100755 --- a/scripts/install +++ b/scripts/install @@ -25,14 +25,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC - +admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD single_user=$YNH_APP_ARG_SINGLE_USER -architecture=$YNH_ARCH - # Bypass package_checker name not compatible with writefreely if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then admin="test" @@ -45,6 +42,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." +architecture=$YNH_ARCH # Check machine architecture, we don't support 32bit machines if [ $architecture = "i386" ] then @@ -84,7 +82,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE @@ -126,7 +124,7 @@ ynh_script_progression --message="Adding a configuration file..." ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" -chmod 400 "$final_path/config.ini" +chmod 600 "$final_path/config.ini" chown $app:$app "$final_path/config.ini" #================================================= diff --git a/scripts/restore b/scripts/restore index 0314885..7d80661 100755 --- a/scripts/restore +++ b/scripts/restore @@ -43,20 +43,13 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -71,6 +64,13 @@ chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 36a923a..c017549 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -100,7 +100,7 @@ fi ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -147,7 +147,7 @@ ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" -chmod 400 "$final_path/config.ini" +chmod 600 "$final_path/config.ini" chown $app:$app "$final_path/config.ini" #=================================================