From f060e9bd88a09eec9fb814ec3e4931b60bf4c7dd Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Wed, 13 Dec 2023 17:53:05 +0100 Subject: [PATCH] Update pypi publishing to double auth --- .github/workflows/devpublish.yml | 78 ----------------------------- .github/workflows/pythonpublish.yml | 25 ++++----- 2 files changed, 9 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/devpublish.yml 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..dd3a671 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -9,20 +9,13 @@ on: jobs: deploy: runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write 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/* + # retrieve your distributions here + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1