-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (58 loc) · 1.96 KB
/
build-package.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
on:
release:
types: [published]
name: Create package and attach to GitHub release on release publish
jobs:
build-package:
name: Create release-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
# cache: 'pip'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade packaging setuptools flit build
- name: Check package version (compare package version with tag)
id: check_package_version
shell: python
run: |
import pathlib, tempfile
from packaging.version import parse
from flit.wheel import WheelBuilder
with tempfile.TemporaryFile() as tmp_fp:
package_version = WheelBuilder.from_ini_path(pathlib.Path('pyproject.toml'), tmp_fp).metadata.version
if parse(package_version) != parse('${{ github.event.release.tag_name }}'):
print(f'version mismatch: {package_version} (package) vs ${{ github.event.release.tag_name }} (tag)')
exit(1)
- name: Build wheel
run: |
python -m build --wheel
- name: Update release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
allowUpdates: true
- name: Push to private PyPi repo
run: |
pip install twine
twine upload \
--repository-url http://algeciras.anfema.net:8200/upload/ \
-u __token__ \
-p ${{ secrets.PRIVATE_PYPI_TOKEN }} \
--non-interactive \
--verbose \
dist/*
- name: Push to PyPi
run: |
twine upload \
-u __token__ \
-p ${{ secrets.PYPI_TOKEN }} \
--non-interactive \
--verbose \
dist/*