-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (43 loc) · 1.78 KB
/
publish.yaml
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
name: Publish to PyPi
run-name: Publish ${{github.ref_name}} to PyPi by @${{ github.actor }}
on: workflow_dispatch
jobs:
release_to_pypi:
name: Release distribution to Pypi
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.9.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install and Configure Poetry and Prepare Publish
run: |
set -e
curl -sSL https://install.python-poetry.org | python3 -
version=$(git describe --tags --abbrev=7)
sed -i "s/version = \"0.0.0\"/version = \"${version:1}\"/" pyproject.toml
echo "__version__ = '${version:1}'" > ./adapta/_version.py
- name: Configure Test PyPi
if: ${{ github.ref == 'refs/heads/main' }}
env:
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: |
set -e
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi $PYPI_TEST_TOKEN
- name: Publish distribution 📦 to test PyPI
if: ${{ github.ref == 'refs/heads/main' }}
run: |
set -e
poetry build && poetry publish -r test-pypi
- name: Publish distribution 📦 to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
if: ${{ startsWith(github.ref, 'refs/tags') }}
run: |
set -e
poetry build && poetry publish