Skip to content

Commit ae283fd

Browse files
authored
[CI] Add the CI to publish to Pypi per GitHub release (#2588)
1 parent f8f246a commit ae283fd

File tree

3 files changed

+58
-90
lines changed

3 files changed

+58
-90
lines changed

.github/linters/zizmor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rules:
2424
docker/setup-qemu-action: any
2525
github/*: any
2626
pypa/cibuildwheel: any
27+
pypa/gh-action-pypi-publish: any
2728
r-lib/actions/check-r-package: any
2829
r-lib/actions/setup-r: any
2930
r-lib/actions/setup-r-dependencies: any

.github/workflows/python-wheel.yml

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
name: Python build wheels
18+
name: Python build and publish wheels
1919

2020
on:
2121
push:
@@ -38,6 +38,9 @@ on:
3838
- 'pom.xml'
3939
- 'python/**'
4040
- '.github/workflows/python-wheel.yml'
41+
release:
42+
types:
43+
- published
4144

4245
permissions:
4346
contents: read
@@ -47,7 +50,8 @@ concurrency:
4750
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
4851

4952
jobs:
50-
build:
53+
build_wheels:
54+
name: Build wheels on ${{ matrix.os }}
5155
strategy:
5256
matrix:
5357
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
@@ -68,7 +72,7 @@ jobs:
6872
image: tonistiigi/binfmt:qemu-v8.1.5
6973
platforms: all
7074
- name: Build wheels
71-
uses: pypa/[email protected].0
75+
uses: pypa/[email protected].1
7276
env:
7377
CIBW_SKIP: 'pp* *musl*'
7478
CIBW_ARCHS_LINUX: 'x86_64 aarch64'
@@ -80,3 +84,48 @@ jobs:
8084
with:
8185
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
8286
path: ./wheelhouse/*.whl
87+
88+
build_sdist:
89+
name: Build source distribution
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v6
93+
with:
94+
persist-credentials: false
95+
96+
- name: Install uv
97+
uses: astral-sh/setup-uv@v4
98+
99+
- name: Build sdist
100+
run: cd python && uv build --sdist
101+
102+
- uses: actions/upload-artifact@v6
103+
with:
104+
name: cibw-sdist
105+
path: python/dist/*.tar.gz
106+
107+
upload_pypi:
108+
needs: [build_wheels, build_sdist]
109+
runs-on: ubuntu-latest
110+
# publish when a GitHub Release is created
111+
if: github.event_name == 'release' && github.event.action == 'published'
112+
environment: pypi
113+
permissions:
114+
id-token: write # IMPORTANT: mandatory for Trusted Publishing
115+
steps:
116+
- uses: actions/download-artifact@v6
117+
with:
118+
# unpacks wheel files into artifacts
119+
pattern: cibw-*
120+
merge-multiple: false
121+
path: artifacts
122+
- name: Copy everything to the dist folder
123+
run: |
124+
mkdir -p dist
125+
for pattern in artifacts/cibw-sdist/* artifacts/cibw-wheels-macos-*/* artifacts/cibw-wheels-ubuntu-*/* artifacts/cibw-wheels-windows-*/*; do
126+
cp -r $pattern dist 2>/dev/null || echo "No files matched $pattern"
127+
done
128+
echo "Content copied to dist."
129+
- name: Publish package to PyPI
130+
uses: pypa/gh-action-pypi-publish@release/v1
131+
# repository_url: https://test.pypi.org/legacy/ # to test

docs/community/publish.md

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -603,93 +603,11 @@ rm apache-sedona-{{ sedona_create_release.current_version }}-bin.tar.gz.sha512
603603
1. Click `Close` on the Sedona staging repo on https://repository.apache.org under `staging repository`
604604
2. Once the staging repo is closed, click `Release` on this repo.
605605

606-
**NOTICE**: The staging repo will be automatically dropped after 3 days without closing. If you find the staging repo being dropped, you can re-stage the release using the following script.
606+
## 9. Release Sedona Python
607607

608-
```bash
609-
#!/bin/bash
610-
611-
echo "Re-staging releases to https://repository.apache.org"
612-
613-
git checkout master
614-
git pull
615-
616-
rm -f release.*
617-
rm -f pom.xml.*
618-
619-
# Function to get Java version for Spark version
620-
get_java_version() {
621-
local spark_version=$1
622-
if [[ "$spark_version" == "4.0" ]]; then
623-
echo "17"
624-
else
625-
echo "11"
626-
fi
627-
}
628-
629-
# Function to set JAVA_HOME based on Java version
630-
set_java_home() {
631-
local java_version=$1
632-
if [[ "$java_version" == "17" ]]; then
633-
# Try to find Java 17 installation
634-
if command -v /usr/libexec/java_home >/dev/null 2>&1; then
635-
export JAVA_HOME=$(/usr/libexec/java_home -v 17 2>/dev/null || /usr/libexec/java_home -v 1.17 2>/dev/null || echo "")
636-
fi
637-
if [[ -z "$JAVA_HOME" ]]; then
638-
echo "Warning: Java 17 not found, using system default"
639-
else
640-
echo "Using Java 17: $JAVA_HOME"
641-
fi
642-
else
643-
# Try to find Java 11 installation
644-
if command -v /usr/libexec/java_home >/dev/null 2>&1; then
645-
export JAVA_HOME=$(/usr/libexec/java_home -v 11 2>/dev/null || /usr/libexec/java_home -v 1.11 2>/dev/null || echo "")
646-
fi
647-
if [[ -z "$JAVA_HOME" ]]; then
648-
echo "Warning: Java 11 not found, using system default"
649-
else
650-
echo "Using Java 11: $JAVA_HOME"
651-
fi
652-
fi
653-
654-
# Verify Java version using Maven
655-
echo "Verifying Java version with Maven..."
656-
local mvn_java_version=$(mvn --version | grep "Java version" | sed 's/.*Java version: \([0-9]*\).*/\1/')
657-
if [[ "$mvn_java_version" != "$java_version" ]]; then
658-
echo "ERROR: Maven is using Java $mvn_java_version, but expected Java $java_version"
659-
echo "Please ensure the correct Java version is installed and JAVA_HOME is set properly"
660-
exit 1
661-
fi
662-
echo "✓ Verified: Maven is using Java $mvn_java_version"
663-
}
664-
665-
# For Spark 3.4 and Scala 2.12 (Java 11)
666-
JAVA_VERSION=$(get_java_version "3.4")
667-
set_java_home $JAVA_VERSION
668-
mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -DconnectionUrl=scm:git:https://github.com/apache/sedona.git -Dtag={{ sedona_create_release.current_git_tag }} -Dresume=false -Darguments="-DskipTests -Dspark=3.4 -Dscala=2.12" -Dspark=3.4 -Dscala=2.12
669-
670-
# For Spark 3.4 and Scala 2.13 (Java 11)
671-
mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -DconnectionUrl=scm:git:https://github.com/apache/sedona.git -Dtag={{ sedona_create_release.current_git_tag }} -Dresume=false -Darguments="-DskipTests -Dspark=3.4 -Dscala=2.13" -Dspark=3.4 -Dscala=2.13
672-
673-
# For Spark 3.5 and Scala 2.12 (Java 11)
674-
JAVA_VERSION=$(get_java_version "3.5")
675-
set_java_home $JAVA_VERSION
676-
mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -DconnectionUrl=scm:git:https://github.com/apache/sedona.git -Dtag={{ sedona_create_release.current_git_tag }} -Dresume=false -Darguments="-DskipTests -Dspark=3.5 -Dscala=2.12" -Dspark=3.5 -Dscala=2.12
677-
678-
# For Spark 3.5 and Scala 2.13 (Java 11)
679-
mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -DconnectionUrl=scm:git:https://github.com/apache/sedona.git -Dtag={{ sedona_create_release.current_git_tag }} -Dresume=false -Darguments="-DskipTests -Dspark=3.5 -Dscala=2.13" -Dspark=3.5 -Dscala=2.13
680-
681-
# For Spark 4.0 and Scala 2.13 (Java 17)
682-
# Note: Spark 4.0 + Scala 2.12 is not supported, so we skip it
683-
JAVA_VERSION=$(get_java_version "4.0")
684-
set_java_home $JAVA_VERSION
685-
mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -DconnectionUrl=scm:git:https://github.com/apache/sedona.git -Dtag={{ sedona_create_release.current_git_tag }} -Dresume=false -Darguments="-DskipTests -Dspark=4.0 -Dscala=2.13" -Dspark=4.0 -Dscala=2.13
686-
```
687-
688-
## 9. Release Sedona Python and Zeppelin
689-
690-
You must have the maintainer privilege of `https://pypi.org/project/apache-sedona/` and `https://www.npmjs.com/package/apache-sedona`
608+
Sedona GitHub CI will automatically publish wheel files to PyPi once a GitHub release is created.
691609

692-
To publish Sedona pythons, you have to use GitHub actions since we release wheels for different platforms. Please use this repo: https://github.com/jiayuasu/sedona-publish-python
610+
## 10. Release Sedona Zeppelin
693611

694612
```bash
695613
#!/bin/bash
@@ -705,7 +623,7 @@ cd apache-sedona-{{ sedona_create_release.current_version }}-src/zeppelin && npm
705623
rm -rf apache-sedona-{{ sedona_create_release.current_version }}-src
706624
```
707625

708-
## 10. Release Sedona R to CRAN.
626+
## 11. Release Sedona R to CRAN.
709627

710628
```bash
711629
#!/bin/bash
@@ -715,7 +633,7 @@ R CMD check --as-cran apache.sedona_*.tar.gz
715633

716634
Then submit to CRAN using this [web form](https://xmpalantir.wu.ac.at/cransubmit/).
717635

718-
## 11. Publish the doc website
636+
## 12. Publish the doc website
719637

720638
1. Check out the {{ sedona_create_release.current_version }} Git tag on your local repo to a branch namely `branch-{{ sedona_create_release.current_version }}`
721639
2. Add the download link to [Download page](../download.md).

0 commit comments

Comments
 (0)