-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (88 loc) · 2.91 KB
/
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Builds and publishes to testpypi on every push to main
# On release, publishes to pypi
name: publish
on:
push:
branches:
- main
release:
types: [published]
env:
PYTHON_VERSION: 3.11
POETRY_VERSION: 1.5.1
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry ${{ env.POETRY_VERSION }}
run: python -m pip install poetry==${{ env.POETRY_VERSION }}
- name: Set version with dunamai
uses: mtkennerly/dunamai-action@v1
id: version
with:
command: dunamai from git
args: --no-metadata --style semver
- run: echo ${{ steps.version.outputs.version }}
- run: poetry version ${{ steps.version.outputs.version }}
- name: poetry build
run: poetry build
- uses: actions/upload-artifact@v4
with:
name: poetry_build
path: dist/
publish_test_pypi:
if: github.repository_owner == 'ryankanno'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/download-artifact@v4
with:
name: poetry_build
path: dist/
- name: Install Poetry ${{ env.POETRY_VERSION }}
run: python -m pip install poetry==${{ env.POETRY_VERSION }}
- run: poetry version ${{ needs.build.outputs.version }}
- name: poetry configure TestPyPI Repo
run: poetry config repositories.test-pypi https://test.pypi.org/legacy/
- name: poetry configure TestPyPI Token
run: poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: poetry publish TestPyPi
run: poetry publish -r test-pypi
publish_pypi:
if: github.repository_owner == 'ryankanno' && github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
needs: [build, publish_test_pypi]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/download-artifact@v4
with:
name: poetry_build
path: dist/
- name: Install Poetry ${{ env.POETRY_VERSION }}
run: python -m pip install poetry==${{ env.POETRY_VERSION }}
- run: poetry version ${{ needs.build.outputs.version }}
- name: poetry configure PyPI Token
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: poetry publish PyPi
run: poetry publish