-
Notifications
You must be signed in to change notification settings - Fork 273
95 lines (83 loc) · 2.53 KB
/
pypi-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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 }}