work #128
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 package | |
on: [push] | |
jobs: | |
set_version: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Test version | |
uses: paulhatch/semantic-version@v4.0.2 | |
id: versioning | |
with: | |
tag_prefix: "v" | |
major_pattern: "[MAJOR]" | |
minor_pattern: "[MINOR]" | |
format: "${major}.${minor}.${patch}a${increment}" | |
bump_each_commit: false | |
outputs: | |
version: ${{ github.repository == 'toncenter/pytonlib' && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.versioning.outputs.version_tag || steps.versioning.outputs.version}} | |
build_wheel: | |
runs-on: ubuntu-20.04 | |
needs: [ set_version ] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v2 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.8 | |
- name: Install build dependencies | |
run: | | |
python -m pip install build wheel | |
python -m pip install -r requirements.txt | |
- name: Build distributions | |
shell: bash -l {0} | |
run: PYTONLIB_VERSION=${{ needs.set_version.outputs.version }} python setup.py sdist bdist_wheel | |
- name: Check distributions | |
shell: bash -l {0} | |
run: | | |
echo $(pwd) | |
ls $(pwd)/ | |
- name: Run tests | |
shell: bash -l {0} | |
run: | | |
python -m pip install ./*.whl | |
PYTHONPATH=./ pytest --asyncio-mode=strict tests/ || echo "Warning! Some tests failed" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytonlib-package | |
path: | | |
dist/*.whl | |
dist/*.tar.gz | |
upload-pypi: | |
runs-on: ubuntu-20.04 | |
needs: [ set_version, build_wheel ] | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: pytonlib-package | |
path: dist | |
- name: Check distributions | |
shell: bash -l {0} | |
run: ls -la dist/ | |
- name: Create release tag | |
if: ${{ github.repository == 'toncenter/pytonlib' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
github.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ needs.set_version.outputs.version }}', | |
sha: context.sha | |
}) | |
- name: Publish package to test PyPI | |
if: ${{ github.repository == 'toncenter/pytonlib' && github.event_name == 'push' }} | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_PASSWORD }} | |
repository_url: https://test.pypi.org/legacy/ | |
- name: Publish package to PyPI | |
if: ${{ github.repository == 'toncenter/pytonlib' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} | |
repository_url: https://upload.pypi.org/legacy/ |