forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (160 loc) · 5.36 KB
/
bindings.python.yml
File metadata and controls
175 lines (160 loc) · 5.36 KB
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
168
169
170
171
172
173
174
175
name: Python Package Release
on:
workflow_dispatch:
workflow_call:
inputs:
version:
description: Version to release
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
permissions:
id-token: write
pull-requests: write
contents: read
packages: write
jobs:
get-version:
name: Determine Version
if: (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get and validate version
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
echo "Using latest tag for manual trigger: $VERSION"
elif [[ "${{ github.event_name }}" == "workflow_call" && -n "${{ inputs.version }}" ]]; then
VERSION="${{ inputs.version }}"
echo "Using provided version from workflow_call: $VERSION"
else
echo "Error: No version provided for workflow_call"
exit 1
fi
# Validate version format
if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Warning: Version $VERSION may not follow semantic versioning (vX.Y.Z)"
fi
echo "Final version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
test:
name: Run Tests
if: (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
needs: [get-version]
runs-on:
- self-hosted
- X64
- Linux
- 4c
- aws
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/build_bindings_python
with:
target: x86_64-unknown-linux-gnu
# No version means development build with tests
linux:
name: Build Linux Wheels
if: (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
needs: [get-version, test]
runs-on:
- self-hosted
- "${{ matrix.runner }}"
- Linux
- 4c
- aws
strategy:
fail-fast: false
matrix:
include:
- { arch: x86_64, runner: X64 }
- { arch: aarch64, runner: ARM64 }
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/build_bindings_python
with:
target: ${{ matrix.arch }}-unknown-linux-gnu
version: ${{ needs.get-version.outputs.version }}
- name: Upload Linux wheel
uses: actions/upload-artifact@v7
with:
name: python-linux-${{ matrix.arch }}
path: src/bendpy/dist/*.whl
retention-days: 7
macos:
name: Build macOS Wheels
if: (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
needs: [get-version, test]
runs-on: macos-latest
continue-on-error: true
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install dependencies
run: |
# Install OpenSSL and necessary tools
brew install openssl@3
# Use vendored OpenSSL to avoid cross-compilation issues
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
echo "OPENSSL_VENDORED=1" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- uses: ./.github/actions/build_bindings_python
with:
target: ${{ matrix.target }}
version: ${{ needs.get-version.outputs.version }}
- name: Upload macOS wheel
uses: actions/upload-artifact@v7
with:
name: python-macos-${{ matrix.target }}
path: src/bendpy/dist/*.whl
retention-days: 7
publish:
name: Publish to PyPI
if: (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
needs: [get-version, test, linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
pattern: python-*
merge-multiple: true
path: src/bendpy/dist
continue-on-error: true
- name: Show packages to publish
run: |
echo "Publishing packages for version: ${{ needs.get-version.outputs.version }}"
echo "Packages found:"
ls -la src/bendpy/dist/ || echo "No packages found"
echo "Total packages: $(ls src/bendpy/dist/*.whl 2>/dev/null | wc -l)"
- name: Publish to PyPI
timeout-minutes: 10
run: |
pip install twine
echo "Publishing to PyPI..."
if [ -n "$(find src/bendpy/dist -name "*.whl" 2>/dev/null)" ]; then
twine upload --skip-existing --verbose src/bendpy/dist/*.whl
else
echo "No wheel files found to publish"
exit 1
fi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}