Skip to content

Commit 0cc14a7

Browse files
authored
Merge pull request #111 from doccano/enhancement/test-pypi-job
Add build workflow
2 parents 781438b + fc49b0d commit 0cc14a7

File tree

2 files changed

+74
-29
lines changed

2 files changed

+74
-29
lines changed

.github/workflows/build.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# The "build" workflow produces wheels (and the sdist) for all python
2+
# versions/platforms. Where possible (i.e. the build is not a cross-compile).
3+
name: Build
4+
5+
on:
6+
push:
7+
branches:
8+
# Run on release branches.
9+
- "branch[0-9]*"
10+
# Also run on certain other branches for testing.
11+
- "build-workflow*"
12+
tags:
13+
- "v*"
14+
15+
env:
16+
python-version: '3.8'
17+
18+
jobs:
19+
build_sdist:
20+
name: Build sdist
21+
runs-on: ubuntu-20.04
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-python@v3
25+
name: Install Python
26+
with:
27+
python-version: ${{ env.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install poetry
32+
poetry install
33+
- name: Build a binary wheel and a source tarball
34+
run: |
35+
poetry build
36+
- uses: actions/upload-artifact@v3
37+
with:
38+
path: ./dist/doccano-client-*
39+
40+
upload_pypi_test:
41+
name: Upload to PyPI (test)
42+
needs: [build_sdist]
43+
runs-on: ubuntu-20.04
44+
if: github.event_name == 'push' && startsWith(github.ref_name, 'build-workflow')
45+
steps:
46+
- uses: actions/download-artifact@v3
47+
with:
48+
name: artifact
49+
path: dist
50+
51+
- uses: pypa/[email protected]
52+
with:
53+
user: __token__
54+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
55+
repository_url: https://test.pypi.org/legacy/
56+
skip_existing: true
57+
58+
upload_pypi:
59+
name: Upload to PyPI (prod)
60+
needs: [build_sdist]
61+
runs-on: ubuntu-20.04
62+
if: github.event_name == 'push' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
63+
steps:
64+
- uses: actions/download-artifact@v3
65+
with:
66+
name: artifact
67+
path: dist
68+
69+
- name: Publish a Python distribution to PyPI
70+
uses: pypa/[email protected]
71+
with:
72+
user: ${{ secrets.PYPI_USERNAME }}
73+
password: ${{ secrets.PYPI_PASSWORD }}
74+
packages_dir: ./dist/

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)