diff --git a/.github/workflows/devpublish.yml b/.github/workflows/devpublish.yml deleted file mode 100644 index 7e3ec94..0000000 --- a/.github/workflows/devpublish.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Test and Upload Python Package dev mode - -on: - # Trigger the workflow on push, - # but only for the master branch - push: - branches: - - master - -jobs: - test: - name: run tests - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [ '3.x' ] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools - - name: test execution - run: | - pip install -e ./ - pip install -e ./[tests] - pytest - - publish: - name: publish a new dev revision - runs-on: ubuntu-latest - needs: test - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: upload - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - # Get the online last revision - last_rev=$(pip install pyluos== 2>&1 | grep ')' | awk 'NF{print substr($NF, 1, length($NF)-1)}') - # Get the local last revision - local_rev=$(cat pyluos/version.py | awk 'NF{print substr($NF, 1, length($NF)-1)}') - local_rev="${local_rev:1}" - # if local and remote revision are same increase rev of last_rev - if [[ $last_rev == $local_rev ]]; then - # get bug fix rev and increase it - bugfix_rev=$(expr $(cut -d. -f3 <<< "$last_rev")+1 | bc) - tmp=$(cut -d. -f-2 <<< "$last_rev") - last_rev=${tmp}.${bugfix_rev} - fi - pre_rev_nb=1 - if [[ $last_rev == *b* ]]; then - # get pre rev number and increment it - pre_rev_nb=$(expr $(cut -d "b" -f 2 <<< "$last_rev")+1 | bc) - # remove pre rev number - last_rev=$(cut -db -f1 <<< "$last_rev") - fi - # put dev revision after last_rev - revision=${last_rev}.b${pre_rev_nb} - # save it into version file - echo version = \'$revision\' > pyluos/version.py - - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 5c27ca7..501fa1c 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -7,22 +7,46 @@ on: jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python setup.py sdist bdist_wheel + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: upload release to PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/ # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1