Skip to content

unitsnet-py

unitsnet-py #145

Workflow file for this run

name: unitsnet-py
on: [push, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Generate units
run: |
pip install -r requirements-dev.txt
python units_generator/generate_package.py
- name: Test units
run: |
python -m unittest discover tests
- name: Bump version
if: github.ref == 'refs/heads/main'
id: update_version
run: |
old_version=$(python setup.py --version)
IFS='.' read -ra parts <<< "$old_version"
version="${parts[0]}.${parts[1]}.$((parts[2]+1))"
sed -i 's|'$old_version'|'$version'|g' setup.py
echo "VERSION=$version" >> $GITHUB_OUTPUT
- name: Get version info
id: version_info
run: |
body=$(git log -1 --pretty=%B | sed -n '1p')
echo "BODY=$body" >> $GITHUB_OUTPUT
- name: Commit and push version
if: github.ref == 'refs/heads/main'
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Update to version ${{ steps.update_version.outputs.VERSION }} [skip-ci]
- name: Publish release
if: github.ref == 'refs/heads/main'
env:
API_KEY: '${{ secrets.PIP_API_KEY }}'
run: |
pip install twine
python setup.py sdist
twine upload dist/* -u __token__ -p $API_KEY
- name: Create Release
if: github.ref == 'refs/heads/main'
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.update_version.outputs.VERSION }}
name: Package Version ${{ steps.update_version.outputs.VERSION }}
body: ${{ steps.version_info.outputs.BODY }}
draft: false
prerelease: false