1+ name : Manual Publish to PyPI
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Version to publish (without v prefix, e.g. 1.2.5)'
8+ required : true
9+ type : string
10+
11+ permissions :
12+ contents : read
13+
14+ jobs :
15+ manual-publish :
16+ runs-on : ubuntu-latest
17+ environment :
18+ name : pypi
19+
20+ steps :
21+ - uses : actions/checkout@v4
22+
23+ - name : Set up Python
24+ uses : actions/setup-python@v5
25+ with :
26+ python-version : " 3.11"
27+
28+ - name : Verify version matches
29+ run : |
30+ VERSION=$(grep -m 1 "version = " pyproject.toml | sed 's/version = "\(.*\)"/\1/')
31+ echo "Version in pyproject.toml: $VERSION"
32+ echo "Version requested: ${{ github.event.inputs.version }}"
33+ if [ "$VERSION" != "${{ github.event.inputs.version }}" ]; then
34+ echo "::error::Version mismatch! pyproject.toml has $VERSION but requested ${{ github.event.inputs.version }}"
35+ exit 1
36+ fi
37+
38+ - name : Install build
39+ run : |
40+ python -m pip install --upgrade pip
41+ python -m pip install build
42+
43+ - name : Build package
44+ run : python -m build
45+
46+ - name : Verify distribution files
47+ run : |
48+ echo "Generated distribution files:"
49+ ls -la dist/
50+
51+ - name : Publish to PyPI
52+ uses : pypa/gh-action-pypi-publish@release/v1
53+ with :
54+ password : ${{ secrets.PYPI_TOKEN }}
55+ packages-dir : dist/
56+ verbose : true
57+
58+ - name : Verify publication
59+ run : |
60+ echo "Waiting for PyPI to index the package..."
61+ sleep 30
62+
63+ # Use pip to verify the version is available
64+ python -m pip install commitloom==${{ github.event.inputs.version }} --no-deps
65+ INSTALLED_VERSION=$(python -c "import commitloom; print(commitloom.__version__)")
66+
67+ echo "Installed version: $INSTALLED_VERSION"
68+ if [ "$INSTALLED_VERSION" == "${{ github.event.inputs.version }}" ]; then
69+ echo "✅ Publication successful!"
70+ else
71+ echo "⚠️ Publication may have failed or not indexed yet"
72+ fi
0 commit comments