Skip to content

Merge pull request #885 from atsign-foundation/dependabot/pip/package… #142

Merge pull request #885 from atsign-foundation/dependabot/pip/package…

Merge pull request #885 from atsign-foundation/dependabot/pip/package… #142

name: Build and publish sshnpd PyPI package
on:
workflow_dispatch:
push:
tags:
- 'p*.*.*'
branches:
- trunk
permissions: # added using https://github.com/step-security/secure-repo
contents: read
jobs:
build:
name: Build package
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Set up Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.11'
- name: Install Poetry
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # v3.0.0
with:
poetry-version: '1.7.1'
- name: Build using Poetry
working-directory: packages/python/sshnpd
run: |
poetry build
cp -r dist/ $GITHUB_WORKSPACE
- name: Store the distribution packages
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: sshnpd-python-package
path: dist/
publish-to-testpypi:
name: Publish package to TestPyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/sshnpd
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: sshnpd-python-package
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
with:
skip-existing: true
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish package to PyPI
if: startsWith(github.ref, 'refs/tags/p') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sshnpd
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: sshnpd-python-package
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
github-release:
name: >-
Sign the Python distribution with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: sshnpd-python-package
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@61f6a500bbfdd9a2a339cf033e5421951fbc1cd2 # v2.1.1
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'