-
Notifications
You must be signed in to change notification settings - Fork 14
130 lines (121 loc) · 4.64 KB
/
python-package.yml
File metadata and controls
130 lines (121 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# 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", "3.11", "3.12"]
#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@v4.1.7
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@v4.1.7
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 }}'