Skip to content

Commit

Permalink
Update to use OIDC publishing (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Aug 17, 2023
1 parent cf1aa88 commit 2e2a6c8
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true

permissions:
contents: read
id-token: write

jobs:
build-wheels:
name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }}
Expand Down Expand Up @@ -177,6 +181,7 @@ jobs:
run: |
pip install build
python -m build --sdist --outdir dist .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -219,10 +224,12 @@ jobs:
run: |
pip install flake8
flake8 src setup.py python-bindings python-impl
- name: mypy
run: |
pip install mypy
mypy --config-file mypi.ini python-bindings python-impl
upload:
name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }}
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
Expand Down Expand Up @@ -270,32 +277,17 @@ jobs:
name: packages
path: ./dist

- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SECRET
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT
env:
SECRET: "${{ secrets.test_pypi_password }}"

- name: Install twine
run: pip install twine

- name: Publish distribution to PyPI
if: env.RELEASE == 'true' && steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'
if: env.RELEASE == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true

- name: Publish distribution to Test PyPI
if: env.PRE_RELEASE == 'true' && steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'
if: env.PRE_RELEASE == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/
skip-existing: true

0 comments on commit 2e2a6c8

Please sign in to comment.