-
Notifications
You must be signed in to change notification settings - Fork 6
101 lines (86 loc) · 3.36 KB
/
upload-to-testpypi.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
96
97
98
99
100
101
# This is a basic workflow to help you get started with Actions
name: Publish to TestPyPI and PyPI
# Controls when the action will run.
on:
# Triggers the workflow on push to the master branch
#push:
# branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: Build Python 🐍 distributions to 📦
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# with:
# fetch-depth: 0
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
# Installs and upgrades pip, installs other dependencies and installs the package from pyproject.toml
- name: Installs and upgrades pip and installs other dependencies
run: |
# Upgrade pip
python3 -m pip install --upgrade pip
# Install build deps
python3 -m pip install -U build
# If requirements.txt exists, install from it
python3 -m pip install -r requirements.txt
- name: Builds the package
run: |
# Install package with build
python3 -m build
- name: Store wheel artifacts
uses: actions/upload-artifact@v2
with:
name: wheel-${{ runner.os }}-${{ runner.python-version }}
path: dist/*
publish:
name: Publish 📦 to PyPI and TestPyPI
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- name: Download wheel artifacts
uses: actions/download-artifact@v2
with:
name: wheel-${{ runner.os }}-${{ runner.python-version }}
path: dist/
- name: Store aggregated wheel artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist/*
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check to TestPyPI
run: |
python3 -m pip install -U twine
# Check twine in advance even though gh-action-pypi also does that
twine check dist/*
# Upload to TestPyPI
- name: Publish package to TestPyPI 📦
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TWINE_TEST_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI 📦
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true