-
-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (75 loc) · 1.9 KB
/
python-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
name: 'Python Build'
on:
workflow_dispatch:
push:
branches:
- 'dev'
- 'main'
- 'dependabot/**'
- 'feature/**'
- 'issue/**'
- 'release/**'
tags:
- 'v*.*.*'
paths:
- src/**
- tests/**
- setup.py
pull_request:
branches:
- 'dev'
- 'main'
- 'dependabot/**'
- 'feature/**'
- 'issue/**'
- 'release/**'
tags:
- 'v*.*.*'
paths:
- src/**
- tests/**
- setup.py
jobs:
test-build-package:
name: Test & Build Python Package
runs-on: ubuntu-20.04
steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4
# Set up the environment to run Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
# Set up the environment to run the latest Python build, test, and publish tools
- name: Set Up Environment
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools
python3 -m pip install --upgrade wheel
python3 -m pip install --upgrade pytest
python3 -m pip install --upgrade twine
# Install the package from source
- name: Install Source Code
run: |
python3 -m pip install .
# Run the package tests
- name: Test Source Code
run: |
python3 -m pytest -v
# Build the package
- name: Build Package
run: |
python3 -m pip install --upgrade build
python3 -m build
# Check the distribution files with Twine
- name: Check Package
run: |
python3 -m twine check dist/*
# Store the distribution files as artifacts
- name: Upload Package
uses: actions/upload-artifact@v3
with:
name: python-package
path: dist/