File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish PyPI Package
2+
3+ on :
4+ push :
5+ tags :
6+ - ' py-v*'
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : read
11+ id-token : write
12+
13+ jobs :
14+ publish-pypi :
15+ runs-on : ubuntu-latest
16+ defaults :
17+ run :
18+ working-directory : blackwall-llm-shield-python
19+
20+ steps :
21+ - name : Check out repository
22+ uses : actions/checkout@v4
23+
24+ - name : Set up Python
25+ uses : actions/setup-python@v5
26+ with :
27+ python-version : ' 3.11'
28+
29+ - name : Install build tooling
30+ run : python -m pip install --upgrade pip build
31+
32+ - name : Run tests
33+ run : python -m unittest discover -s tests
34+
35+ - name : Verify tag matches package version
36+ if : startsWith(github.ref, 'refs/tags/')
37+ env :
38+ GITHUB_REF_NAME : ${{ github.ref_name }}
39+ run : |
40+ PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
41+ EXPECTED_TAG="py-v${PACKAGE_VERSION}"
42+ if [ "$GITHUB_REF_NAME" != "$EXPECTED_TAG" ]; then
43+ echo "Tag $GITHUB_REF_NAME does not match package version $PACKAGE_VERSION"
44+ exit 1
45+ fi
46+
47+ - name : Build package
48+ run : python -m build
49+
50+ - name : Publish to PyPI
51+ uses : pypa/gh-action-pypi-publish@release/v1
52+ with :
53+ password : ${{ secrets.PYPI_TOKEN }}
54+ packages-dir : blackwall-llm-shield-python/dist/
You can’t perform that action at this time.
0 commit comments