-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (90 loc) · 2.61 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
---
name: Build
on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
branches:
- '*'
defaults:
run:
shell: bash
jobs:
build:
name: Build python package
runs-on: ubuntu-22.04
env:
TZ: UTC
steps:
- name: Checkout the repository
uses: actions/checkout@v4.1.7
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v7
- name: Check code integrity
run: nix develop --command make check
- name: Check docs
run: nix develop --command make docs
- name: Check REUSE compliance
run: nix-shell -p reuse --run "reuse lint"
- name: Build Release Package
run: |
echo "Building package"
nix develop --command make clean build
- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: python-build-artifacts
path: dist/
tests:
name: Test python package
runs-on: ubuntu-22.04
needs: build
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set PIPX_DEFAULT_PYTHON
run: |
echo "PIPX_DEFAULT_PYTHON=$(which python3)" >> $GITHUB_ENV
- name: git checkout
uses: actions/checkout@v4
- name: Fetch python build artifact
uses: actions/download-artifact@v4
with:
name: python-build-artifacts
path: dist/
- name: install
run: |
pip install build
make install
- name: run checks
run: |
make check
- name: run tests
run: |
make tests
release:
runs-on: ubuntu-22.04
needs: [build, tests]
if: github.event_name == 'push' && contains(github.event.ref, '/tags/') && contains(github.event.base_ref, 'main') # Only runs if the original event was a tag
steps:
- name: Checkout the repository
uses: actions/checkout@v3.1.0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v1
- name: Fetch python build artifact
uses: actions/download-artifact@v4
with:
name: python-build-artifacts
path: dist/
- name: Upload Release to PyPI
run: |
echo "Uploading source code"
nix develop --command python -m twine upload --verbose --non-interactive --skip-existing -u '__token__' -p ${{ secrets.PYPI_API_TOKEN }} dist/*