diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index fad26c3..8e449f7 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -14,14 +14,24 @@ #================================================= # 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 '.[] | 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 "'")) +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') + +# CORE +# repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +repo="TryGhost/Ghost" +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'").zipball_url ] | join(" ") | @sh' | tr -d "'")) + +# ADMIN admin_repo="TryGhost/Admin" -assets+=("https://github.com/TryGhost/Admin/archive/refs/tags/${version}.zip") +assets+=("https://github.com/$admin_repo/archive/refs/tags/${version}.zip") + +# THEME +theme_repo="TryGhost/Casper" +theme_version=$(curl --silent "https://api.github.com/repos/$theme_repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets+=("https://github.com/$theme_repo/archive/refs/tags/${theme_version}.zip") # 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. @@ -67,12 +77,15 @@ echo "Handling asset at $asset_url" # 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 - *"Ghost-"*".zip") + *"/Ghost/"*) src="app" ;; *"/Admin/"*) src="admin" ;; + *"/Casper/"*) + src="casper" + ;; *) src="" ;; @@ -92,20 +105,13 @@ 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=false +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=true EOT echo "... conf/$src.src updated" @@ -117,8 +123,8 @@ fi done -if [ $count == 0 ]; then - echo "::warning ::None of the assets were processed." +if [ $count -lt 2 ]; then + echo "::warning ::Some assets were not processed." exit 0 fi @@ -141,4 +147,3 @@ echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > # The Action will proceed only if the PROCEED environment variable is set to true echo "PROCEED=true" >> $GITHUB_ENV exit 0 - diff --git a/README.md b/README.md index 37cb059..829c056 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Publishing, memberships, subscriptions and newsletters platform -**Shipped version:** 5.2.2~ynh1 +**Shipped version:** 5.8.3~ynh1 + ## Screenshots diff --git a/README_fr.md b/README_fr.md index 0ce2198..66d2e59 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Plateforme d'édition, d'adhésions, d'abonnements et de newsletters -**Version incluse :** 5.2.2~ynh1 +**Version incluse :** 5.8.3~ynh1 + ## Captures d'écran diff --git a/conf/admin.src b/conf/admin.src deleted file mode 100644 index e34aa75..0000000 --- a/conf/admin.src +++ /dev/null @@ -1,5 +0,0 @@ -SOURCE_URL=https://github.com/TryGhost/Admin/archive/refs/tags/v5.2.2.zip -SOURCE_SUM=20f1aea329107ad1ef9c128b6727a73316a2ff3dfdf5f143735506d6a988d249 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=false diff --git a/conf/app.src b/conf/app.src index 9164fd2..3553922 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/TryGhost/Ghost/releases/download/v4.40.0/Ghost-4.40.0.zip -SOURCE_SUM=c0ad20deb45984e70211f50e31271c9a204cc7eba3f9488a115d3f6bcc0fe3d7 +SOURCE_URL=https://api.github.com/repos/TryGhost/Ghost/zipball/v5.8.3 +SOURCE_SUM=557c39864483fff00beeb60e27d84915e184845c69db3be83dcd7a65f327d497 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=false +SOURCE_IN_SUBDIR=true diff --git a/conf/casper.src b/conf/casper.src new file mode 100644 index 0000000..d635bb2 --- /dev/null +++ b/conf/casper.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://github.com/TryGhost/Casper/archive/refs/tags/v5.2.3.zip +SOURCE_SUM=49d57ce078a2775f39d019ed74fa4ae9476e95fa35b02593c726c0ea25fe49df +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=true diff --git a/conf/systemd.service b/conf/systemd.service index 38c6c70..a0e74da 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,7 +9,8 @@ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="__YNH_NODE_LOAD_PATH__" Environment="NODE_ENV=production" -ExecStart=__YNH_NODE__ index.js run +#ExecStart=__YNH_NODE__ core/index.js run +ExecStart=yarn start Restart=always # Sandboxing options to harden security diff --git a/manifest.json b/manifest.json index ec6a20e..7af56e1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,13 +6,14 @@ "en": "Publishing, memberships, subscriptions and newsletters platform", "fr": "Plateforme d'édition, d'adhésions, d'abonnements et de newsletters" }, - "version": "5.2.2~ynh1", + "version": "5.8.3~ynh1", "url": "https://ghost.org/", "upstream": { "license": "MIT", "website": "https://ghost.org/", "admindoc": "https://ghost.org/help/", - "code": "https://github.com/TryGhost/Ghost" + "code": "https://github.com/TryGhost/Ghost", + "cpe": "cpe:2.3:a:ghost:ghost" }, "license": "MIT", "maintainer": { @@ -50,4 +51,4 @@ } ] } -} +} \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index 6173e14..d7bfda0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -124,9 +124,9 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json" -chmod 400 "$final_path/config.production.json" -chown $app:$app "$final_path/config.production.json" +ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json" +chmod 400 "$final_path/ghost/core/config.production.json" +chown $app:$app "$final_path/ghost/core/config.production.json" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 0f7fd56..388008d 100644 --- a/scripts/install +++ b/scripts/install @@ -99,9 +99,9 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -# Download, check integrity, uncompress and patch the source from admin.src -mkdir -p $final_path/core/client/Admin -ynh_setup_source --dest_dir="$final_path/core/client/Admin" --source_id="admin" +# Download, check integrity, uncompress and patch the source from casper.src +mkdir -p $final_path/ghost/core/content/themes/casper +ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -122,9 +122,13 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json" -chmod 400 "$final_path/config.production.json" -chown $app:$app "$final_path/config.production.json" +ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json" +chmod 400 "$final_path/ghost/core/config.production.json" +chown $app:$app "$final_path/ghost/core/config.production.json" + +touch "$final_path/.yarnrc.yml" +chmod 400 "$final_path/.yarnrc.yml" +chown $app:$app "$final_path/.yarnrc.yml" #============================================== # BUILD GHOST @@ -133,10 +137,10 @@ ynh_script_progression --message="Building Ghost... (this will take some time an pushd "$final_path" ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --non-interactive - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/knex-migrator init - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt symlink - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt init --force + # Longer network timeouts for slow systems; see https://github.com/yarnpkg/yarn/issues/8242 + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn config set network-timeout 600000 + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn add knex-migrator ember-cli --dev --ignore-workspace-root-check --non-interactive + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn setup # catch-all command provided by Ghost that handles all the setup popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 304bc31..d3a2b7c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -92,10 +92,24 @@ then tmpdir="$(mktemp -d)" # Copy the admin saved settings from final path to tmp directory - cp -ar "$final_path/config.production.json" "$tmpdir/config.production.json" + if [ -f "$final_path/config.production.json" ] + then + # Old versions of Ghost store it here + cp -ar "$final_path/config.production.json" "$tmpdir/config.production.json" + else + # New versions of Ghost store it here + cp -ar "$final_path/ghost/core/config.production.json" "$tmpdir/config.production.json" + fi # Backup the content folder to the temp dir - cp -ar "$final_path/content" "$tmpdir/content" + if [ -f "$final_path/config.production.json" ] + then + # Old versions of Ghost store it here + cp -ar "$final_path/content" "$tmpdir/content" + else + # New versions of Ghost store it here + cp -ar "$final_path/ghost/core/content" "$tmpdir/content" + fi # Remove the app directory securely ynh_secure_remove --file=$final_path @@ -103,15 +117,15 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path - # Download, check integrity, uncompress and patch the source from admin.src - mkdir -p $final_path/core/client/Admin - ynh_setup_source --dest_dir="$final_path/core/client/Admin" --source_id="admin" + # Download, check integrity, uncompress and patch the source from casper.src + mkdir -p $final_path/content/themes/casper + ynh_setup_source --dest_dir="$final_path/ghost/core/content/themes/casper" --source_id="casper" # Copy the admin saved settings from tmp directory to final path - cp -ar "$tmpdir/config.production.json" "$final_path/config.production.json" + cp -ar "$tmpdir/config.production.json" "$final_path/ghost/core/config.production.json" # Copy content folder back to the final_path - cp -ar "$tmpdir/content" "${final_path}" + cp -ar "$tmpdir/content" "${final_path}/ghost/core" # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" @@ -149,9 +163,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_add_config --template="../conf/config.production.json" --destination="$final_path/config.production.json" -chmod 400 "$final_path/config.production.json" -chown $app:$app "$final_path/config.production.json" +ynh_add_config --template="../conf/config.production.json" --destination="$final_path/ghost/core/config.production.json" +chmod 400 "$final_path/ghost/core/config.production.json" +chown $app:$app "$final_path/ghost/core/config.production.json" + +touch "$final_path/.yarnrc.yml" +chmod 400 "$final_path/.yarnrc.yml" +chown $app:$app "$final_path/.yarnrc.yml" #============================================== # BUILD GHOST @@ -162,10 +180,11 @@ then ynh_script_progression --message="Building Ghost... (this will take some time and resources!)" pushd "$final_path" - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --non-interactive - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/knex-migrator init - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt symlink - ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $final_path/node_modules/.bin/grunt init --force + # Longer network timeouts for slow systems; see https://github.com/yarnpkg/yarn/issues/8242 + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn config set network-timeout 600000 + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn install --non-interactive + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn add knex-migrator ember-cli --dev --ignore-workspace-root-check --non-interactive + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH HOME="$final_path" yarn setup popd fi