mirror of
https://github.com/YunoHost-Apps/prometheus_ynh.git
synced 2024-09-03 20:16:01 +02:00
Merge pull request #6 from YunoHost-Apps/testing
Upgrade to v2.33.1 and add auto-updater
This commit is contained in:
commit
0266abd9c4
16 changed files with 225 additions and 36 deletions
145
.github/workflows/updater.sh
vendored
Normal file
145
.github/workflows/updater.sh
vendored
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
#!/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 "'"))
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# Leave $src empty to ignore the asset
|
||||||
|
case $asset_url in
|
||||||
|
*"linux-386"*)
|
||||||
|
src="app.386"
|
||||||
|
;;
|
||||||
|
*"linux-amd64"*)
|
||||||
|
src="app.amd64"
|
||||||
|
;;
|
||||||
|
*"linux-arm64"*)
|
||||||
|
src="app.arm64"
|
||||||
|
;;
|
||||||
|
*"linux-armv5"*)
|
||||||
|
src="app.armv5"
|
||||||
|
;;
|
||||||
|
*"linux-armv6"*)
|
||||||
|
src="app.armv6"
|
||||||
|
;;
|
||||||
|
*"linux-armv7"*)
|
||||||
|
src="app.armv7"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
50
.github/workflows/updater.yml
vendored
Normal file
50
.github/workflows/updater.yml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# 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 7:00 UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '0 7 * * *'
|
||||||
|
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 }}
|
||||||
|
draft: false
|
||||||
|
|
|
@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
|
|
||||||
Monitoring system and time series database
|
Monitoring system and time series database
|
||||||
|
|
||||||
**Shipped version:** 2.28.0~ynh1
|
**Shipped version:** 2.33.1~ynh1
|
||||||
|
|
||||||
**Demo:** https://demo.do.prometheus.io
|
**Demo:** https://demo.do.prometheus.io
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
||||||
|
|
||||||
Supervision chronologique de systèmes et services
|
Supervision chronologique de systèmes et services
|
||||||
|
|
||||||
**Version incluse :** 2.28.0~ynh1
|
**Version incluse :** 2.33.1~ynh1
|
||||||
|
|
||||||
**Démo :** https://demo.do.prometheus.io
|
**Démo :** https://demo.do.prometheus.io
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-386.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-386.tar.gz
|
||||||
SOURCE_SUM=9666d90c981f80d82b605e022eb2af61b65e7d0962a95b6b5fe67cc395cbf915
|
SOURCE_SUM=2a02adc1ba695c4efd0ca9c466d253c4c3008d49c2d65339ce4f0f98e2052ee2
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-amd64.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-amd64.tar.gz
|
||||||
SOURCE_SUM=d2d0ded275090a13208114b633abe41c40e14c83ff5ec07230d79b4da1d8e701
|
SOURCE_SUM=55de29727fc4d3977d3400c54fa222ebb52755bd0201936f1e1052fea6f2b44b
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-arm64.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-arm64.tar.gz
|
||||||
SOURCE_SUM=c6ef6c0ef92bfc9682c9ae5275c5bd5ab2c6f74178201e15f2bfd08cc8a139a8
|
SOURCE_SUM=21d89df7a98882a1a872bd3210aeaac3915a7f7be9f2ad28c986c80ad64ee77d
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-armv5.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-armv5.tar.gz
|
||||||
SOURCE_SUM=5cc36a0254c118639a461e52f7736f4b86e0f2775ab552cb426f0a4748c8cd8b
|
SOURCE_SUM=bc51a6073ac1d90c8ebd548694baeb8c6dff91945cf00b763c65a11412b7f945
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-armv6.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-armv6.tar.gz
|
||||||
SOURCE_SUM=8346908ad57777d1cd7b2a3e95e0b7beb9891251f768caf863895bb051a65209
|
SOURCE_SUM=16769a890ce803f571a5c68689dd9c6401a9d80e491352eaefd5eeff6441e460
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.28.0/prometheus-2.28.0.linux-armv7.tar.gz
|
SOURCE_URL=https://github.com/prometheus/prometheus/releases/download/v2.33.1/prometheus-2.33.1.linux-armv7.tar.gz
|
||||||
SOURCE_SUM=214632282772a45d4ac2c7053f95d252b8eb8c279ff228aba2ac25329ae903f8
|
SOURCE_SUM=09e285f098c36a5f2e7cf065fb38bd8f65ef262aeda728aac48b8cbb40ef34cc
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_EXTRACT=true
|
|
||||||
SOURCE_FILENAME=prometheus.tar.gz
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ location __PATH__ {
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_pass http://127.0.0.1:__PORT____PATH__;
|
proxy_pass http://127.0.0.1:__PORT__;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
|
@ -9,7 +9,8 @@ Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
WorkingDirectory=__FINALPATH__/
|
||||||
ExecStart=__FINALPATH__/prometheus \
|
ExecStart=__FINALPATH__/prometheus \
|
||||||
--config.file=__FINALPATH__/prometheus.yml --web.enable-admin-api \
|
--config.file=__FINALPATH__/prometheus.yml --web.enable-admin-api \
|
||||||
--web.external-url=__PATH__ \
|
--web.external-url=__PATH__/ \
|
||||||
|
--web.route-prefix=__PATH__/ \
|
||||||
--web.listen-address=localhost:__PORT__
|
--web.listen-address=localhost:__PORT__
|
||||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Monitoring system and time series database",
|
"en": "Monitoring system and time series database",
|
||||||
"fr": "Supervision chronologique de systèmes et services"
|
"fr": "Supervision chronologique de systèmes et services"
|
||||||
},
|
},
|
||||||
"version": "2.28.0~ynh1",
|
"version": "2.33.1~ynh1",
|
||||||
"url": "https://prometheus.io",
|
"url": "https://prometheus.io",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install": [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
version="2.28.0"
|
version="2.28.0"
|
||||||
architecture=""
|
architecture=""
|
||||||
case $(uname -m) in
|
case $(uname -m) in
|
||||||
i386) architecture="386" ;;
|
i386) architecture="386" ;;
|
||||||
x86_64) architecture="amd64" ;;
|
x86_64) architecture="amd64" ;;
|
||||||
armv5) architecture="armv5" ;;
|
armv5) architecture="armv5" ;;
|
||||||
armv6) architecture="armv6" ;;
|
armv6) architecture="armv6" ;;
|
||||||
armv7) architecture="armv7" ;;
|
armv7) architecture="armv7" ;;
|
||||||
arm) dpkg --print-architecture | grep -q "arm64" && architecture="arm64" || architecture="unsupported arm" ;;
|
armv7l) architecture="armv7" ;;
|
||||||
|
aarch64) architecture="arm64" ;;
|
||||||
|
*) ynh_die --message="Sorry, your architecture $YNH_ARCH is not supported." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -94,6 +94,8 @@ then
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
# Create a dedicated service config
|
# Create a dedicated service config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
else
|
||||||
|
path_url="$old_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for NGINX
|
# Change the domain for NGINX
|
||||||
|
|
|
@ -113,6 +113,7 @@ ynh_add_systemd_config
|
||||||
ynh_script_progression --message="Configuring the app..." --weight=2
|
ynh_script_progression --message="Configuring the app..." --weight=2
|
||||||
|
|
||||||
ynh_replace_string --match_string="localhost:9090" --replace_string="localhost:$port" --target_file="$final_path/prometheus.yml"
|
ynh_replace_string --match_string="localhost:9090" --replace_string="localhost:$port" --target_file="$final_path/prometheus.yml"
|
||||||
|
echo " metrics_path: $path_url/metrics" >> "$final_path/prometheus.yml"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
Loading…
Reference in a new issue