Skip to content

unitsnet-py

unitsnet-py #151

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: |
VERSION=$(python setup.py --version)
DEFINITION_VERSION=$(grep -oP "(?<=definition_version = ')[^']+" setup.py)
CURRENT_DEFINITION=$(python ./scripts/definition-version.py)
NEXT_VERSION=$(python ./scripts/next-package-version.py $VERSION $DEFINITION_VERSION $CURRENT_DEFINITION)
sed -i 's|'$VERSION'|'$NEXT_VERSION'|g' setup.py
sed -i "s/definition_version = '[^']*'/definition_version = '$CURRENT_DEFINITION'/" setup.py
echo "VERSION=$NEXT_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