v1.5.3 Release (#81) #5
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: Create Release and Publish to PyPI | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
check-version-change: | |
runs-on: ubuntu-latest | |
outputs: | |
version_changed: ${{ steps.version_changed.outputs.version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check if version.py has changed | |
id: version_changed | |
uses: dorny/paths-filter@v2 | |
with: | |
filters: | | |
version: | |
- 'pyaim/version.py' | |
create-release: | |
if: ${{ needs.check-version-change.outputs.version_changed == 'true' }} | |
needs: check-version-change | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Extract version | |
id: get_version | |
run: | | |
VERSION=$(grep '^__version__ = ' pyaim/version.py | cut -d '"' -f 2 | cut -d "'" -f 2) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "::set-output name=VERSION::$VERSION" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
publish-to-pypi: | |
if: ${{ needs.check-version-change.outputs.version_changed == 'true' }} | |
needs: create-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
pip install --upgrade setuptools wheel twine | |
- name: Build package | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
twine upload dist/* |