-
-
Notifications
You must be signed in to change notification settings - Fork 183
149 lines (128 loc) · 4.58 KB
/
deploy.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
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
146
147
148
149
name: Python package
on:
push:
pull_request:
types: [ opened, edited ]
workflow_dispatch:
jobs:
build-dists:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python:
- {version: '3.8'}
- {version: '3.9'}
- {version: '3.10'}
- {version: '3.11'}
- {version: '3.12'}
- {version: '3.13'}
discord-py:
- {NAME: 'pypi', PIP_TARGET: 'discord.py[voice]'}
- {NAME: 'git', PIP_TARGET: 'discord.py[voice] @ git+https://github.com/Rapptz/discord.py@master'}
name: "${{ matrix.os }} CPython ${{ matrix.python.version }} with ${{ matrix.discord-py.NAME }} discord.py"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
# 3.13 needs audioop-lts
pip install -U "audioop-lts; python_version>='3.13'"
pip install -U "${{ matrix.discord-py.PIP_TARGET }}" --extra-index-url https://scarletcafe.github.io/pip/
pip install -U $(find requirements -name *.txt -print | sed -e 's/^/-r /' | tr '\n' ' ')
- name: Test from local directory
shell: bash
run: |
PYTHONPATH="$(pwd)" pytest -vs --cov=jishaku --cov-report term-missing:skip-covered
- name: Lint repository
shell: bash
run: |
echo "flake8:"
flake8 .
echo "pylint:"
pylint jishaku
echo "isort:"
isort . --check-only
- name: Create distributions and install wheel
shell: bash
run: |
export tag_name="${GITHUB_REF##*/}"
# Substitute README assets with direct GitHub links
sed -i'.original' -e "s/src=\".github\/assets/src=\"https:\/\/raw.githubusercontent.com\/scarletcafe\/jishaku\/$(git rev-parse HEAD)\/.github\/assets/g" README.md
rm -f README.md.original
python ./setup.py sdist bdist_wheel
rm -rf jishaku
find dist -name *.whl -exec pip install '{}' +
- name: Test from installed module
shell: bash
run: |
PYTHONPATH="$(pwd)" pytest -vs
- name: Build documentation
shell: bash
run: |
cd docs && make html
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: distributions-${{ matrix.os }}-${{ matrix.python.version }}-${{ matrix.discord-py.NAME }}
path: dist/*
upload_pypi:
needs: [ build-dists ]
runs-on: ubuntu-latest
environment: publish
permissions:
id-token: write
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13' # Watch as I let this get handled as a float again
- name: Install dependencies
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y hub
python -m pip install --upgrade pip setuptools wheel
export tag_name="${GITHUB_REF##*/}"
pip install -U ".[publish]"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
# There is currently a bug where download-artifact downloading multiple files of the same name corrupts the file.
# https://github.com/actions/download-artifact/issues/298
# Very cool.
# We don't have any native code so using the latest Ubuntu artifact should be OK.
#pattern: distributions-*
pattern: distributions-ubuntu-latest-3.13-pypi
merge-multiple: true
path: dist
- name: Publish wheels as release artifacts on GitHub
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
export tag_name="${GITHUB_REF##*/}"
python create_dist_summary.py
assets=()
for asset in ./dist/*.{whl,tar.gz}; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -F ./dist/DIST_SUMMARY.md "$tag_name"
rm ./dist/*.md
- name: Publish packages to PyPI
uses: pypa/[email protected]