-
Notifications
You must be signed in to change notification settings - Fork 29
161 lines (149 loc) · 4.53 KB
/
build.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: build
run-name: Build Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [published]
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python:
- "3.11"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python }}
- name: Setup pipx for build tool isolation
run: |
pip install --user pipx
pipx ensurepath
- name: Set up poetry and install dependencies
run: |
pipx install --python '${{ steps.setup-python.outputs.python-path }}' poetry
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
poetry install --with dev
- name: Run pre-commit checks
run: |
poetry run poe pre-commit
- name: Run static type checks
continue-on-error: true
run: |
poetry run poe type-check
- name: Run tests
run: |
poetry run poe test -v
- name: Build wheel and sdist for distribution
run: |
pipx install --python '${{ steps.setup-python.outputs.python-path }}' build
pyproject-build
- name: Check distribution with twine
run: |
pipx install --python '${{ steps.setup-python.outputs.python-path }}' twine
twine check --strict dist/*
- name: Store the distribution files
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: python-package-distributions
path: dist/
- name: Build documentation artifacts
run: |
poetry run poe build-docs
- name: Zip documentation
if: matrix.os == 'ubuntu-latest'
run: |
DOCS_VERSION=`poetry version -s`
mkdir _build_docs/dist
pushd _build_docs/_build/html
zip -r ../../dist/sammo-docs-$DOCS_VERSION.zip .
popd
- name: Store the documentation artifacts for GitHub Pages
uses: actions/upload-pages-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
path: _build_docs/_build/html
- name: Store the zipped documentation
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: zipped-documentation
path: _build_docs/dist/
release-publish-artifacts:
name: Publish Artifacts
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
defaults:
run:
shell: bash
environment:
name: pypi
url: https://pypi.org/p/sammo
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
contents: write # Allow artifacts to be uploaded to release on GH
steps:
- name: Download the distribution artifacts
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Download zipped documentation
uses: actions/download-artifact@v3
with:
name: zipped-documentation
path: dist/
- name: Generate SHA256 checksums for all artifacts
run: |
sha256sum dist/*.whl > checksums.txt
sha256sum dist/*.tar.gz >> checksums.txt
sha256sum dist/*.zip >> checksums.txt
cat checksums.txt
- name: Update release with SHA256 and Artifacts
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
dist/*
checksums.txt
release-publish-pages:
name: Publish Documentation Site
runs-on: ubuntu-latest
needs: release-publish-artifacts
if: github.event_name == 'release'
defaults:
run:
shell: bash
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4