summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml6
-rw-r--r--CONTRIBUTING.md9
-rw-r--r--pyproject.toml3
-rw-r--r--requests_cache/__init__.py20
4 files changed, 34 insertions, 4 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ceb923f..8d3709e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -96,16 +96,16 @@ jobs:
- name: Run cyclomatic complexity check
run: radon cc --show-complexity --average --order SCORE requests_cache
- # Deploy stable builds on tags only
+ # Deploy pre-release builds from dev branch, and stable builds on tags only
release:
needs: [test, analyze]
- if: startsWith(github.ref, 'refs/tags/v')
+ if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/dev'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
- python-version: '3.8'
+ python-version: ${{ env.LATEST_PY_VERSION }}
- name: Install dependencies
run: pip install -U ".[build]"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0f68c92..3b734f9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -145,3 +145,12 @@ Release steps:
- Push a new tag, e.g.: `git tag v0.1 && git push origin --tags`
- This will trigger a deployment. Verify that this completes successfully and that the new version
can be installed from pypi with `pip install`
+
+## Pre-Releases
+Pre-release builds are convenient for letting testers try out in-development changes. Versions with
+the suffix `.dev` (among others) can be deployed to PyPI and installed by users with `pip install --pre`,
+and are otherwise ignored by `pip install`. See python packaging docs on
+[pre-release versioning](https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning)
+for more details.
+
+A pre-release build for requests-cache will automatically be published for **any commits to the dev branch.**
diff --git a/pyproject.toml b/pyproject.toml
index aa18291..c2c5a0e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,6 +11,9 @@ directory = 'test-reports'
[tool.coverage.run]
branch = true
source = ['requests_cache']
+omit = [
+ 'requests_cache/__init__.py',
+]
[tool.isort]
profile = "black"
diff --git a/requests_cache/__init__.py b/requests_cache/__init__.py
index 7758462..cc8cd3d 100644
--- a/requests_cache/__init__.py
+++ b/requests_cache/__init__.py
@@ -1,5 +1,8 @@
# flake8: noqa: E402,F401
-__version__ = '0.6.2'
+from logging import getLogger
+from os import getenv
+
+__version__ = '0.6.3'
try:
from .response import AnyResponse, CachedHTTPResponse, CachedResponse, ExpirationTime
@@ -17,3 +20,18 @@ try:
# Quietly ignore ImportError, if setup.py is invoked outside a virtualenv
except ImportError:
pass
+
+
+def get_prerelease_version(version: str) -> str:
+ """If we're running in a GitHub Action job on the dev branch, get a prerelease semantic version
+ using the current build number. For example: ``1.0.0 -> 1.0.0-dev.123``
+ """
+ if getenv('GITHUB_REF') == 'refs/heads/dev':
+ build_number = getenv('GITHUB_RUN_NUMBER', '0')
+ version = f'{version}.dev{build_number}'
+ getLogger(__name__).info(f'Using pre-release version: {version}')
+ return version
+
+
+# This won't modify the version outside of a GitHub Action
+__version__ = get_prerelease_version(__version__)