From e807e5ad937cab97d284f693af6f250d311ef14b Mon Sep 17 00:00:00 2001 From: pchang388 Date: Fri, 14 Feb 2025 05:19:57 -0500 Subject: [PATCH 1/5] update full example and build commands --- Makefile | 6 +++++- README.md | 1 + setup.cfg | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0ea5a7a..7fd717b 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ pip_build: pip_local_dev: python -m pip install -e . -build: +pip_build: python -m pip install --upgrade build python -m build @@ -30,6 +30,10 @@ upload_testpypi: download_testpypi: python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple bookstack-file-exporter +upload_realpypi: + python -m pip install --upgrade twine + python -m twine upload dist/* + docker_build_simple: docker build \ --build-arg BASE_IMAGE=${BASE_IMAGE} \ diff --git a/README.md b/README.md index 710424a..f33b6b8 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,7 @@ assets: export_meta: false verify_ssl: true keep_last: 5 +run_interval: 0 ``` #### Options and Descriptions diff --git a/setup.cfg b/setup.cfg index 4c25490..296aa29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = bookstack-file-exporter # version will be replaced by IMAGE_TAG via Github Actions -version = 0.0.1 +version = 1.4.0 author = pchang388 # author_email = your@email.address url = https://github.com/homeylab/bookstack-file-exporter From 5831ec73b4ddc6254bbf009a3cbfd3f05f7a7a84 Mon Sep 17 00:00:00 2001 From: pchang388 Date: Fri, 14 Feb 2025 05:22:54 -0500 Subject: [PATCH 2/5] update full example and build commands --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 296aa29..4c25490 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = bookstack-file-exporter # version will be replaced by IMAGE_TAG via Github Actions -version = 1.4.0 +version = 0.0.1 author = pchang388 # author_email = your@email.address url = https://github.com/homeylab/bookstack-file-exporter From bd5ffff6084e01c24966229826c6484e84e429f8 Mon Sep 17 00:00:00 2001 From: pchang388 Date: Fri, 14 Feb 2025 05:33:49 -0500 Subject: [PATCH 3/5] update description on application mode --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f33b6b8..b8fc1b3 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ What it does: - Can be run via [Python](#run-via-pip) or [Docker](#run-via-docker) - Can push archives to remote object storage like [Minio](https://min.io/) - Basic housekeeping option (`keep_last`) to keep a tidy archive destination +- Can run in application mode (always running) using `run_interval` property. Used for basic scheduling of backups. Supported backup targets are: @@ -262,7 +263,7 @@ More descriptions can be found for each section below: | `assets.export_meta` | `bool` | `false` | Optional (default: `false`), export of metadata about the page in a json file | | `assets.verify_ssl` | `bool` | `false` | Optional (default: `true`), whether or not to check ssl certificates when requesting content from Bookstack host | | `keep_last` | `int` | `false` | Optional (default: `None`), if exporter can delete older archives. valid values are:
- set to `-1` if you want to delete all archives after each run (useful if you only want to upload to object storage)
- set to `1+` if you want to retain a certain number of archives
- `0` will result in no action done | -| `run_interval` | `int` | `false` | Optional (default: `0`). If specified, exporter will run in a loop and pause for `{run_interval}` seconds before subsequent runs. Example: `86400` seconds = `24` hours or run once a day. Setting this property to `0` will disable looping | +| `run_interval` | `int` | `false` | Optional (default: `0`). If specified, exporter will run as an application and pause for `{run_interval}` seconds before subsequent runs. Example: `86400` seconds = `24` hours or run once a day. Setting this property to `0` will invoke a single run and exit. Used for basic scheduling of backups. | | `minio` | `object` | `false` | Optional [Minio](#minio-backups) configuration options. | #### Valid Environment Variables From 5a65036910f2a6154ab3dbfbefbc040131a4e608 Mon Sep 17 00:00:00 2001 From: pchang388 Date: Fri, 21 Feb 2025 01:38:47 -0500 Subject: [PATCH 4/5] avoid nested github action due to lack of support from pypi action --- .github/workflows/on_release.yml | 40 +++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on_release.yml b/.github/workflows/on_release.yml index aa9aa72..3cbe760 100644 --- a/.github/workflows/on_release.yml +++ b/.github/workflows/on_release.yml @@ -54,9 +54,37 @@ jobs: timeout-minutes: 20 environment: 'PyPi' steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Deploy release to PyPi - uses: ./.github/actions/python - with: - pypi_api_token: "${{ secrets.PYPI_API_TOKEN }}" \ No newline at end of file + - name: Get tag release without v + shell: bash + run: | + TAG=${{ github.ref_name }} + echo "VERSION=${TAG#v}" >> "$GITHUB_ENV" + echo "Tag without v is: ${VERSION}" + - name: Update Release Tag + shell: bash + run: sed -i "s/^version = [^ ]*/version = ${{ env.VERSION }}/" setup.cfg + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.13.2' + - name: Install Dependencies + shell: bash + run: | + python -m pip install --upgrade pip + pip install build + - name: Build Python Package + shell: bash + run: | + python -m pip install --upgrade build + python -m build + - name: Publish to PyPi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + skip-existing: true + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Deploy release to PyPi + # uses: ./.github/actions/python + # with: + # pypi_api_token: "${{ secrets.PYPI_API_TOKEN }}" \ No newline at end of file From c34da95561b565c12feb17a11990e5ba488d8530 Mon Sep 17 00:00:00 2001 From: pchang388 Date: Fri, 21 Feb 2025 03:47:53 -0500 Subject: [PATCH 5/5] fix retry status force list --- bookstack_file_exporter/common/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bookstack_file_exporter/common/util.py b/bookstack_file_exporter/common/util.py index 4591e9d..f2ff5f4 100644 --- a/bookstack_file_exporter/common/util.py +++ b/bookstack_file_exporter/common/util.py @@ -16,11 +16,11 @@ def http_get_request(url: str, headers: Dict[str, str], # {backoff factor} * (2 ** ({number of previous retries})) # {raise_on_status} if status falls in status_forcelist range # and retries have been exhausted. - # {status_force_list} 429 is supposed to be included - retries = Retry(total=3, + # {status_force_list} 413, 429, 503 defaults are overwritten with additional ones + retries = Retry(total=5, backoff_factor=0.5, raise_on_status=True, - status_forcelist=[ 500, 502, 503, 504 ]) + status_forcelist=[413, 429, 500, 502, 503, 504]) session.mount(url_prefix, HTTPAdapter(max_retries=retries)) response = session.get(url, headers=headers, verify=verify_ssl, timeout=timeout) except Exception as req_err: