Skip to content

Use "build" instead of setup.py + add "[cd build]" build trigger word #52

Use "build" instead of setup.py + add "[cd build]" build trigger word

Use "build" instead of setup.py + add "[cd build]" build trigger word #52

Workflow file for this run

# SPDX-FileCopyrightText: 2016-2024 PyThaiNLP Project
# SPDX-License-Identifier: CC0-1.0
name: Build and publish to PyPI
on:
push:
branches:
- dev
pull_request:
branches:
- dev
release:
types: [published]
jobs:
echo_github_env:
name: Echo env variables
runs-on: ubuntu-latest
steps:
- run: |
echo "github.event.action : ${{ github.event.action }}"
echo "github.event_name : ${{ github.event_name }}"
echo "github.ref : ${{ github.ref }}"
echo "github.ref_type : ${{ github.ref_type }}"
echo "github.event.ref : ${{ github.event.ref }}"
# Check whether to build the wheels and the source tarball
check_build_trigger:
name: Check build trigger
runs-on: ubuntu-latest
# Not for forks
if: github.repository == 'pythainlp/pythainlp'
outputs:
build: ${{ steps.check_build_trigger.outputs.build }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: check_build_trigger
name: Check build trigger
run: bash build_tools/github/check_build_trigger.sh
# To trigger the build steps, add "[cd build]" to commit message
build:
name: Build and check distributions
needs: [check_build_trigger]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade build pip twine
- name: Build source distribution and wheels
run: python -m build
- name: Check distributions
run: twine check dist/*
- name: Store distributions
uses: actions/upload-artifact@v3
with:
path: pythainlp/dist/*
publish_pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Retrieve distributions
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
skip-existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}