Skip to content

Commit 43082ee

Browse files
committed
Merge branch 'release-v5.2.5'
2 parents 57be270 + 5e591b7 commit 43082ee

File tree

13 files changed

+2880
-119
lines changed

13 files changed

+2880
-119
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
netfoundry/_version.py export-subst

.github/workflows/docker-image.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Publish Python Package and Docker Image
10+
11+
on:
12+
push:
13+
branches:
14+
- release-v*
15+
release:
16+
types: [published]
17+
18+
jobs:
19+
upload_pypi:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0 # unshallow checkout enables setuptools_scm to infer PyPi version from Git
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: '3.6'
30+
31+
- name: Install dependencies
32+
run: |
33+
python3 -m pip install --upgrade pip
34+
pip3 install build
35+
36+
- name: Build Package
37+
run: python3 -m build
38+
39+
- name: Publish Test Package
40+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
41+
with:
42+
user: __token__
43+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
44+
repository_url: https://test.pypi.org/legacy/
45+
46+
- name: Temporarily Store the Python Package in GitHub # for convenient reference, troubleshooting, investigation, etc...
47+
uses: actions/upload-artifact@v2
48+
with:
49+
name: netfoundry-pypi-${{ github.run_id }}
50+
path: dist/netfoundry-*.tar.gz
51+
52+
- name: Read version string
53+
id: read_version
54+
run: |
55+
PYPI_VERSION=$(python setup.py --version)
56+
[[ ${PYPI_VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+.* ]] || {
57+
echo "ERROR: unexpected version string '${PYPI_VERSION}'" >&2
58+
exit 1
59+
}
60+
echo ::set-output name=pypi_version::${PYPI_VERSION}
61+
62+
- name: Append 'latest' tag if release published
63+
env:
64+
GITHUB_ACTION: ${{ github.event.action }}
65+
PYPI_VERSION: ${{ steps.read_version.outputs.pypi_version }}
66+
id: compose_tags
67+
run: |
68+
CONTAINER_TAGS="netfoundry/python:${PYPI_VERSION}"
69+
if [[ ${GITHUB_ACTION} == "published" ]]; then
70+
CONTAINER_TAGS+=",netfoundry/python:latest"
71+
fi
72+
echo ::set-output name=container_tags::${CONTAINER_TAGS}
73+
74+
- name: Publish Release Package
75+
if: github.event.action == 'published'
76+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
77+
with:
78+
user: __token__
79+
password: ${{ secrets.PYPI_API_TOKEN }}
80+
81+
- name: Set up QEMU
82+
uses: docker/setup-qemu-action@master
83+
with:
84+
platforms: amd64,arm,arm64
85+
86+
- name: Set up Docker BuildKit
87+
id: buildx
88+
uses: docker/setup-buildx-action@master
89+
90+
- name: Login to Docker Hub
91+
uses: docker/login-action@v1
92+
with:
93+
username: ${{ secrets.DOCKER_HUB_API_USER }}
94+
password: ${{ secrets.DOCKER_HUB_API_TOKEN }}
95+
96+
- name: Build & Push Multi-Platform Container Image to Hub
97+
uses: docker/build-push-action@v2
98+
with:
99+
context: . # build context is workspace so we can copy artifacts from ./dist/
100+
builder: ${{ steps.buildx.outputs.name }}
101+
platforms: linux/amd64,linux/arm/v7,linux/arm64
102+
push: true
103+
tags: ${{ steps.compose_tags.outputs.container_tags }}

.github/workflows/python-publish.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ FROM python:3.9-slim-buster
22
COPY ./dist/netfoundry-*.tar.gz /tmp/
33
RUN pip install --upgrade pip
44
RUN pip install /tmp/netfoundry-*.tar.gz
5-
CMD ["bash"]
5+
RUN rm -f /tmp/netfoundry-*.tar.gz
6+
CMD ["python3 -m netfoundry.version"]

MANIFEST.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
exclude Dockerfile
22
exclude .gitignore
3-
exclude .github/workflows/*
3+
exclude .github/workflows/*include versioneer.py
4+
include netfoundry/_version.py
5+
include versioneer.py

netfoundry/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
from .network import Network
55
from .network_group import NetworkGroup
66
from .organization import Organization
7+
8+
from . import _version
9+
__version__ = _version.get_versions()['version']

0 commit comments

Comments
 (0)