Skip to content

Build and Publish

Build and Publish #14

# This is a basic workflow to help you get started with Actions
name: Build and Publish
# Controls when the action will run.
on:
# Triggers the workflow on push to the master branch
# push:
# branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Build_and_Publish:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Sets up python3
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Installs and upgrades pip, installs other dependencies and installs the package from setup.py
- name: "Setup python dependencies"
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine build
- name: Build package
run: |
python -m build
- name: Get Package version
if: always()
id: app-version
run: echo ::set-output name=current-version::$(python setup.py --version)
- name: Release to Github
if: always()
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
allowUpdates: true
tag: ${{ steps.app-version.outputs.current-version}}
token: ${{ secrets.GITHUB_TOKEN }}
replacesArtifacts: true
artifactErrorsFailBuild: true
# even if pypi upload fails upload to github release
- name: Publish to PyPI register
run:
python3 -m twine upload dist/*
continue-on-error: true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}