-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (136 loc) · 3.96 KB
/
build-test-publish.yaml
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
name: Build, Test, and Deploy
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
workflow_dispatch:
inputs:
deploy:
description: Deploy if tests successful
required: true
type: boolean
default: false
permissions:
contents: write
jobs:
check-version-txt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Tag with the release version
run: |
git tag $(cat version.txt)
lint-format-and-static-code-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install pre-commit
run: |
pip install pre-commit
- name: Lint, Format, and other static code quality checks
run: |
/bin/bash -x run.sh lint:ci
build-wheel-and-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install build CLI
run: |
pip install build
- name: Build python package
run: |
/bin/bash -x run.sh build
- name: Upload wheel and sdist
uses: actions/upload-artifact@v3
with:
name: wheel-and-sdist
path: ./dist/*
execute-tests:
needs:
- build-wheel-and-sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Download wheel and sdist
uses: actions/download-artifact@v3
with:
name: wheel-and-sdist
path: ./dist/
- name: Install test dependencies
run: |
pip install pytest pytest-cov ./dist/*.whl
- name: Lint, Format, and other static code quality checks
run: |
/bin/bash -x run.sh test:ci
publish:
needs:
- execute-tests
- build-wheel-and-sdist
- lint-format-and-static-code-checks
- check-version-txt
runs-on: ubuntu-latest
# if - this is a merge to main or push directly to the main branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Download wheel and sdist
uses: actions/download-artifact@v3
with:
name: wheel-and-sdist
path: ./dist/
- name: Install twine
run: |
pip install twine
- name: Deploy
# if: ${{ github.event.inputs.deploy == 'true' }}
run: |
# make publish-test
make publish-prod
env:
PROD_PYPI_TOKEN: ${{ secrets.PROD_PYPI_TOKEN }}
- name: Push tags
run: |
git tag $(cat version.txt)
git push origin --tags
# Print variables that are available to the workflow. This is useful for debugging and troubleshooting.
# docs: https://docs.github.com/en/actions/learn-github-actions/contexts#example-printing-context-information-to-the-log
dump-contexts-to-log:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
id: github_context_step
run: echo '${{ toJSON(github) }}'
- name: Dump job context
run: echo '${{ toJSON(job) }}'
- name: Dump steps context
run: echo '${{ toJSON(steps) }}'
- name: Dump runner context
run: echo '${{ toJSON(runner) }}'
- name: Dump strategy context
run: echo '${{ toJSON(strategy) }}'
- name: Dump matrix context
run: echo '${{ toJSON(matrix) }}'
- name: Dump secrets
run: echo '${{ toJSON(secrets) }}'
- name: Dump vars
run: echo '${{ toJSON(vars) }}'