-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (65 loc) · 2.26 KB
/
python_publish.yml
File metadata and controls
80 lines (65 loc) · 2.26 KB
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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
name: Upload Python Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
pypi_release_type:
description: "Release to TestPyPI or PyPI (testpypi or pypi)"
required: true
default: "testpypi"
permissions:
contents: read
# Only cancel concurrent runs of the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-publish
cancel-in-progress: true
jobs:
unit_tests:
uses: ./.github/workflows/unit_tests.yml
with:
environment: testing
secrets:
WIKIFIER_API_KEY: ${{ secrets.WIKIFIER_API_KEY }}
static_analysis:
uses: ./.github/workflows/static_analysis.yml
format_check:
uses: ./.github/workflows/black.yml
typo_check:
uses: ./.github/workflows/typo.yml
deploy_to_pypi:
name: Deploy to PyPI
runs-on: ubuntu-latest
needs: [unit_tests, static_analysis, format_check, typo_check]
if: success()
steps:
- uses: actions/checkout@v3.5.2
- name: Set up Python
uses: actions/setup-python@v4.5.0
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
# Default to TestPyPI on workflow_dispatch and release
# So that we can test the release process before publishing to PyPI
# To publish to PyPI, set the pypi_release_type input to 'pypi' (has to be run manually)
- name: Publish to TestPyPI
if: ${{ github.event.inputs.pypi_release_type != 'pypi' }}
uses: pypa/gh-action-pypi-publish@v1.8.3
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Publish to PyPI
if: ${{ github.event.inputs.pypi_release_type == 'pypi' }}
uses: pypa/gh-action-pypi-publish@v1.8.3
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}