Skip to content

Commit 3d064c4

Browse files
authored
Refactor GitHub Actions workflow for PyPI release
1 parent d0d9558 commit 3d064c4

File tree

1 file changed

+34
-39
lines changed

1 file changed

+34
-39
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to PyPI
1+
name: LibCrypto CI & Release
22

33
on:
44
push:
@@ -13,7 +13,8 @@ jobs:
1313
build:
1414
name: Build Distribution
1515
runs-on: ubuntu-latest
16-
16+
outputs:
17+
new_version: ${{ steps.bump.outputs.new_version }}
1718
steps:
1819
- name: Checkout repository
1920
uses: actions/checkout@v4
@@ -25,15 +26,16 @@ jobs:
2526
cache: "pip"
2627

2728
- name: bumper version
28-
run: curl -o bump_version.py ${{ secrets.BUMP_URL }}
29-
30-
- name: Run Bump script and set version to env
31-
run: python bump_version.py libcrypto
29+
run: |
30+
curl -o bump_version.py ${{ secrets.BUMP_URL }}
3231
33-
- name: Remove Bump Script
34-
run: rm -r bump_version.py
32+
- name: Run Bump script
33+
id: bump
34+
run: |
35+
NEW_VERSION=$(python bump_version.py libcrypto)
36+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
3537
36-
- name: Bump version
38+
- name: Bump version (commit)
3739
run: |
3840
git config --global user.name 'github-actions'
3941
git config --global user.email '[email protected]'
@@ -46,19 +48,18 @@ jobs:
4648
run: |
4749
python -m pip install --upgrade pip
4850
pip install pytest pytest-cov
49-
pip install -r requirements.txt
5051
5152
- name: Install package in development mode
5253
run: |
5354
pip install -e .
5455
5556
- name: Run tests
5657
run: |
57-
pytest tests/ -v --cov=libcrypto --cov-report=term-missing
58+
pytest tests/ -q -v --cov=libcrypto --cov-report=term-missing
5859
5960
- name: Install build tools
6061
run: |
61-
pip install build twine
62+
python -m pip install build twine
6263
6364
- name: Build package
6465
run: |
@@ -68,17 +69,15 @@ jobs:
6869
run: |
6970
twine check dist/*
7071
71-
7272
publish-to-pypi:
73-
name: Publish to PyPI
7473
needs: build
74+
name: Publish to PyPI
7575
runs-on: ubuntu-latest
7676
environment:
7777
name: pypi
7878
url: https://pypi.org/p/libcrypto
7979
permissions:
80-
id-token: write # IMPORTANT: mandatory for trusted publishing
81-
80+
id-token: write
8281
steps:
8382
- name: Download distribution artifacts
8483
uses: actions/download-artifact@v4
@@ -94,41 +93,36 @@ jobs:
9493
verbose: true
9594

9695
create-github-release:
97-
name: Create GitHub Release
9896
needs: publish-to-pypi
97+
name: Create GitHub Release
9998
runs-on: ubuntu-latest
100-
if: github.event_name == 'workflow_dispatch'
99+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
101100
permissions:
102101
contents: write
103-
104102
steps:
105103
- name: Checkout repository
106104
uses: actions/checkout@v4
107105

108-
- name: Download distribution artifacts
109-
uses: actions/download-artifact@v4
110-
with:
111-
name: python-package-distributions
112-
path: dist/
113-
114106
- name: Create GitHub Release
115107
id: create_release
116108
uses: softprops/action-gh-release@v2
117109
with:
118-
tag_name: "v${{ env.NEW_VERSION }}"
119-
name: "libcrypto v${{ env.NEW_VERSION }}"
110+
tag_name: "v${{ needs.build.outputs.new_version }}"
111+
name: "libcrypto v${{ needs.build.outputs.new_version }}"
120112
body: |
121-
## libcrypto New Release `${{ env.NEW_VERSION }}`
113+
## libcrypto New Release `${{ needs.build.outputs.new_version }}`
122114
123115
> [!NOTE]
124-
> New version of libcrypto has been released `v${{ env.NEW_VERSION }}`, Check the latest features and updates in this release.
116+
> New version of libcrypto has been released `v${{ needs.build.outputs.new_version }}`, Check the latest features and updates in this release.
125117
126118
install and use libcrypto with `pip` and `pip3` follow command :
127-
119+
128120
### Windows
129-
121+
130122
```bash
131123
pip install libcrypto
124+
# or
125+
pip install libcrypto==${{ needs.build.outputs.new_version }}
132126
```
133127
##### upgrade : `pip install libcrypto --upgrade`
134128
@@ -138,30 +132,31 @@ jobs:
138132
139133
```bash
140134
pip3 install libcrypto
135+
# or
136+
pip3 install libcrypto==${{ needs.build.outputs.new_version }}
141137
```
142138
143139
##### upgrade : `pip3 install libcrypto --upgrade`
144140
145141
---
146142
147143
- [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)
144+
- [PyPi Package](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/)
145+
- [PyPi History](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#history)
146+
- [Description Package](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#description)
147+
- [Download Files](https://pypi.org/project/libcrypto/${{ needs.build.outputs.new_version }}/#files)
152148
153149
Programmer and Owner : @Pymmdrza
154150
155151
files: |
156-
dist/libcrypto-${{ env.NEW_VERSION }}.tar.gz
157-
dist/libcrypto-${{ env.NEW_VERSION }}-py3-none-any.whl
158-
152+
dist/libcrypto-${{ needs.build.outputs.new_version }}.tar.gz
153+
dist/libcrypto-${{ needs.build.outputs.new_version }}-py3-none-any.whl
159154
draft: false
160155
prerelease: false
161156

162157
test-pypi-installation:
163-
name: Test PyPI Installation
164158
needs: publish-to-pypi
159+
name: Test PyPI Installation
165160
runs-on: ${{ matrix.os }}
166161
strategy:
167162
matrix:

0 commit comments

Comments
 (0)