bug: use exact tag instead of github ref for release #17
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: 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: Extract Tag Name | |
id: extract_tag | |
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}" | |
- name: Publish to PyPI | |
if: success() | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.extract_tag.outputs.TAG_NAME }} | |
release_name: Release ${{ steps.extract_tag.outputs.TAG_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
uses: AButler/[email protected] | |
with: | |
files: "dist/*" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |