-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.39 KB
/
pypi.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
name: Python CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions: write-all
jobs:
build:
# -------- https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
name: Build distribution 📦
runs-on: ubuntu-20.04
steps:
# -------- https://github.com/actions/checkout
# check out your repository files onto the runner, so that the workflow can access them
- uses: actions/checkout@v4
# -------- https://github.com/actions/setup-python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.0"
# --------
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black pytest
pip install -r requirements.txt
# --------
- name: Format with black
run: |
black . --line-length=128
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add: '*.py'
author_name: GitHub Actions
author_email: [email protected]
message: "Formatted code with black."
default_author: github_actor
github_token: ${{ secrets.GITHUB_TOKEN }}
# -------- build --------
- name: Install pypa/build
run: |
python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: |
pip install --upgrade wheel
python -m build
- name: Install twine
run: pip install twine
- name: Check the distribution with twine
run: twine check dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
# -------- pypi --------
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-20.04
environment:
name: pypi
url: https://pypi.org/p/MetricDB
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 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1