Merge pull request #52 from minaskar/dev #37
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 pocomc to PyPI / GitHub | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'pocomc/_version.py' # Only run workflow on pushes where _version.py was changed | |
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab | |
jobs: | |
build-n-publish: | |
name: Build and publish to PyPI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.11" | |
- name: Build source and wheel distributions | |
run: | | |
python -m pip install --upgrade build twine | |
python -m build | |
twine check --strict dist/* | |
- name: Install pocomc from the wheel file | |
run: | | |
pip install dist/*.whl | |
- name: List the installed packages | |
run: | | |
pip freeze | |
- name: Run pocomc unittests | |
run: | | |
python -m unittest discover tests | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::$(cat pocomc/_version.py | grep version | cut -d'"' -f 2) | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create our own | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: ${{ steps.get_version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Get Asset name | |
run: | | |
export PKG=$(ls dist/ | grep tar) | |
set -- $PKG | |
echo "name=$1" >> $GITHUB_ENV | |
- name: Upload Release Asset (sdist) to GitHub | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: dist/${{ env.name }} | |
asset_name: ${{ env.name }} | |
asset_content_type: application/zip |