Merge pull request #31 from rdkit/EdgarHarutyunian-patch-12 #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | |
## from packaging tutorial: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
# Trigger the workflow on push to a tag (used for releases) | |
on: | |
push: | |
tags: | |
- "v*" # Push events to matching v*, like v1.0, v20.15.10 | |
jobs: | |
build: | |
name: Build distribution 📦 | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Miniconda | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: buildenv | |
auto-activate--base: false | |
# Step 3: Install RDKit (conda-forge) and Python | |
- name: Install RDKit and Python | |
shell: bash | |
run: | | |
conda install -c conda-forge python=3.9 rdkit | |
# Step 4: Install build tools(pip, pdm) | |
- name: Install build tools | |
shell: bash | |
run: | | |
conda activate buildenv | |
python3 -m pip install --upgrade pip pdm | |
# Step 4: Install Twine | |
- name: Install Twine | |
shell: bash | |
run: | | |
conda activate buildenv | |
python3 -m pip install --upgrade twine | |
# Step 5: Build a binary wheel and a source tarball | |
- name: Build a binary wheel and a source tarball | |
shell: bash | |
run: | | |
conda activate buildenv | |
pdm build | |
# Step 6: Validate the distribution | |
- name: Validate the distribution | |
shell: bash | |
run: | | |
conda activate buildenv | |
python3 -m twine check dist/* | |
# Step 7: Store the distribution artifacts for later use | |
- name: Store the distribution artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: Publish Python 🐍 distribution 📦 to PyPI | |
needs: build | |
runs-on: ubuntu-latest | |
if: "! contains(github.ref_name, '-')" # Only run for stable tags (no '-' in tag name) | |
environment: | |
name: pypi | |
url: https://pypi.org/project/laplaciannb/ | |
permissions: | |
contents: read | |
steps: | |
# Step 1: Download the distribution artifacts | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
# Step 2: Set up Miniconda | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: pypienv | |
auto-activate--base: false | |
# Step 3: Install Twine & RDKit | |
- name: Install Twine & RDKit | |
shell: bash | |
run: | | |
conda activate pypienv | |
conda install -c conda-forge python=3.9 rdkit | |
python3 -m pip install --upgrade twine | |
# Step 4: Publish distribution 📦 to PyPI | |
- name: Publish distribution 📦 to PyPI | |
shell: bash | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
conda activate pypienv | |
python3 -m twine upload --non-interactive --repository-url https://upload.pypi.org/legacy/ dist/* | |
publish-to-testpypi: | |
name: Publish Python 🐍 distribution 📦 to TestPyPI | |
needs: build | |
runs-on: ubuntu-latest | |
if: contains(github.ref_name, '-') # Only run for beta tags (contains '-' in tag name) | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/project/laplaciannb/ | |
permissions: | |
contents: read | |
steps: | |
# Step 1: Download the distribution artifacts | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
# Step 2: Set up Miniconda | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: testenv | |
auto-activate--base: false | |
# Step 3: Install Twine & RDKit | |
- name: Install Twine & RDKit | |
shell: bash | |
run: | | |
conda activate testenv | |
conda install -c conda-forge python=3.9 rdkit | |
python3 -m pip install --upgrade twine | |
# Step 4: Publish distribution 📦 to TestPyPI | |
- name: Publish distribution 📦 to TestPyPI | |
shell: bash | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: pypi-AgENdGVzdC5weXBpLm9yZwIkNDA5YTI4NjAtMGQ2Ni00MDhjLWIyNTEtZjE0MGMwOTZkNjEzAAITWzEsWyJsYXBsYWNpYW5uYiJdXQACLFsyLFsiMDE4NmFlNGEtZDU3Zi00NGY1LWJhZTEtZWJhOTgwNzdlZDc1Il1dAAAGIEi0TXsH8htF5P2HgdXO-N66z08IdmH-WpGZLgt7gY9s | |
run: | | |
conda activate testenv | |
python3 -m twine upload --verbose --non-interactive --repository-url https://test.pypi.org/legacy/ dist/* | |
# Step 5: Validate after publishing to TestPyPI | |
- name: Install from TestPyPI | |
shell: bash | |
run: | | |
conda activate testenv | |
python3 -m pip install --index-url https://test.pypi.org/simple/ laplaciannb==0.6.4 | |
python3 -c "import laplaciannb; print('laplaciannb installed OK from TestPyPi!')" | |
github-release: | |
name: Create a GitHub release | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
# Step 2: Download the distribution artifacts | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
# Step 3: Create a GitHub release | |
- name: Create a GitHub release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
body: | | |
## Chnages in this Release | |
- This is the automatically generated release notes for ${{ github.ref_name }}. | |
draft: false | |
prerelease: ${{ contains(github.ref_name, '-') }} # Set to true for beta releases | |
# Step 4: Attach the distribution artifacts to the GitHub release | |
- name: Attach the distribution artifacts to the GitHub release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/* | |
asset_name: $(basename $file) | |
asset_content_type: application/octet-stream |