Add trusted publisher #1
This file contains hidden or 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: Upload libboost-headers to PyPI | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
get-versions: | |
name: "Upload latest libboost-headers version to PyPI" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write # Required for Trusted Publishing | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
architecture: x64 | |
- name: Install dependencies | |
run: pip install build | |
- name: Enable brew | |
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH | |
- name: Download boost | |
run: brew install boost | |
- name: Get latest version | |
id: version | |
run: echo "latest=$(brew list --version boost | sed -e 's/boost\s//')" >> $GITHUB_OUTPUT | |
- name: List version | |
run: echo "latest=${{ steps.version.outputs.latest }}" | |
- name: Get the libboost-headers contents | |
run: cp -r /home/linuxbrew/.linuxbrew/Cellar/boost/${{ steps.version.outputs.latest }}/include/* src/libboost_headers/include | |
- name: Set PyPI Version | |
run: | | |
echo "$(echo ${{ steps.version.outputs.latest }} | sed -e 's/_\w*//')" >> PYPI_VERSION | |
cat PYPI_VERSION | |
- name: Show contents | |
run: ls -ahl src/libboost_headers/include | |
- name: Build wheel | |
run: python -m build --wheel --outdir wheelhouse . | |
- name: Test wheel | |
run: | | |
pip install wheelhouse/* | |
pip install pytest | |
pytest | |
- name: Keep Wheel file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheelhouse | |
path: ./wheelhouse/*.whl | |
- name: List assets | |
run: ls ./wheelhouse/ -al | |
- name: Upload assets to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
# To test, use the TestPyPI: | |
# repository-url: https://test.pypi.org/legacy/ | |
# You must also create an account and project on TestPyPI, | |
# as well as set the trusted-publisher in the project settings: | |
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
# To publish to the official PyPI repository, just keep | |
# repository-url commented out. | |
packages-dir: wheelhouse | |
skip-existing: true | |
print-hash: true | |
verbose: true |