Skip to content

bug: workflow auto release not working, match .whl name properly #15

bug: workflow auto release not working, match .whl name properly

bug: workflow auto release not working, match .whl name properly #15

name: Publish and Release Python Package
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for trusted publishing to PyPI
contents: write # Required for creating releases and uploading assets
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run Tests
run: poetry run pytest
- name: Build the package
if: success()
run: poetry build
- name: Publish to PyPI
if: success()
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
if: success()
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass the GitHub token
with:
tag_name: ${{ github.ref }} # Use the current tag
release_name: Release ${{ github.ref }} # Name the release
body: |
Automated release for version ${{ github.ref }}
draft: false
prerelease: false
- name: List dist contents for debugging
if: success()
run: ls -al dist/
- name: Upload .whl to GitHub Release
if: success()
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/*.whl # This will match the actual file in the dist/ folder
asset_name: nag-${{ github.ref }}.whl # Use dynamic name based on tag/version
asset_content_type: application/zip
- name: Upload .tar.gz to GitHub Release
if: success()
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/*.tar.gz # Match the tar.gz file
asset_name: nag-${{ github.ref }}.tar.gz
asset_content_type: application/gzip