-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (149 loc) · 5.29 KB
/
release-python.yml
File metadata and controls
174 lines (149 loc) · 5.29 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
name: Build and Publish python version
on:
push:
branches:
- main
# tags:
# - "v*.*.*" # Optional: only run on version tags
# pull_request:
# branches:
# - main
jobs:
create-dist:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
# - name: Create source distribution
# uses: PyO3/maturin-action@v1
# with:
# command: sdist
# args: >
# --manifest-path Cargo.toml
# --out dist
- name: Build with maturin
run: |
python -m pip install --upgrade pip
pip install --upgrade maturin==1.8.7
maturin sdist --manifest-path Cargo.toml --out dist
- name: Inspect Source Distribution
run: |
for file in dist/*.tar.gz; do
echo "Inspecting $file"
tar --wildcards -tzf "$file" | grep PKG-INFO || echo "PKG-INFO not found"
tar --wildcards -xOf "$file" */PKG-INFO || echo "Unable to read PKG-INFO"
done
- name: Test sdist
run: |
python -m pip install --upgrade pip
pip install --upgrade --force-reinstall twine
twine check dist/*.tar.gz
pip install --force-reinstall --verbose dist/*.tar.gz
python -c 'from polodb import PoloDB'
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build:
runs-on: ${{ matrix.os }}
needs: create-dist
strategy:
matrix:
os: [ubuntu-latest, macos-14, macos-latest, windows-latest]
# os: [macos-14]
python-version: ["3.9", "3.10", "3.11"] # , "3.10"
architecture: [x86_64, aarch64] # Explicitly define architectures
# architecture: [aarch64] # Explicitly define architectures
exclude:
- os: windows-latest
architecture: aarch64
- os: macos-latest
architecture: aarch64 # macOS 13 on GitHub Actions is only x86_64 (Intel)
- os: macos-14
architecture: x86_64
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Create source distribution
# uses: PyO3/maturin-action@v1
# with:
# command: build
# args: >
# --manifest-path Cargo.toml
# --profile dist-release
# --out target/wheels
- name: Create source distribution
run: |
python -m pip install --upgrade pip
pip install --upgrade maturin==1.8.7
maturin build --manifest-path Cargo.toml --profile dist-release --out target/wheels
- name: Extract Version from pyproject.toml
id: get_version
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
VERSION=$(grep -m 1 version pyproject.toml | sed 's/.*version *= *"*\([^"]*\)"*/\1/')
else
VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Print Version
run: |
echo "The current version is ${{ env.VERSION }}"
- name: Upload Artifact with OS and Architecture Tags
uses: actions/upload-artifact@v4
with:
name: polodb_python-${{env.VERSION}}-${{ matrix.os }}-${{ matrix.architecture }}-python${{matrix.python-version}}
path: target/wheels/*
publish:
needs: build # Ensure it runs after build job
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
# - name: Download Artifacts
# uses: actions/download-artifact@v4
# with:
# name: sdist
# path: dist # Download to dist/ directory
- name: Download Wheel Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Inspect Generated PKG-INFO
run: |
for file in artifacts/**/*.tar.gz; do
echo "Inspecting $file"
tar -tzf "$file" | grep PKG-INFO || echo "PKG-INFO not found"
tar -xOf "$file" */PKG-INFO || echo "Unable to read PKG-INFO"
done
- name: Install Twine
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel twine maturin
- name: Upload to PyPI with Twine
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
ls -R artifacts/
pip install --upgrade --force-reinstall twine
twine check artifacts/**/*.tar.gz
twine upload artifacts/**/*.tar.gz || echo "Failed to upload artifacts/**/*.tar.gz "
twine check artifacts/**/*.whl
for file in artifacts/**/*.whl; do
if [[ -f "$file" ]]; then
echo "Uploading $file..."
twine upload "$file" || echo "Failed to upload $file"
fi
done
# twine upload artifacts/**/*.whl