Skip to content

Commit

Permalink
PyPi (#278)
Browse files Browse the repository at this point in the history
- bring back PyPi workflow it got dropped somehow.
  • Loading branch information
carlkidcrypto authored Jan 11, 2025
1 parent 01afd4a commit 6c21ca8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 155 deletions.
118 changes: 89 additions & 29 deletions .github/workflows/build_and_publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,109 @@
# Refer to the following link for help
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: "Pull Request Sphinx Docs Check"

name: PyPI Distributions
concurrency: build_and_publish_to_pypi
on:
release:
types: [published]

jobs:
sphinx_docs_build:
runs-on: ubuntu-latest
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14, macos-15]

steps:
- name: Check out repository code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Python 3.11 env for sphinx...
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Build Requirements
- name: Install cibuildwheel
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build wheels using cibuildwheel
uses: carlkidcrypto/[email protected]
with:
linux: |
sudo apt install -y libsnmp-dev g++ python3-dev;
cd /home/runner/work/ezsnmp/ezsnmp/ &&
python -m pip install . --user;
linux: python -m cibuildwheel --output-dir wheelhouse --platform linux;

macos: |
MACOS_VERSION=$(sw_vers -productVersion)
if [[ "$MACOS_VERSION" == "10.15."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\110.15"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "11."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\111.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "12."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\112.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "13."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\113.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "14."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\114.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "15."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\115.0"/' pyproject.toml
else
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\110.15"/' pyproject.toml
fi
python -m cibuildwheel --output-dir wheelhouse --platform macos;
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl

- name: Run sphinx...
build-n-publish-pypi:
name: Build and Publish To PyPi
runs-on: ubuntu-latest
needs: build_wheels

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Set up dependencies
uses: carlkidcrypto/[email protected]
with:
linux: |
cd /home/runner/work/ezsnmp/ezsnmp/sphinx_docs_build;
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
mkdir source/_static;
mkdir source/_templates;
make clean && make html SPHINXOPTS="-W"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux: sudo apt-get update;
sudo apt-get install -y libsnmp-dev libperl-dev;

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a source tarball
run: >-
python -m
build
--sdist
--outdir dist/
.
- name: Download Wheels
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
merge-multiple: true
path: dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.6
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./sphinx_docs_build/build/html/
asset_name: documentation.zip
asset_content_type: application/zip
print_hash: true
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sphinx_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./sphinx_docs_build/build/html/
asset_path: ../../docs/
asset_name: sphinx_documentation.zip
asset_content_type: application/zip
123 changes: 0 additions & 123 deletions docs/htmll/_static/_sphinx_javascript_frameworks_compat.js

This file was deleted.

2 changes: 0 additions & 2 deletions docs/htmll/_static/jquery.js

This file was deleted.

0 comments on commit 6c21ca8

Please sign in to comment.