-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 2.27 KB
/
ci-cd.yml
File metadata and controls
67 lines (56 loc) · 2.27 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
name: CI-CD # CI/CD workflow
on:
push:
branches: [ "main" ] # Trigger on pushes to 'main'
tags: [ "*" ] # Trigger on version tags like v1.0.0
pull_request:
branches: [ "main" ] # Trigger on PRs targeting 'main'
jobs:
build-test: # Our first job for building and testing
runs-on: ubuntu-latest
steps:
- name: Check out code # Check out your repository
uses: actions/checkout@v3
- name: Set up Python # Install desired Python version
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Editable install of your package so your code in src/
# is recognized as a Python package
pip install -e .
# If you have additional dev/test dependencies,
# either put them in setup.py or:
# pip install -r requirements.txt
- name: Run tests
run: |
# Use python -m pytest to ensure we use the same Python interpreter
python -m pytest tests/
deploy: # Second job for "CD" or deployment
needs: [ build-test ] # Only run if 'build-test' succeeds
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Build distribution
run: |
python -m pip install --upgrade pip
pip install build twine # Tools needed to build & upload your package
python -m build # Creates dist/*.whl and dist/*.tar.gz
- name: Publish to PyPI
# Sample checks if the push is a tagged release.
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
# By default, this will push to PyPI.
# For TestPyPI, pass --repository-url or set env var:
# python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
python -m twine upload dist/*