Refactor GitHub Actions workflow to use actions/upload-artifact@v4 an… #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python Package Build and Publish | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install build tools | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install setuptools wheel | |
- name: Build the package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Check dist folder | |
run: ls -l dist | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
publish: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: ./dist # Ensure the dist directory is created locally | |
- name: Check working directory | |
run: pwd | |
- name: Check dist folder | |
run: ls -l dist | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
run: | | |
python -m pip install --upgrade twine | |
twine upload ./dist/* |