зеркало из https://github.com/docker/docker-py.git
ci: add workflow for releases (#3018)
GitHub Actions workflow to create a release: will upload to PyPI and create a GitHub release with the `sdist` and `bdist_wheel` as well. The version code is switched to `setuptools_scm` to work well with this flow (e.g. avoid needing to write a script that does a `sed` on the version file and commits as part of release). Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
Родитель
828d06f5f5
Коммит
cd2c35a9b6
|
@ -9,3 +9,6 @@ max_line_length = 80
|
|||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
|
|
@ -2,6 +2,9 @@ name: Python package
|
|||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
DOCKER_BUILDKIT: '1'
|
||||
|
||||
jobs:
|
||||
flake8:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release Tag WITHOUT `v` Prefix (e.g. 6.0.0)"
|
||||
required: true
|
||||
dry-run:
|
||||
description: 'Dry run'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- run: python setup.py sdist bdist_wheel
|
||||
env:
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOCKER: ${{ inputs.tag }}
|
||||
|
||||
- name: Publish to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
if: ! inputs.dry-run
|
||||
with:
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
- name: Create GitHub release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: ! inputs.dry-run
|
||||
with:
|
||||
artifacts: "dist/*"
|
||||
generateReleaseNotes: true
|
||||
draft: true
|
||||
commit: ${{ github.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ inputs.tag }}
|
|
@ -13,6 +13,10 @@ html/*
|
|||
_build/
|
||||
README.rst
|
||||
|
||||
# setuptools_scm
|
||||
_version.py
|
||||
|
||||
env/
|
||||
venv/
|
||||
.idea/
|
||||
*.iml
|
||||
|
|
|
@ -2,7 +2,6 @@ ARG PYTHON_VERSION=3.10
|
|||
|
||||
FROM python:${PYTHON_VERSION}
|
||||
|
||||
RUN mkdir /src
|
||||
WORKDIR /src
|
||||
|
||||
COPY requirements.txt /src/requirements.txt
|
||||
|
@ -11,5 +10,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||
COPY test-requirements.txt /src/test-requirements.txt
|
||||
RUN pip install --no-cache-dir -r test-requirements.txt
|
||||
|
||||
COPY . /src
|
||||
COPY . .
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER
|
||||
RUN pip install --no-cache-dir .
|
||||
|
|
|
@ -4,7 +4,6 @@ from .client import DockerClient, from_env
|
|||
from .context import Context
|
||||
from .context import ContextAPI
|
||||
from .tls import TLSConfig
|
||||
from .version import version, version_info
|
||||
from .version import __version__
|
||||
|
||||
__version__ = version
|
||||
__title__ = 'docker'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import sys
|
||||
from .version import version
|
||||
from .version import __version__
|
||||
|
||||
DEFAULT_DOCKER_API_VERSION = '1.41'
|
||||
MINIMUM_DOCKER_API_VERSION = '1.21'
|
||||
|
@ -28,7 +28,7 @@ INSECURE_REGISTRY_DEPRECATION_WARNING = \
|
|||
IS_WINDOWS_PLATFORM = (sys.platform == 'win32')
|
||||
WINDOWS_LONGPATH_PREFIX = '\\\\?\\'
|
||||
|
||||
DEFAULT_USER_AGENT = f"docker-sdk-python/{version}"
|
||||
DEFAULT_USER_AGENT = f"docker-sdk-python/{__version__}"
|
||||
DEFAULT_NUM_POOLS = 25
|
||||
|
||||
# The OpenSSH server default value for MaxSessions is 10 which means we can
|
||||
|
|
|
@ -1,2 +1,14 @@
|
|||
version = "6.0.0-dev"
|
||||
version_info = tuple(int(d) for d in version.split("-")[0].split("."))
|
||||
try:
|
||||
from ._version import __version__
|
||||
except ImportError:
|
||||
try:
|
||||
# importlib.metadata available in Python 3.8+, the fallback (0.0.0)
|
||||
# is fine because release builds use _version (above) rather than
|
||||
# this code path, so it only impacts developing w/ 3.7
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
try:
|
||||
__version__ = version('docker')
|
||||
except PackageNotFoundError:
|
||||
__version__ = '0.0.0'
|
||||
except ImportError:
|
||||
__version__ = '0.0.0'
|
||||
|
|
11
docs/conf.py
11
docs/conf.py
|
@ -63,12 +63,11 @@ author = 'Docker Inc'
|
|||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
with open('../docker/version.py') as vfile:
|
||||
exec(vfile.read())
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
# The short X.Y version.
|
||||
version = f'{version_info[0]}.{version_info[1]}'
|
||||
# see https://github.com/pypa/setuptools_scm#usage-from-sphinx
|
||||
from importlib.metadata import version
|
||||
release = version('docker')
|
||||
# for example take major/minor
|
||||
version = '.'.join(release.split('.')[:2])
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[build-system]
|
||||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
|
||||
|
||||
[tool.setuptools_scm]
|
||||
write_to = 'docker/_version.py'
|
8
setup.py
8
setup.py
|
@ -29,9 +29,6 @@ extras_require = {
|
|||
'ssh': ['paramiko>=2.4.3'],
|
||||
}
|
||||
|
||||
version = None
|
||||
exec(open('docker/version.py').read())
|
||||
|
||||
with open('./test-requirements.txt') as test_reqs_txt:
|
||||
test_requirements = [line for line in test_reqs_txt]
|
||||
|
||||
|
@ -42,7 +39,9 @@ with codecs.open('./README.md', encoding='utf-8') as readme_md:
|
|||
|
||||
setup(
|
||||
name="docker",
|
||||
version=version,
|
||||
use_scm_version={
|
||||
'write_to': 'docker/_version.py'
|
||||
},
|
||||
description="A Python library for the Docker Engine API.",
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
|
@ -54,6 +53,7 @@ setup(
|
|||
'Tracker': 'https://github.com/docker/docker-py/issues',
|
||||
},
|
||||
packages=find_packages(exclude=["tests.*", "tests"]),
|
||||
setup_requires=['setuptools_scm'],
|
||||
install_requires=requirements,
|
||||
tests_require=test_requirements,
|
||||
extras_require=extras_require,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# syntax = docker/dockerfile:1.4
|
||||
ARG PYTHON_VERSION=3.10
|
||||
|
||||
FROM python:${PYTHON_VERSION}
|
||||
|
||||
ARG APT_MIRROR
|
||||
|
@ -29,11 +29,16 @@ RUN curl -sSL -o /opt/docker-credential-pass.tar.gz \
|
|||
chmod +x /usr/local/bin/docker-credential-pass
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY requirements.txt /src/requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install -r requirements.txt
|
||||
|
||||
COPY test-requirements.txt /src/test-requirements.txt
|
||||
RUN pip install -r test-requirements.txt
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install -r test-requirements.txt
|
||||
|
||||
COPY . /src
|
||||
RUN pip install .
|
||||
ARG SETUPTOOLS_SCM_PRETEND_VERSION=99.0.0-docker
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install -e .
|
||||
|
|
Загрузка…
Ссылка в новой задаче