1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

Merge pull request #132 from YunoHost-Apps/testing

Apply last example_ynh
This commit is contained in:
yalh76 2022-06-13 15:37:58 +02:00 committed by GitHub
commit 2dd97e4952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 231 additions and 59 deletions

134
.github/workflows/updater.sh vendored Normal file
View file

@ -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 <<EOT > 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

52
.github/workflows/updater.yml vendored Normal file
View file

@ -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 <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
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

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -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 ./

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Mobilizon for YunoHost # 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) [![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)* *[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 **Demo:** https://demo.mobilizon.org
## Screenshots ## Screenshots
![](./doc/screenshots/screenshot1.jpg) ![Screenshot of Mobilizon](./doc/screenshots/screenshot1.jpg)
## Disclaimers / important information ## Disclaimers / important information
@ -42,21 +42,22 @@ A decentralized and federated platform to organize events
## Documentation and resources ## Documentation and resources
* Official app website: https://joinmobilizon.org/ * Official app website: <https://joinmobilizon.org/>
* Official user documentation: https://docs.joinmobilizon.org * Official user documentation: <https://docs.joinmobilizon.org>
* Upstream app code repository: https://framagit.org/framasoft/mobilizon/ * Upstream app code repository: <https://framagit.org/framasoft/mobilizon/>
* YunoHost documentation for this app: https://yunohost.org/app_mobilizon * YunoHost documentation for this app: <https://yunohost.org/app_mobilizon>
* Report a bug: https://github.com/YunoHost-Apps/mobilizon_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/mobilizon_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing). 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. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug
or or
sudo yunohost app upgrade mobilizon -u https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug 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 **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Mobilizon pour YunoHost # 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) [![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)* *[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. > *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.* 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 **Démo :** https://demo.mobilizon.org
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/screenshot1.jpg) ![Capture d'écran de Mobilizon](./doc/screenshots/screenshot1.jpg)
## Avertissements / informations importantes ## Avertissements / informations importantes
@ -38,21 +42,22 @@ A decentralized and federated platform to organize events
## Documentations et ressources ## Documentations et ressources
* Site officiel de l'app : https://joinmobilizon.org/ * Site officiel de l'app : <https://joinmobilizon.org/>
* Documentation officielle utilisateur : https://docs.joinmobilizon.org * Documentation officielle utilisateur : <https://docs.joinmobilizon.org>
* Dépôt de code officiel de l'app : https://framagit.org/framasoft/mobilizon/ * Dépôt de code officiel de l'app : <https://framagit.org/framasoft/mobilizon/>
* Documentation YunoHost pour cette app : https://yunohost.org/app_mobilizon * Documentation YunoHost pour cette app : <https://yunohost.org/app_mobilizon>
* Signaler un bug : https://github.com/YunoHost-Apps/mobilizon_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/mobilizon_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing). 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. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade mobilizon -u https://github.com/YunoHost-Apps/mobilizon_ynh/tree/testing --debug 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 **Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,9 +1,9 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
admin="john"
language="fr"
is_public=1 is_public=1
language="fr"
admin="john"
password="password" password="password"
name="My_Mobilizon" name="My_Mobilizon"
; Checks ; Checks
@ -17,13 +17,15 @@
# 1.1.3~ynh1 # 1.1.3~ynh1
# upgrade=1 from_commit=87d34001dd0b77aed4fa7be2911bc04f58b069ee # upgrade=1 from_commit=87d34001dd0b77aed4fa7be2911bc04f58b069ee
# 1.1.4~ynh1 # 1.1.4~ynh1
upgrade=1 from_commit=215b20b0d35178a2c3405a7e3239eba81e22c060 # upgrade=1 from_commit=215b20b0d35178a2c3405a7e3239eba81e22c060
# 1.2.2~ynh1 # 1.2.2~ynh1
upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc # upgrade=1 from_commit=b63c7833f80de56bbc4a255ddda3b865a5637afc
# 1.2.3~ynh1 # 1.2.3~ynh1
upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea # upgrade=1 from_commit=42d479d2cc5bcdc40806ac01802d8eac9df5b2ea
# 1.3.2~ynh1 # 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 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0
@ -31,14 +33,3 @@
;;; Options ;;; Options
Email=yalh@yahoo.com Email=yalh@yahoo.com
Notification=all 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

View file

@ -6,7 +6,7 @@
"en": "A decentralized and federated platform to organize events", "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" "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/", "url": "https://joinmobilizon.org/",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -27,15 +27,11 @@
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
@ -50,6 +46,10 @@
}, },
"choices": ["fr", "en"], "choices": ["fr", "en"],
"default": "fr" "default": "fr"
},
{
"name": "admin",
"type": "user"
} }
] ]
} }

View file

@ -42,6 +42,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { 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. # 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" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"

View file

@ -25,9 +25,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
admin_email=$(ynh_user_get_info $admin 'mail') admin_email=$(ynh_user_get_info $admin 'mail')
ynh_user_password=$(ynh_string_random --length=30) ynh_user_password=$(ynh_string_random --length=30)
architecture=$YNH_ARCH 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=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url 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=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=admin_email --value=$admin_email
ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password

View file

@ -19,9 +19,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) 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) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) 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_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) 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" ynh_store_file_checksum --file="$final_path/live/config/runtime.exs"
fi fi
ynh_remove_nodejs
if ynh_version_gt "2.0.2~ynh1" "${previous_version}" ; then if ynh_version_gt "2.0.2~ynh1" "${previous_version}" ; then
mkdir -p /etc/$app mkdir -p /etc/$app
if [ -f "$final_path/live/config/prod.secret.exs" ]; then 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 # CREATE DATADIR FOLDER
#================================================= #=================================================
ynh_script_progression --message="Create datadir folder..." ynh_script_progression --message="Create datadir folder..."
mkdir -p $datadir mkdir -p $datadir