-
Notifications
You must be signed in to change notification settings - Fork 4
140 lines (115 loc) · 4.41 KB
/
macos12_build_test.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
name: macOS-12 Build-Test
on:
push:
branches: [ master ]
tags: 'v*.*.*'
jobs:
build:
runs-on: ${{ matrix.os }}
outputs:
output1: ${{ steps.strings.outputs.build-output-dir }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
os: [macos-latest]
build_type: [Release]
c_compiler: [clang]
cpp_compiler: [clang++]
steps:
- uses: actions/checkout@v4
# Add ssh-key to clone repository cadical
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Install libarchive
run: |
brew install libarchive
shell: bash
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
working-directory: ${{ github.workspace }}
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-S ${{ github.workspace }}
shell: bash
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Run tests
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
ctest --build-config ${{ matrix.build_type }}
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ${{ steps.strings.outputs.build-output-dir }}
publish:
runs-on: macos-latest
needs: build
# Trigger only for releases
if: startsWith(github.ref_name, 'v')
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: true
# '3.8','3.9','3.10' do not build architecture-universal wheels
matrix:
python_version: [ '3.8','3.9','3.10', '3.11','3.12']
archive_lib: [ -L/usr/local/opt/libarchive/lib ]
archive_include: [ -I/usr/local/opt/libarchive/include ]
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifact
path: ${{needs.build.outputs.output1}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"
# Set version = release-tag in setup.py
- name: Change version in setup.py
working-directory: ${{ github.workspace }}
run: |
PYPI_VERSION=$(echo ${{ github.ref_name }} | sed 's/[a-zA-Z]*//g')
sed -i "" "s/version=\"[^\"]*\"/version=\"$PYPI_VERSION\"/" setup.py
shell: bash
- name: Install dependencies
working-directory: ${{ github.workspace }}
shell: bash
run: |
pip install wheel
pip install -U pip setuptools
pip install delocate
brew install libarchive
- name: Python Build
working-directory: ${{ github.workspace }}
shell: bash
run: |
export _PYTHON_HOST_PLATFORM="macosx-12.0-x86_64"
export ARCHFLAGS="-arch x86_64"
export LDFLAGS="${{ matrix.archive_lib }}"
export CPPFLAGS="${{ matrix.archive_include }} -std=c++11"
python3 setup.py bdist_wheel -v
for whl in dist/*.whl; do
delocate-listdeps --all "$whl"
delocate-wheel -v "$whl"
delocate-listdeps --all "$whl"
done
- name: Publish package to PyPI
shell: bash
run: |
pip install twine
export TWINE_USERNAME="__token__"
export TWINE_PASSWORD="${{ secrets.PYPI_API_TOKEN }}"
twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/* --verbose