Merge stacklet ARM64 support #11
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
# ref: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
name: CI/CD | |
on: | |
push: | |
branches: [ "*" ] | |
tags: [ "fibers-*" ] | |
pull_request: | |
branches: [ "*" ] | |
tags: [ "fibers-*" ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# would use windows-latest, but distutils tries to build against the version of MSVC that python was compiled with | |
# https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/msvc9compiler.py#L403 | |
os: [ "ubuntu-latest", "macos-12", "windows-2019" ] | |
python-version: ["3.7", "3.8", "3.9", "3.10"] | |
#os: [ "ubuntu-latest" ] | |
#python-version: ["3.8"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --user -r dev-requirements.txt | |
- name: Build Packages | |
run: | | |
python -m build | |
#- name: Lint with flake8 | |
# run: | | |
# # stop the build if there are Python syntax errors or undefined names | |
# flake8 fibers/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
# flake8 fibers --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Install Package | |
working-directory: ./dist | |
run: | | |
# this silly wildcard expansion is because powershell doesn't do it inherently but this syntax works for both bash and powershell | |
python -m pip install -v $(ls *.whl) | |
- name: Verify Version Number | |
## be sure NOT to be in the src root, as we will pick up the fibers/ folder as a module instead of the whl we installed | |
working-directory: ./tests | |
if: startsWith(github.ref, 'refs/tags/fibers-') | |
run: | | |
python verify-version.py '${{ github.ref_name }}' | |
- name: Test with pytest | |
## be sure NOT to be in the src root, as we will pick up the fibers/ folder as a module instead of the whl we installed | |
working-directory: ./tests | |
run: | | |
python -m pytest -v . | |
- name: Store the distribution packages | |
# Note: We *don't* publish wheels for linux because pypi only accepts 'manylinux' arch and GH actions don't seem to make that too easy. | |
# So we'll just let it install from src pkg and build, which is a common practice for linux packages, being that a compiler so often installed. | |
if: runner.os != 'Linux' && startsWith(github.ref, 'refs/tags/fibers-') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: Publish to PyPI (if tag) | |
if: startsWith(github.ref, 'refs/tags/fibers-') # only publish to PyPI on tag pushes | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/fibers | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution packages to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: Create GitHub Release (if tag) | |
needs: | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # IMPORTANT: mandatory for making GitHub Releases | |
id-token: write # IMPORTANT: mandatory for sigstore | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Sign the dists with Sigstore | |
uses: sigstore/gh-action-sigstore-python@v1.2.3 | |
with: | |
inputs: >- | |
./dist/*.tar.gz | |
./dist/*.whl | |
- name: Create GitHub Release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: >- | |
gh release create | |
'${{ github.ref_name }}' | |
--notes "" | |
- name: Upload artifact signatures to GitHub Release | |
env: | |
GH_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 }}' |