Skip to content

Build and publish

Build and publish #19

Workflow file for this run

name: Build and publish
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
jobs:
build_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
archs: x86_64
- os: macos-latest
archs: x86_64 arm64
- os: ubuntu-latest
archs: aarch64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Set up QEMU to build non-native architectures
if: ${{ matrix.archs == 'aarch64' }}
uses: docker/setup-qemu-action@v3
- name: Install required Python packages
run: |
python -m pip install --upgrade pip setuptools wheel cython
python -m pip install 'cibuildwheel>=2.2.0' twine
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
env:
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_SKIP: |
cp38-musllinux_*
pp38-*
pp*-manylinux_i686
${{ matrix.archs == 'aarch64' && 'pp*' }}
- name: Check packages
run: twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: "packages-${{ matrix.os }}-${{ matrix.archs }}"
path: dist/
build_sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install required Python packages
run: |
python -m pip install --upgrade pip setuptools wheel cython numpy
python -m pip install build twine
- name: Build sdist
run: |
python setup.py sdist
python -m venv test_venv
. test_venv/bin/activate
python -m pip install dist/*.tar.gz
python -c 'import wordllama; print(wordllama.__version__); \
from wordllama import WordLlama, Config, WordLlamaConfig; \
wl = WordLlama.load(); \
similarity_score = wl.similarity("i went to the car", "i went to the pawn shop"); \
print(similarity_score);'
- name: Check packages
run: twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: packages-sdist
path: dist/
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
pattern: packages-*
- name: Display structure of downloaded files
run: ls -R dist/
- name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'dleemiller'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}