Build and Publish #44
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: Build and Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
version_type: | |
description: "Patch" | |
required: true | |
type: choice | |
options: | |
- prerelease | |
- prepatch | |
- preminor | |
- premajor | |
- patch | |
- minor | |
- major | |
jobs: | |
increment-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install poetry | |
- name: Increment version number | |
id: version | |
run: | | |
poetry version ${{ github.event.inputs.version_type }} | |
echo "::set-output name=version_tag::$(poetry version | grep --only-matching '[0-9].[0-9].[0-9].*$')" | |
- name: Commit files | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "Increment version number" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
outputs: | |
version_tag: ${{ steps.version.outputs.version_tag }} | |
build: | |
needs: increment-version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install poetry | |
sudo apt install git | |
- name: Pull latest | |
run: git pull | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.increment-version.outputs.version_tag }} | |
release_name: Release ${{ needs.increment-version.outputs.version_tag }} | |
draft: false | |
prerelease: false | |
- name: Build package | |
run: poetry build --no-interaction | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |