Merge pull request #68 from mchrisgm/v2.5.0 #46
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 to PyPi | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build distribution | |
runs-on: ubuntu-latest | |
outputs: | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install toml | |
- name: Get version from pyproject.toml file | |
id: get_version | |
run: | | |
version=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
echo "VERSION=${version}" >> $GITHUB_OUTPUT | |
- name: Install pypa/build | |
run: python -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
run: python -m build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Set VERSION for next jobs | |
id: set_version | |
run: echo "VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV | |
publish-to-pypi: | |
name: Publish distribution to PyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/bambulabs_api | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
- name: Set VERSION for next jobs | |
id: set_version | |
run: echo "VERSION=${{ needs.build.outputs.VERSION }}" >> $GITHUB_ENV | |
github-release: | |
name: Sign the Python distribution with Sigstore and upload them to GitHub Release | |
needs: | |
- build | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Import VERSION environment variable | |
run: | | |
echo "VERSION=${{ needs.build.outputs.VERSION }}" >> $GITHUB_ENV | |
echo "VERSION=${{ env.VERSION }}" | |
- 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: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create "${{ env.VERSION }}" --latest --repo "${{ github.repository }}" --notes "" | |
- name: Upload artifact signatures to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload "${{ env.VERSION }}" dist/** --repo "${{ github.repository }}" |