Skip to content

Commit efa947f

Browse files
committed
2 parents 3a04d66 + 2131dd7 commit efa947f

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

.github/workflows/pypi.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build and Publish LibCrypto Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: 'Version bump type (patch, minor, major) or skip for no bump'
8+
required: false
9+
default: 'skip'
10+
type: choice
11+
options:
12+
- skip
13+
- patch
14+
- minor
15+
- major
16+
custom_version:
17+
description: 'Custom version (e.g., 1.2.3) - overrides version_bump'
18+
required: false
19+
type: string
20+
version_suffix:
21+
description: 'Version suffix (e.g., rc1, a1, b1) - optional'
22+
required: false
23+
type: string
24+
dry_run:
25+
description: 'Dry run (build only, do not publish)'
26+
required: false
27+
default: false
28+
type: boolean
29+
push:
30+
tags:
31+
- 'v*'
32+
33+
release:
34+
types: [published]
35+
36+
jobs:
37+
version-check:
38+
runs-on: ubuntu-latest
39+
outputs:
40+
version: ${{ steps.get-version.outputs.version }}
41+
should_publish: ${{ steps.check-publish.outputs.should_publish }}
42+
43+
steps:
44+
- name: \[LIBCrypto]\ Checkout Repository
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.10'
51+
- name: check and clean dist folders
52+
run: |
53+
rm -rf dist/ build/ *.egg-info/
54+
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install rich
59+
60+
- name: Update version if requested
61+
if: ${{ github.event.inputs.version_bump != 'skip' || github.event.inputs.custom_version != '' }}
62+
run: |
63+
if [ "${{ github.event.inputs.custom_version }}" != "" ]; then
64+
echo "Setting custom version: ${{ github.event.inputs.custom_version }}"
65+
python version_manager.py --set "${{ github.event.inputs.custom_version }}" --suffix "${{ github.event.inputs.version_suffix }}"
66+
elif [ "${{ github.event.inputs.version_bump }}" != "skip" ]; then
67+
echo "Bumping version: ${{ github.event.inputs.version_bump }}"
68+
python version_manager.py --bump "${{ github.event.inputs.version_bump }}" --suffix "${{ github.event.inputs.version_suffix }}"
69+
fi
70+
71+
- name: Get current version
72+
id: get-version
73+
run: |
74+
VERSION=$(python version_manager.py --show | grep "Current version:" | cut -d' ' -f3)
75+
echo "version=$VERSION" >> $GITHUB_OUTPUT
76+
echo "Current version: $VERSION"
77+
78+
- name: Validate version consistency
79+
run: |
80+
python version_manager.py --check
81+
echo "✅ Version consistency validated"
82+
83+
- name: Commit version changes
84+
if: ${{ github.event.inputs.version_bump != 'skip' || github.event.inputs.custom_version != '' }}
85+
run: |
86+
git config --local user.email "[email protected]"
87+
git config --local user.name "GitHub Action"
88+
git add src/libcrypto/_version.py
89+
git commit -m "🔖 Bump version to ${{ steps.get-version.outputs.version }}" || echo "No changes to commit"
90+
git push origin ${{ github.ref_name }} || echo "Push failed, continuing..."
91+
92+
93+
- name: Install build tools
94+
run: |
95+
python -m pip install --upgrade pip
96+
pip install build twine
97+
98+
- name: Build the package
99+
run: python -m build
100+
101+
- name: Publish to PyPI
102+
env:
103+
TWINE_USERNAME: __token__
104+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
105+
run: |
106+
twine upload dist/*
107+
108+
- name: Upload build artifacts
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: libcrypto-distribution
112+
path: dist/

0 commit comments

Comments
 (0)