diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..e6951e8 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,144 @@ +#!/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/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 "'")) + +admin_repo="TryGhost/Admin" +assets+=("https://api.github.com/repos/TryGhost/Admin/zipball/$version") + +# 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. + +count=0 + +# 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 + *"Ghost-"*".zip") + src="app" + ;; + *"/Admin/"*) + src="admin" + ;; + *) + 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=false +EOT +echo "... conf/$src.src updated" + +count=$((count+1)) + +else +echo "... asset ignored" +fi + +done + +if [ $count == 0 ]; then + echo "::warning ::None of the assets were processed." + exit 0 +fi + +#================================================= +# 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..fd6ed60 --- /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 + branch: ci-auto-update-v${{ env.VERSION }} + base: testing + 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 43e89c6..e69e926 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Just a blogging platform -**Shipped version:** 4.9.4~ynh1 +**Shipped version:** 4.16.0~ynh1 diff --git a/README_fr.md b/README_fr.md index 78e9c7c..bceeedb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Plateforme de blogging -**Version incluse :** 4.9.4~ynh1 +**Version incluse :** 4.16.0~ynh1 diff --git a/check_process b/check_process index 8f8fa27..70c1485 100644 --- a/check_process +++ b/check_process @@ -13,6 +13,8 @@ upgrade=1 # 4.3.3 upgrade=1 from_commit=198004df76b0b3ef22a6dfe1b9a2738af62f0786 + # 4.9.4 + upgrade=1 from_commit=7a150ab29ee969f72dd7846539ae12ac1975165b backup_restore=1 multi_instance=1 change_url=0 @@ -22,3 +24,5 @@ Notification=none ;;; Upgrade options ; commit=198004df76b0b3ef22a6dfe1b9a2738af62f0786 name=4.3.3 + ; commit=7a150ab29ee969f72dd7846539ae12ac1975165b + name=4.9.4 diff --git a/conf/admin.src b/conf/admin.src index 3bdb91c..d7ba541 100644 --- a/conf/admin.src +++ b/conf/admin.src @@ -1,7 +1,5 @@ -SOURCE_URL=https://github.com/TryGhost/Admin/archive/refs/tags/v4.7.0.zip -SOURCE_SUM=0bd18e13e138b015561609d7b19ddd8623c22c86bf19c6ada3a4267b8c5dbe1c +SOURCE_URL=https://github.com/TryGhost/Admin/archive/refs/tags/v4.16.0.zip +SOURCE_SUM=91b674c26838bd55a57a3cbc0cfbf873e6aa5dec625bc1245405d653f3410c99 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false -SOURCE_FILENAME= - diff --git a/conf/app.src b/conf/app.src index 12fd405..01ef1dc 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/TryGhost/Ghost/releases/download/v4.9.4/Ghost-4.9.4.zip -SOURCE_SUM=90f48a1554430c13e57caece5aaef145dd3c7e6aedf9e72a1e12987a938692bc +SOURCE_URL=https://github.com/TryGhost/Ghost/releases/download/v4.16.0/Ghost-4.16.0.zip +SOURCE_SUM=DE7041DA31362BB8DF1043864A94026D6B692EBCEF8FEBD886F635BEF8E3DA84 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false diff --git a/manifest.json b/manifest.json index 97191c7..131821b 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Just a blogging platform", "fr": "Plateforme de blogging" }, - "version": "4.9.4~ynh1", + "version": "4.16.0~ynh1", "url": "https://ghost.org/", "upstream": { "license": "MIT", @@ -31,12 +31,11 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", - "type": "path", + "type": "path", "example": "/blog", "default": "/blog" }, diff --git a/scripts/install b/scripts/install index c8ee86f..6862964 100644 --- a/scripts/install +++ b/scripts/install @@ -129,12 +129,12 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd "$final_path" || ynh_die ynh_use_nodejs - yarn install --non-interactive --silent - yarn global add knex-migrator - NODE_ENV=production knex-migrator init - yarn global add grunt-cli ember-cli - NODE_ENV=production grunt symlink - NODE_ENV=production grunt init --force + ynh_exec_warn_less yarn install --non-interactive --silent + ynh_exec_warn_less yarn global add knex-migrator + ynh_exec_warn_less NODE_ENV=production knex-migrator init + ynh_exec_warn_less yarn global add grunt-cli ember-cli + ynh_exec_warn_less NODE_ENV=production grunt symlink + ynh_exec_warn_less NODE_ENV=production grunt init --force popd || ynh_die @@ -210,5 +210,5 @@ ynh_send_readme_to_admin "$message" #================================================= # END OF SCRIPT #================================================= - + ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/restore b/scripts/restore index 68709ce..405d5e9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -39,8 +39,6 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= ynh_script_progression --message="Validating restoration parameters..." -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " diff --git a/scripts/upgrade b/scripts/upgrade index cf364d6..a2af1bc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,12 +156,12 @@ then ynh_script_progression --message="Building $app... (this will take some time and resources!)" pushd "$final_path" || ynh_die - yarn install - yarn global add knex-migrator - NODE_ENV=production knex-migrator init - yarn global add grunt - NODE_ENV=production grunt symlink - NODE_ENV=production grunt init --force + ynh_exec_warn_less yarn install + ynh_exec_warn_less yarn global add knex-migrator + ynh_exec_warn_less NODE_ENV=production knex-migrator init + ynh_exec_warn_less yarn global add grunt + ynh_exec_warn_less NODE_ENV=production grunt symlink + ynh_exec_warn_less NODE_ENV=production grunt init --force popd || ynh_die fi