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 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..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: @@ -240,6 +241,7 @@ assets: export_meta: false verify_ssl: true keep_last: 5 +run_interval: 0 ``` #### Options and Descriptions @@ -261,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 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: