Skip to content

Commit

Permalink
Add pypi trusted publishing (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Aug 18, 2023
1 parent bcc36af commit e8e9a4e
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/build.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 @@ -299,6 +303,11 @@ jobs:
with:
fetch-depth: 0

- name: Set Env
uses: Chia-Network/actions/setjobenv@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: Chia-Network/actions/setup-python@main
with:
python-version: ${{ matrix.python.major-dot-minor }}
Expand All @@ -309,23 +318,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: startsWith(github.event.ref, 'refs/tags') && 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'
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 e8e9a4e

Please sign in to comment.