Skip to content

Build & Upload Python Package to Asset #15

Build & Upload Python Package to Asset

Build & Upload Python Package to Asset #15

name: Build & Upload Python Package to Asset
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build-n-publish:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: GitHub Tag Name example
run: |
echo "Tag name from GITHUB_REF_NAME: $GITHUB_REF_NAME"
echo "Tag name from github.ref_name: ${{ github.ref_name }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -U poetry
pip install build
- name: Build package
run: python -m build
#- name: Publish package to PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
- name: Extract Asset Name
run: |
ls dist/* > asset_paths.txt
sed -i ':a;N;$!ba;s/\n/\\n/g' asset_paths.txt
echo "files_names=$(cat asset_paths.txt)" >> $GITHUB_ENV
#run: |
# export PKG=$(ls dist/ | grep whl)
# set -- $PKG
# echo "name=$1" >> $GITHUB_ENV
- name: Create and upload release with asset to GitHub
id: upload-release-asset
uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: true
files: |
dist/${{ env.name }}