Skip to content

Update publish-to-test-pypi.yml #33

Update publish-to-test-pypi.yml

Update publish-to-test-pypi.yml #33

name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
on:
push:
branches:
- main
jobs:
build:
name: Build distribution πŸ“¦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y r-base libtirpc-dev libcurl4-openssl-dev libssl-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install pypa/build
run: python3 -m pip install build
- name: Ensure requirements.txt exists
run: |
if [ ! -f requirements.txt ]; then echo "requirements.txt not found!"; exit 1; fi
- name: Build a binary wheel and a source tarball
env:
RPY2_CFFI_MODE: ABI
run: python -m build --sdist --wheel --outdir dist/
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-testpypi:
name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/openspi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install R
run: |
sudo apt-get update
sudo apt-get install -y r-base
- name: Install R dependencies
run: |
R_LIBS_USER=$(Rscript -e 'cat(Sys.getenv("R_LIBS_USER"))')
mkdir -p "$R_LIBS_USER"
Rscript -e "install.packages('devtools', repos='http://cran.rstudio.com/', lib='$R_LIBS_USER')"
Rscript -e "devtools::install_version('rpy2', version='3.5.16', lib='$R_LIBS_USER')"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install -r build_requirements.txt
- name: Install runtime dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build the package
env:
RPY2_CFFI_MODE: ABI
run: python -m build
- name: Publish to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
github-release:
name: Sign the Python 🐍 distribution πŸ“¦ with Sigstore and upload them to GitHub Release
needs: publish-to-testpypi
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@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create v${{steps.get_version.outputs.VERSION}} dist/*.whl dist/*.tar.gz --repo KrisHeathNREL/OpenSpecy-Python-Interface --notes "Release v${{ steps.get_version.outputs.VERSION }}"
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload v${{steps.get_version.outputs.VERSION}} dist/** --repo KrisHeathNREL/OpenSpecy-Python-Interface