-
-
Notifications
You must be signed in to change notification settings - Fork 6
138 lines (117 loc) · 3.94 KB
/
build.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
# Runs a build test on commit to ensure functionality.
name: Build
on:
push:
tags:
- "*.*.*"
workflow_run:
workflows: ["Type Coverage and Linting"]
types: [completed]
branches: [main]
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.x"]
name: "Build @ ${{ matrix.python-version }}"
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-0
- name: "Setup Poetry @ ${{ matrix.python-version }}"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
- name: "Setup Python @ ${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: "poetry"
- name: "Load cached venv @ ${{ matrix.python-version }}"
id: cached-pip-wheels
uses: actions/cache@v4
with:
path: .venv/
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: "Install Python deps @ ${{ matrix.python-version }}"
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
id: install-deps
run: |
poetry install --no-interaction
- name: Activate venv @ ${{ matrix.python-version }}
run: |
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
- name: "Check it imports @ ${{ matrix.python-version }}"
run: |
poetry run python -c 'import hondana'
- name: "Test Suite @ ${{ matrix.python-version }}"
run: |
poetry run pytest
- name: "Build wheels @ ${{ matrix.python-version}}"
run: |
poetry build
- name: "Build docs @ ${{ matrix.python-version}}"
run: |
cd docs/
poetry run sphinx-build -aETW --keep-going . build
- name: "Upload artifacts @ ${{ matrix.python-version}}"
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/*
# Credits to most of this step go to Gorialis (Devon R [https://github.com/Gorialis])
# as I found them in their Jishaku builds (https://github.com/Gorialis/jishaku/blob/d3f50749b5a977b544e5fd14894585f656247486/.github/workflows/deploy.yml#L82-L119)
create_release:
name: Create Release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: distributions
path: dist
- name: Create GitHub release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./dist/*.{whl,tar.gz}; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -F "CHANGELOG.md" "$tag_name"
- name: "Set up Poetry"
uses: snok/install-poetry@v1
with:
version: 1.2.0
virtualenvs-create: true
virtualenvs-in-project: false
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish