|
| 1 | +name: LibCrypto Test & Deploy - Publish to PYPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + branches: ["main"] |
| 8 | + pull_request: |
| 9 | + branches: ["main"] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install setuptools wheel twine |
| 33 | + pip install -r requirements.txt |
| 34 | + pip install pytest pytest-cov |
| 35 | +
|
| 36 | + - name: Install package in editable mode |
| 37 | + run: | |
| 38 | + pip install -e . |
| 39 | +
|
| 40 | + - name: Verify no external crypto dependencies |
| 41 | + run: | |
| 42 | + python -c "import sys; import libcrypto; assert 'ecdsa' not in sys.modules, 'ecdsa should not be loaded'; assert 'Crypto' not in sys.modules, 'pycryptodome should not be loaded'; print('✅ No external crypto dependencies')" |
| 43 | +
|
| 44 | + - name: Run pytest with coverage |
| 45 | + run: | |
| 46 | + pytest tests/ -v --cov=libcrypto --cov-report=term-missing |
| 47 | +
|
| 48 | + - name: Lint with flake8 |
| 49 | + run: | |
| 50 | + pip install flake8 |
| 51 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 52 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 53 | +
|
| 54 | + publish: |
| 55 | + needs: build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v2 |
| 62 | + |
| 63 | + - name: Set up Python 3.12 |
| 64 | + uses: actions/setup-python@v2 |
| 65 | + with: |
| 66 | + python-version: "3.12" |
| 67 | + |
| 68 | + - name: Install dependencies |
| 69 | + run: | |
| 70 | + python -m pip install --upgrade pip |
| 71 | + pip install -r requirements.txt |
| 72 | + pip install setuptools wheel twine build |
| 73 | +
|
| 74 | + - name: Get Bumper File |
| 75 | + if: ${{ secrets.BUMP_URL != '' }} |
| 76 | + run: curl -o bump_version.py ${{ secrets.BUMP_URL }} |
| 77 | + |
| 78 | + - name: Run Bump script |
| 79 | + if: ${{ secrets.BUMP_URL != '' }} |
| 80 | + run: python bump_version.py libcrypto |
| 81 | + |
| 82 | + - name: Remove Bump Script |
| 83 | + if: ${{ secrets.BUMP_URL != '' }} |
| 84 | + run: rm -r bump_version.py |
| 85 | + |
| 86 | + - name: Bump version |
| 87 | + if: ${{ secrets.BUMP_URL != '' }} |
| 88 | + run: | |
| 89 | + git config --global user.name 'github-actions' |
| 90 | + git config --global user.email 'github-actions@github.com' |
| 91 | + git add setup.py pyproject.toml src/libcrypto/__init__.py |
| 92 | + git add . |
| 93 | + git commit -m 'version Update Mode' |
| 94 | + git push origin main |
| 95 | +
|
| 96 | + - name: Build libcrypto Package |
| 97 | + run: | |
| 98 | + python -m build |
| 99 | +
|
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + |
| 103 | + - name: Publish package to PyPI |
| 104 | + env: |
| 105 | + TWINE_USERNAME: __token__ |
| 106 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 107 | + run: | |
| 108 | + twine upload dist/* |
| 109 | +
|
| 110 | + - name: Create GitHub Release |
| 111 | + id: create_release |
| 112 | + uses: softprops/action-gh-release@v2 |
| 113 | + with: |
| 114 | + tag_name: "v${{ env.NEW_VERSION }}" |
| 115 | + name: "libcrypto v${{ env.NEW_VERSION }}" |
| 116 | + body: | |
| 117 | + ## libcrypto New Release `${{ env.NEW_VERSION }}` |
| 118 | +
|
| 119 | + > [!NOTE] |
| 120 | + > New version of libcrypto has been released `v${{ env.NEW_VERSION }}`, Check the latest features and updates in this release. |
| 121 | +
|
| 122 | + install and use libcrypto with `pip` and `pip3` follow command : |
| 123 | +
|
| 124 | + ### Windows |
| 125 | +
|
| 126 | + ```bash |
| 127 | + pip install libcrypto |
| 128 | + # or |
| 129 | + pip install libcrypto==${{ env.NEW_VERSION }} |
| 130 | + ``` |
| 131 | + ##### upgrade : `pip install libcrypto --upgrade` |
| 132 | +
|
| 133 | + --- |
| 134 | +
|
| 135 | + ### Linux & MacOS |
| 136 | +
|
| 137 | + ```bash |
| 138 | + pip3 install libcrypto |
| 139 | + # or |
| 140 | + pip3 install libcrypto==${{ env.NEW_VERSION }} |
| 141 | + ``` |
| 142 | +
|
| 143 | + ##### upgrade : `pip3 install libcrypto --upgrade` |
| 144 | +
|
| 145 | + --- |
| 146 | +
|
| 147 | + - [Documentation](https://libcrypto.readthedocs.io/) |
| 148 | + - [PyPi Package](https://pypi.org/project/libcrypto/${{ env.NEW_VERSION }}/) |
| 149 | + - [PyPi History](https://pypi.org/project/libcrypto/${{ env.NEW_VERSION }}/#history) |
| 150 | + - [Description Package](https://pypi.org/project/libcrypto/${{ env.NEW_VERSION }}/#description) |
| 151 | + - [Download Files](https://pypi.org/project/libcrypto/${{ env.NEW_VERSION }}/#files) |
| 152 | +
|
| 153 | + Programmer and Owner : @Pymmdrza |
| 154 | +
|
| 155 | + files: | |
| 156 | + dist/libcrypto-${{ env.NEW_VERSION }}.tar.gz |
| 157 | + dist/libcrypto-${{ env.NEW_VERSION }}-py3-none-any.whl |
0 commit comments