-
-
Notifications
You must be signed in to change notification settings - Fork 11
167 lines (148 loc) · 5.4 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build And Publish
on:
push:
branches: [ master ]
paths:
- '.github/workflows/*'
- 'cmake/*'
- 'deps/*'
- 'include/*'
- 'ntgcalls/*'
- 'wrtc/*'
- 'CMakeLists.txt'
- 'setup.py'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
cibw_archs: "native"
shared_name: "linux-x86_64"
cibw_os_build: "manylinux_"
#- os: ubuntu-latest
# cibw_archs: "aarch64"
# shared_name: "linux-arm64"
# cibw_os_build: "manylinux_"
- os: windows-latest
cibw_archs: "native"
shared_name: "windows-x86_64"
- os: macos-13
cibw_archs: "arm64"
cibw_os_build: "macosx_arm64"
shared_name: "macos-arm64"
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Build Debug Shared lib
run: python3 setup.py build_shared --no-preserve-cache --debug
- name: Build Release Shared lib
run: python3 setup.py build_shared --no-preserve-cache
- name: Upload Debug Shared lib for ${{ matrix.shared_name }}
uses: actions/upload-artifact@v3
with:
name: ntgcalls.${{ matrix.shared_name }}-debug-shared_libs
path: ./shared-output-debug/*
if-no-files-found: error
- name: Upload Release Shared lib for ${{ matrix.shared_name }}
uses: actions/upload-artifact@v3
with:
name: ntgcalls.${{ matrix.shared_name }}-shared_libs
path: ./shared-output/*
if-no-files-found: error
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
CIBW_BUILD: cp3*-${{ matrix.cibw_os_build }}*
CIBW_SKIP: cp36-* cp37-*
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_TEST_COMMAND: python -c "from ntgcalls import NTgCalls; NTgCalls().ping()"
- uses: actions/upload-artifact@v3
with:
name: ntgcalls-${{ matrix.shared_name }}-wheels
path: ./wheelhouse/*.whl
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: [build]
permissions:
id-token: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get library Version
id: get-library-version
run: |
VERSION=$(grep -oP -m 1 'ntgcalls VERSION \K[A-Za-z0-9.]+' CMakeLists.txt)
echo "Library Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Patch version number
id: patch-version
run: |
version="${{ steps.get-library-version.outputs.version }}"
if [[ "$version" == *.*.* ]]; then
echo "Version contains three dots"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
tweak=$(echo "$version" | cut -d. -f4)
new_version="${major}.${minor}.${patch}.dev${tweak}"
echo $new_version
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "is_dev=true" >> $GITHUB_OUTPUT
else
echo "Version does not contain three dots"
echo "new_version=${{ steps.get-library-version.outputs.version }}" >> $GITHUB_OUTPUT
echo "is_dev=false" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: tmp/
- name: Prepare source distribution
run: |
python3 -m pip install --upgrade setuptools
python3 setup.py sdist
- name: Zip releases
run: |
mkdir releases
for dir in tmp/*shared_libs; do
if [ -d "$dir" ]; then
echo "$dir"
folder_name=$(basename "$dir" .zip)
(cd $dir && zip -r "../../releases/${folder_name}.zip" *)
fi
done
- name: Create Release
id: create-new-release
uses: softprops/action-gh-release@v1
with:
files: |
./releases/*
tag_name: "v${{ steps.patch-version.outputs.new_version }}"
name: "NTgCalls auto build v${{ steps.patch-version.outputs.new_version }}"
body: "These are the build files for the commit [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}).\nThese files were built during [this workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
prerelease: ${{ steps.patch-version.outputs.is_dev }}
- name: Extract artifacts
run: find tmp -type f -name "*.whl" | xargs -I {} mv {} dist
- name: Publish a Python distribution to PyPI.
if: github.ref == 'refs/heads/master' && github.repository == 'pytgcalls/ntgcalls'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
packages-dir: dist/