1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/searxng_ynh.git synced 2024-09-03 20:26:00 +02:00

Move to ynh autoupdater
Some checks are pending
YunoHost apps package linter / test (push) Waiting to run
Create master promotion pull request / masterPromotion (push) Waiting to run

This commit is contained in:
Sylvain 2024-06-10 21:23:51 +02:00
parent ca0cf5b7a0
commit 2b35ec96fe
7 changed files with 22 additions and 145 deletions

View file

@ -1,64 +0,0 @@
#!/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.toml | tomlq -j '.version|split("~")[0]')
repo=$(cat manifest.toml | tomlq -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_raw=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r ".commit.committer.date")
version=$(date -d "$version_raw" +%Y.%m.%d.%H.%M.%S)
commit_hash=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r ".sha")
# 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
#=================================================
# UPDATE SOURCE FILES
#=================================================
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Replace new version in _common.sh
sed -i "s/^commit_sha=.*/commit_sha=\"$commit_hash\"/" scripts/_common.sh
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
sed -i "s/^version = .*/version = \"$version~ynh1\"/" manifest.toml
# 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

View file

@ -1,57 +0,0 @@
# 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@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install yq/tomlq
id: install_yq
run: pip install yq
- 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 to testing
id: cpr-testing
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
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](https://github.com/${{ env.REPO }}/releases/tag/v${{ env.VERSION }})
draft: false

View file

@ -1,19 +1,19 @@
location __PATH__/ { location __PATH__/ {
uwsgi_pass unix:///var/run/__APP__/app.socket; uwsgi_pass unix:///var/run/__APP__/app.socket;
include uwsgi_params; include uwsgi_params;
uwsgi_param HTTP_HOST $host; uwsgi_param HTTP_HOST $host;
uwsgi_param HTTP_CONNECTION $http_connection; uwsgi_param HTTP_CONNECTION $http_connection;
# see flaskfix.py # see flaskfix.py
uwsgi_param HTTP_X_SCHEME $scheme; uwsgi_param HTTP_X_SCHEME $scheme;
uwsgi_param HTTP_X_SCRIPT_NAME /searxng; uwsgi_param HTTP_X_SCRIPT_NAME /searxng;
# see limiter.py # see limiter.py
uwsgi_param HTTP_X_REAL_IP $remote_addr; uwsgi_param HTTP_X_REAL_IP $remote_addr;
uwsgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for; uwsgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -7,7 +7,7 @@ description.fr = "Un méta-moteur de recherche qui rassemble les résultats de p
version = "2024.05.17.07.51.17~ynh1" version = "2024.05.17.07.51.17~ynh1"
maintainers = ["mh4ckt3mh4ckt1c4s"] maintainers = ["mh4ckt3mh4ckt1c4s", "ewilly"]
[upstream] [upstream]
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"
@ -40,6 +40,13 @@ ram.runtime = "200M"
default = "visitors" default = "visitors"
[resources] [resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/searxng/searxng/archive/f5eb56b63f250c7804e5e1cf4426e550bc933906.tar.gz"
sha256 = "5424c916ba6312fb22d14b7eac268e40995bda073e480b3e6c8e9d63dcd5e087"
autoupdate.strategy = "latest_github_commit"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
repo_fullpath="https://github.com/searxng/searxng"
commit_sha="ec41b535876c7906871ea25638837db3dbc5e4ab"
#================================================= #=================================================
# UWSGI HELPERS # UWSGI HELPERS
#================================================= #=================================================

View file

@ -16,10 +16,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" ynh_setup_source --dest_dir="$install_dir/searxng-src"
pushd "$install_dir/searxng-src"
ynh_exec_fully_quiet git checkout "$commit_sha"
popd
ynh_script_progression --message="Installing SearXNG..." --weight=2 ynh_script_progression --message="Installing SearXNG..." --weight=2

View file

@ -49,10 +49,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_secure_remove --file="$install_dir/searxng-src" ynh_secure_remove --file="$install_dir/searxng-src"
ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" ynh_setup_source --dest_dir="$install_dir/searxng-src"
pushd "$install_dir/searxng-src"
ynh_exec_fully_quiet git checkout "$commit_sha"
popd
ynh_secure_remove --file="$install_dir/searxng-pyenv" ynh_secure_remove --file="$install_dir/searxng-pyenv"
python3 -m venv --system-site-packages "$install_dir/searxng-pyenv" python3 -m venv --system-site-packages "$install_dir/searxng-pyenv"