Skip to content

Commit ac507bb

Browse files
authored
Update publish.yml
1 parent ed263ba commit ac507bb

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

.github/workflows/publish.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# .github/workflows/publish-to-pypi.yml
2-
32
name: Publish to PyPI
4-
53
on:
64
release:
75
types: [published]
86
workflow_dispatch: # Allows you to manually trigger the workflow
9-
107
permissions:
118
contents: read
129
id-token: write # Required for secure OIDC authentication with PyPI
13-
1410
jobs:
1511
deploy:
1612
runs-on: ubuntu-latest
@@ -19,20 +15,25 @@ jobs:
1915
steps:
2016
- name: Checkout code
2117
uses: actions/checkout@v4
22-
# This fetches the specific commit associated with the tag
23-
# to ensure the workflow is using the correct code.
24-
18+
with:
19+
fetch-depth: 0 # Fetch full history to ensure we have the latest commits
20+
21+
- name: Clear GitHub Actions cache
22+
run: |
23+
echo "Clearing any cached data..."
24+
rm -rf ~/.cache/pip
25+
2526
- name: Set up Python
2627
uses: actions/setup-python@v5
2728
with:
2829
python-version: '3.11'
29-
cache: 'pip' # Speeds up dependency installation
30-
30+
# Removed pip cache to force fresh install
31+
3132
- name: Install dependencies
3233
run: |
3334
python -m pip install --upgrade pip
34-
pip install build twine
35-
35+
pip install build twine toml
36+
3637
- name: Verify package version
3738
run: |
3839
PACKAGE_VERSION=$(python -c "import toml; print(toml.load(open('pyproject.toml'))['project']['version'])")
@@ -42,15 +43,13 @@ jobs:
4243
echo "Error: The version in pyproject.toml does not match the release tag."
4344
exit 1
4445
fi
45-
46+
4647
- name: Clean old builds and build new package
4748
run: |
48-
rm -rf dist/ # Always delete the old dist directory to prevent stale artifacts
49+
rm -rf dist/ build/ *.egg-info/ # Clean all build artifacts
4950
python -m build
50-
51+
5152
- name: Publish package to PyPI
52-
uses: pypa/gh-action-pypi-publish@release/v1 # This action is a secure and recommended way to publish
53+
uses: pypa/gh-action-pypi-publish@release/v1
5354
with:
5455
password: ${{ secrets.PYPI_API_TOKEN }}
55-
# The action will automatically find and upload the files in the 'dist' folder
56-

0 commit comments

Comments
 (0)