Skip to content

Commit 4674619

Browse files
authored
Merge pull request #3 from caiyunapp/ci/cross-platform
ci: test across platform
2 parents 2fb7363 + 2e08959 commit 4674619

3 files changed

Lines changed: 327 additions & 52 deletions

File tree

.github/workflows/release.yml

Lines changed: 157 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,41 @@ on:
1212
type: string
1313

1414
jobs:
15-
test:
16-
uses: ./.github/workflows/test.yml
17-
18-
build:
19-
needs: test
15+
extract-version:
2016
runs-on: ubuntu-latest
21-
container:
22-
image: python:3.12-bookworm
17+
outputs:
18+
version: ${{ steps.version.outputs.version }}
19+
version_number: ${{ steps.version.outputs.version_number }}
20+
steps:
21+
- name: Extract version from tag
22+
id: version
23+
run: |
24+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
25+
VERSION=${{ inputs.tag }}
26+
else
27+
VERSION=${GITHUB_REF#refs/tags/}
28+
fi
29+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
30+
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
31+
32+
linux-build:
33+
needs: [extract-version]
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
include:
38+
- os: ubuntu-latest
39+
container: python:3.12-bookworm
40+
platform: linux_x86_64
41+
arch: x86_64
42+
arch_label: x86_64
43+
- os: ubuntu-24.04-arm
44+
container: python:3.12-bookworm
45+
platform: linux_aarch64
46+
arch: arm64
47+
arch_label: arm64
48+
runs-on: ${{ matrix.os }}
49+
container: ${{ matrix.container }}
2350
env:
2451
UV_LINK_MODE: copy
2552
UV_CACHE_DIR: /github/home/.cache/uv
@@ -37,30 +64,20 @@ jobs:
3764
uses: actions/cache@v5
3865
with:
3966
path: /github/home/.cache/uv
40-
key: uvcache-${{ runner.os }}-${{ hashFiles('uv.lock', 'pyproject.toml') }}
67+
key: uvcache-${{ runner.os }}-${{ matrix.arch_label }}-${{ hashFiles('uv.lock', 'pyproject.toml') }}
4168
restore-keys: |
42-
uvcache-${{ runner.os }}-
43-
44-
- name: Extract version from tag
45-
id: version
46-
run: |
47-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
48-
VERSION=${{ inputs.tag }}
49-
else
50-
VERSION=${GITHUB_REF#refs/tags/}
51-
fi
52-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
53-
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
69+
uvcache-${{ runner.os }}-${{ matrix.arch_label }}-
5470
5571
- name: Add Debian sid repository
72+
if: matrix.container != null
5673
run: |
5774
echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
5875
echo 'Package: *\nPin: release a=sid\nPin-Priority: 100' > /etc/apt/preferences.d/sid
5976
60-
- name: Install system dependencies
77+
- name: Install system dependencies (Linux)
78+
if: matrix.container != null
6179
run: |
6280
apt-get update
63-
# Ensure /etc/os-release exists (required by some actions' OS detection).
6481
apt-get install -y base-files
6582
apt-get install -y build-essential pkg-config libbz2-dev
6683
apt-get install -y -t sid libmapnik-dev
@@ -70,51 +87,149 @@ jobs:
7087
with:
7188
enable-cache: false
7289

90+
- name: Update version from tag
91+
run: |
92+
# Extract base version from pyproject.toml
93+
BASE_VERSION=$(grep -E '^version = ' pyproject.toml | sed -E 's/^version = "([^"]+)"/\1/')
94+
TAG=${{ needs.extract-version.outputs.version }}
95+
VERSION="${BASE_VERSION}-${TAG}"
96+
echo "Base version from pyproject.toml: $BASE_VERSION"
97+
echo "Git tag: $TAG"
98+
echo "Setting version to: $VERSION"
99+
# Update pyproject.toml
100+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
101+
# Update setup.py
102+
sed -i "s/version=\"[^\"]*\"/version=\"$VERSION\"/" setup.py
103+
# Verify changes
104+
echo "pyproject.toml version:"
105+
grep "^version = " pyproject.toml
106+
echo "setup.py version:"
107+
grep "version=" setup.py | head -1
108+
73109
- name: Build wheel and sdist
74110
run: |
75111
uv build --wheel --sdist
76112
77113
- name: Upload build artifacts
78114
uses: actions/upload-artifact@v4
79115
with:
80-
name: dist
116+
name: dist-${{ matrix.platform }}
81117
path: dist/
82118
retention-days: 7
83119

120+
# macos-build:
121+
# needs: [extract-version]
122+
# strategy:
123+
# fail-fast: false
124+
# matrix:
125+
# include:
126+
# - os: macos-15-intel
127+
# platform: macosx_10_9_x86_64
128+
# arch: x86_64
129+
# arch_label: x86_64
130+
# - os: macos-15
131+
# platform: macosx_15_0_arm64
132+
# arch: arm64
133+
# arch_label: arm64
134+
# runs-on: ${{ matrix.os }}
135+
# env:
136+
# UV_LINK_MODE: copy
137+
# UV_CACHE_DIR: /Users/runner/.cache/uv
138+
# permissions:
139+
# actions: write
140+
# contents: write
141+
142+
# steps:
143+
# - name: Checkout code
144+
# uses: actions/checkout@v6
145+
# with:
146+
# submodules: recursive
147+
148+
# - name: Cache uv downloads
149+
# uses: actions/cache@v5
150+
# with:
151+
# path: /Users/runner/.cache/uv
152+
# key: uvcache-${{ runner.os }}-${{ matrix.arch_label }}-${{ hashFiles('uv.lock', 'pyproject.toml') }}
153+
# restore-keys: |
154+
# uvcache-${{ runner.os }}-${{ matrix.arch_label }}-
155+
156+
# - name: Install and cache Homebrew tools
157+
# uses: tecolicom/actions-use-homebrew-tools@v1
158+
# with:
159+
# tools: mapnik icu4c pkg-config
160+
# key: mapnik-${{ matrix.arch_label }}
161+
162+
# - name: Install uv
163+
# uses: astral-sh/setup-uv@v7
164+
# with:
165+
# enable-cache: false
166+
167+
# - name: Build wheel and sdist
168+
# run: |
169+
# uv build --wheel --sdist
170+
171+
# - name: Upload build artifacts
172+
# uses: actions/upload-artifact@v4
173+
# with:
174+
# name: dist-${{ matrix.platform }}
175+
# path: dist/
176+
# retention-days: 7
177+
178+
release:
179+
needs:
180+
- extract-version
181+
- linux-build
182+
# - macos-build
183+
runs-on: ubuntu-latest
184+
permissions:
185+
contents: write
186+
if: github.event_name == 'push'
187+
188+
steps:
189+
- name: Download all artifacts
190+
uses: actions/download-artifact@v4
191+
with:
192+
path: dist-all
193+
194+
- name: Combine artifacts
195+
run: |
196+
mkdir -p dist
197+
find dist-all -name "*.whl" -exec cp {} dist/ \;
198+
find dist-all -name "*.tar.gz" -exec head -1 {} \; | head -1 | xargs -I {} find dist-all -name "{}" -exec cp {} dist/ \;
199+
84200
- name: Create GitHub Release
85201
uses: softprops/action-gh-release@v2
86-
if: github.event_name == 'push'
87202
with:
88-
tag_name: ${{ steps.version.outputs.version }}
89-
name: Release ${{ steps.version.outputs.version }}
203+
tag_name: ${{ needs.extract-version.outputs.version }}
204+
name: Release ${{ needs.extract-version.outputs.version }}
90205
body: |
91-
## Python Mapnik ${{ steps.version.outputs.version_number }}
206+
## Python Mapnik ${{ needs.extract-version.outputs.version_number }}
92207
93208
### Installation
94209
95-
Download the wheel file below and install:
210+
Download the wheel file for your platform and install:
96211
```bash
97-
pip install mapnik-${{ steps.version.outputs.version_number }}-*.whl
212+
pip install mapnik-${{ needs.extract-version.outputs.version_number }}-*.whl
98213
```
99214
100-
Or install directly from GitHub:
215+
Or install directly from GitHub (replace platform tag as needed):
101216
```bash
102-
pip install https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/mapnik-${{ steps.version.outputs.version_number }}-cp312-cp312-linux_x86_64.whl
217+
pip install https://github.com/${{ github.repository }}/releases/download/${{ needs.extract-version.outputs.version }}/mapnik-${{ needs.extract-version.outputs.version_number }}-cp312-cp312-linux_x86_64.whl
103218
```
104219
105220
Or install from source:
106221
```bash
107-
pip install git+https://github.com/${{ github.repository }}.git@${{ steps.version.outputs.version }}
222+
pip install git+https://github.com/${{ github.repository }}.git@${{ needs.extract-version.outputs.version }}
108223
```
109224
110225
### Requirements
111226
112-
- Python >= 3.8
113-
- Mapnik >= 4.0.0
227+
- Python >= 3.12
228+
- Mapnik >= 4.2.0
114229
115230
### Changes
116231
117-
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ steps.version.outputs.version }}/CHANGELOG.md) for details.
232+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ needs.extract-version.outputs.version }}/CHANGELOG.md) for details.
118233
files: |
119234
dist/*.whl
120235
dist/*.tar.gz
@@ -127,10 +242,16 @@ jobs:
127242
run: |
128243
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
129244
echo "" >> $GITHUB_STEP_SUMMARY
130-
echo "✅ Released version: **${{ steps.version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY
245+
echo "✅ Released version: **${{ needs.extract-version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY
131246
echo "" >> $GITHUB_STEP_SUMMARY
132247
echo "### Artifacts Built:" >> $GITHUB_STEP_SUMMARY
133248
ls -lh dist/ >> $GITHUB_STEP_SUMMARY
134249
echo "" >> $GITHUB_STEP_SUMMARY
250+
echo "### Supported Platforms:" >> $GITHUB_STEP_SUMMARY
251+
echo "- Linux x86_64: ✅" >> $GITHUB_STEP_SUMMARY
252+
echo "- Linux arm64: ✅" >> $GITHUB_STEP_SUMMARY
253+
# echo "- macOS x86_64: ✅" >> $GITHUB_STEP_SUMMARY
254+
# echo "- macOS arm64: ✅" >> $GITHUB_STEP_SUMMARY
255+
echo "" >> $GITHUB_STEP_SUMMARY
135256
echo "### Distribution:" >> $GITHUB_STEP_SUMMARY
136257
echo "- GitHub Release: ✅" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)