1- name : FastCrypt Package CI/CD
1+ name : fastCrypt Package
22
33on :
44 push :
5- branches : [ "main", "develop" ]
5+ branches : [ "main" ]
66 pull_request :
77 branches : [ "main" ]
8- release :
9- types : [published]
108 workflow_dispatch :
119
1210jobs :
13- test :
14- name : Test on Python ${{ matrix.python-version }}
15- runs-on : ${{ matrix.os }}
11+ build :
12+ runs-on : ubuntu-latest
1613 strategy :
1714 fail-fast : false
1815 matrix :
19- os : [ubuntu-latest, windows-latest]
16+ os : [ubuntu-latest, windows-latest, macos-latest ]
2017 python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
2118
2219 steps :
2320 - name : Checkout repository
24- uses : actions/checkout@v4
21+ uses : actions/checkout@v2
2522
2623 - name : Set up Python ${{ matrix.python-version }}
27- uses : actions/setup-python@v4
24+ uses : actions/setup-python@v2
2825 with :
2926 python-version : ${{ matrix.python-version }}
3027
31- - name : Cache pip dependencies
32- uses : actions/cache@v3
33- with :
34- path : ~/.cache/pip
35- key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
36- restore-keys : |
37- ${{ runner.os }}-pip-
38-
39- - name : Install system dependencies (Ubuntu)
40- if : matrix.os == 'ubuntu-latest'
41- run : |
42- sudo apt-get update
43- sudo apt-get install -y build-essential gcc g++ make libssl-dev python3-dev python3-pip libffi-dev
44-
45- - name : Install system dependencies (Windows)
46- if : matrix.os == 'windows-latest'
47- run : |
48- choco install openssl
49-
50- - name : Install Python dependencies
28+ - name : Install dependencies
5129 run : |
5230 python -m pip install --upgrade pip
53- pip install setuptools wheel twine pyOpenSSL cryptography
54- pip install -r requirements.txt
55- pip install pytest pytest-cov flake8 black mypy
56-
57- - name : Install package in development mode
58- run : |
59- pip install -e .
60-
31+ pip install setuptools wheel twine
32+
6133 - name : Lint with flake8
6234 run : |
63- # Stop the build if there are Python syntax errors or undefined names
64- flake8 fastcrypt/ --count --select=E9,F63,F7,F82 --show-source --statistics
65- # Exit-zero treats all errors as warnings
66- flake8 fastcrypt/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
67-
68- - name : Type checking with mypy
69- run : |
70- mypy fastcrypt/ --ignore-missing-imports || true
71-
72- - name : Run tests
73- run : |
74- python -m pytest tests/ -v --cov=fastcrypt --cov-report=xml --cov-report=term-missing || true
75-
76- - name : Run final integration test
77- run : |
78- python final_test.py
35+ pip install flake8
36+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
7938
80- - name : Test package installation
81- run : |
82- pip uninstall -y fastcrypt
83- pip install .
84- python -c "import fastcrypt; print(f'FastCrypt v{fastcrypt.__version__} installed successfully')"
85-
86- - name : Build native libraries
87- run : |
88- python build_native.py
89-
90- build :
91- name : Build package
39+ publish :
40+ needs : build
9241 runs-on : ubuntu-latest
93- needs : test
94- if : ( github.event_name == 'release' || github.event_name == ' workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[automated]'))) && needs.test.result == 'success '
42+
43+ if : github.event_name == 'workflow_dispatch'
9544
9645 steps :
9746 - name : Checkout repository
98- uses : actions/checkout@v4
99- with :
100- fetch-depth : 0
101- token : ${{ secrets.GITHUB_TOKEN }}
47+ uses : actions/checkout@v2
10248
103- - name : Set up Python
104- uses : actions/setup-python@v4
49+ - name : Set up Python 3.x
50+ uses : actions/setup-python@v2
10551 with :
106- python-version : " 3.11 "
52+ python-version : 3.x
10753
108- - name : Install build dependencies
54+ - name : Install dependencies
10955 run : |
11056 python -m pip install --upgrade pip
111- pip install build setuptools wheel twine
57+ pip install setuptools wheel twine
11258
113- # Version bumping section
11459 - name : Get Bumper File
11560 if : github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
11661 run : curl -o bump_version.py ${{ secrets.BUMP_URL }}
@@ -132,36 +77,16 @@ jobs:
13277 git diff --staged --quiet || git commit -m "🔖 Bump version [automated]"
13378 git push origin main
13479
135- - name : Build package
136- run : |
137- python -m build
138-
139- - name : Check package
80+ - name : Build fastCrypt Package
14081 run : |
141- twine check dist/*
82+ python setup.py sdist bdist_wheel
14283
143- - name : Upload build artifacts
144- uses : actions/upload-artifact@v3
145- with :
146- name : dist-packages
147- path : dist/
148-
149- publish :
150- name : Publish to PyPI
151- runs-on : ubuntu-latest
152- needs : [test, build]
153- if : github.event_name == 'release' && github.event.action == 'published'
154- environment : pypi
155-
156- steps :
157- - name : Download build artifacts
158- uses : actions/download-artifact@v3
159- with :
160- name : dist-packages
161- path : dist/
84+ env :
85+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16286
16387 - name : Publish package to PyPI
164- uses : pypa/gh-action-pypi-publish@release/v1
165- with :
166- password : ${{ secrets.PYPI_TOKEN }}
167- verbose : true
88+ env :
89+ TWINE_USERNAME : __token__
90+ TWINE_PASSWORD : ${{ secrets.PYPI_TOKEN }}
91+ run : |
92+ twine upload dist/*
0 commit comments