Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Python Release

Python Release #15

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python Release
on:
push:
tags:
# only run the release pipeline on semver tags
- '[0-9]+.[0-9]+.[0-9]+'
env:
TAG_NAME: ${{ github.ref_name }}
LINUX_AMD64_BINARY: "netplanner-linux-amd64-${{ github.ref_name }}"
jobs:
release:
runs-on: ubuntu-20.04 # use an ancient release for glibc compatibility.
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
which strip
python -m pip install --upgrade pip poetry
poetry config virtualenvs.in-project true
poetry --version
poetry install --no-root
- name: Build package
run: |
poetry build
- name: Install Package
run: |
poetry run python -m pip install dist/*.whl
echo "PROJECT_VERSION=$(poetry run python -m netplanner --version)" >> $GITHUB_ENV
echo "::set-output name=version::$(poetry run python -m netplanner --version)"
poetry run python -m pip uninstall --yes dist/*.whl
id: version
- name: Break on version mismatch
if: ${{ env.TAG_NAME != env.PROJECT_VERSION }}
run: |
echo "::error::We found a version mismatch GIT:[${{ env.TAG_NAME }}] != PROJECT:[${{ env.PROJECT_VERSION }}]"
exit 1
- name: Lint with black
run: |
poetry run black -t py310 --check .
- name: Type Lint with mypy
run: |
poetry run mypy .
- name: Build package
run: |
poetry build
- name: Build dynamically linked binary
run: |
poetry run pyoxidizer build --release
mkdir -p bin/
cp build/x86_64-unknown-linux-gnu/release/install/netplanner "bin/${LINUX_AMD64_BINARY}"
chmod 0644 "bin/${LINUX_AMD64_BINARY}"
strip "bin/${LINUX_AMD64_BINARY}"
- name: E2E Tests
run: |
chmod 0755 "bin/${LINUX_AMD64_BINARY}"
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/worker-config-old.yaml --output /run/systemd/networkd/worker-old configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/worker-config-new.yaml --output /run/systemd/networkd/worker-new configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/master-config-old.yaml --output /run/systemd/networkd/master-old configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/master-config-new.yaml --output /run/systemd/networkd/master-new configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/veth-trial.yaml --output /run/systemd/networkd/veth-trial configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/5g-worker --output /run/systemd/networkd/folder/5g-worker configure
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/5g-worker.yaml --output /run/systemd/networkd/5g-worker configure
# enable the netplan apply command
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/vm-config --output /run/systemd/networkd/folder/vm-config apply
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/vm-config.yaml --output /run/systemd/networkd/vm-config apply
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/vm-config-v6.yaml --output /run/systemd/networkd/vm-config-v6 apply
# this should fail
bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/empty --output /run/systemd/networkd/empty configure || true
- name: Unit Tests
run: |
echo "This should later run the unit tests."
- name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./bin/${{ env.LINUX_AMD64_BINARY }}
./dist/*
./build/x86_64-unknown-linux-gnu/release/install/COPYING.txt
- name: Release on PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}