Skip to content

Publish to PyPI

Publish to PyPI #14

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
# 수동 트리거 시 wheel 빌드만 검증하고 실제 업로드는 skip (dry-run)
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
verify-version:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check Cargo.toml version matches release tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(python -c "
import re
with open('Cargo.toml') as f:
match = re.search(r'^version\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)
print(match.group(1))
")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "ERROR: Tag version ($TAG_VERSION) != Cargo.toml version ($PKG_VERSION)"
exit 1
fi
echo "Version check passed: $TAG_VERSION"
build-linux:
name: Build Linux wheel (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64
runner: ubuntu-latest
- target: aarch64
runner: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
command: build
args: --release --out dist
before-script-linux: |
if command -v yum >/dev/null 2>&1; then
yum install -y freetype-devel fontconfig-devel
elif command -v dnf >/dev/null 2>&1; then
dnf install -y freetype-devel fontconfig-devel
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y libfreetype6-dev libfontconfig1-dev
fi
- uses: actions/upload-artifact@v7
with:
name: wheels-linux-${{ matrix.target }}
path: dist/*.whl
build-macos:
name: Build macOS wheel (${{ matrix.target }})
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
command: build
args: --release --out dist
- uses: actions/upload-artifact@v7
with:
name: wheels-macos-${{ matrix.target }}
path: dist/*.whl
build-windows:
name: Build Windows wheel
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist
- uses: actions/upload-artifact@v7
with:
name: wheels-windows
path: dist/*.whl
sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz
publish:
# 실 PyPI 업로드는 release 이벤트일 때만. workflow_dispatch 에서는 skip (dry-run).
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [verify-version, build-linux, build-macos, build-windows, sdist]
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1