-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45a41cf
commit 50ce4e6
Showing
1 changed file
with
107 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,131 @@ | ||
name: BuildAndDeploy | ||
name: Publish Python | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
- '!*dev*' | ||
- '!*pre*' | ||
- '!*post*' | ||
pull_request: | ||
# Allow manual runs through the web UI | ||
workflow_dispatch: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build_sdist: | ||
name: Build SDist | ||
build: | ||
name: Build distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- uses: actions/setup-python@v2 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- run: python -m pip install pep517 | ||
- run: python -m pep517.build --source . | ||
|
||
- uses: actions/upload-artifact@v2 | ||
python-version: "3.12" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: dist/*.tar.gz | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
build_wheels: | ||
name: Wheel on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, windows-latest, macos-latest] | ||
publish-to-pypi: | ||
name: >- | ||
Publish to PyPi | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/ripplemapper | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- uses: actions/setup-python@v2 | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
python-version: '3.10' | ||
name: python-package-distributions | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
path: dist/ | ||
- name: Publish PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
- run: python -m pip install cibuildwheel | ||
github-release: | ||
name: >- | ||
Sign and upload to GH | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
- run: python -m cibuildwheel --output-dir wheelhouse | ||
env: | ||
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* | ||
CIBW_SKIP: "*-musllinux_*" | ||
CIBW_ARCHS: auto64 | ||
CIBW_ENVIRONMENT: 'LW_CI_BUILD=true' | ||
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_ARCHS_MACOS: x86_64 universal2 | ||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
- uses: actions/upload-artifact@v2 | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: wheelhouse/*.whl | ||
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 | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--notes "" | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' | ||
deploy: | ||
needs: [build_sdist, build_wheels] | ||
publish-to-testpypi: | ||
name: Publish test PyPi | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/ripplemapper | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: artifact | ||
path: dist | ||
|
||
- uses: pypa/gh-action-pypi-publish@v1.3.1 | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_token }} | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ |