Skip to content

Project Release

Project Release #3

Workflow file for this run

name: 'Project Release'
on:
workflow_dispatch:
jobs:
build-test-publish-index-package:
name: PyPi Package Test/Build/Publish
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: write
steps:
# Checkout the repository
- name: Repository Checkout
uses: actions/checkout@v4
# Set up the environment to run Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ">=3.6"
# Set up the environment to run the latest Python build, test, and publish tools
- name: Set Up Build & Test Environment
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools
python3 -m pip install --upgrade wheel
python3 -m pip install --upgrade pytest
python3 -m pip install --upgrade twine
# Install the package from source
- name: Install Source Code
run: |
python3 -m pip install -e .
# Run the package tests
- name: Test Source Code
run: |
python3 -m pytest -v
# Build the package
- name: Build Package
run: |
python3 -m pip install --upgrade build
python3 -m build
# Check the distribution files with Twine
- name: Test Package
run: |
python3 -m twine check dist/*
# Store the distribution files as artifacts
- name: Store Distribution Packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
# Upload the distribution artifacts to PyPi production environment
- name: Publish Package (PyPi)
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_TOKEN }}
# Sign the distribution files with Sigstore
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
# Create a GitHub Release
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
gh release create -d
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
# Upload the distribution artifact signatures to the GitHub Release
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'