Skip to content

Commit e41abc9

Browse files
committed
add configurable workflow dispatch to release - also only trigger on tag pushes prefixed with v
1 parent 70c9c69 commit e41abc9

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/release.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@
55

66
name: Publish to PyPI
77

8-
on: push
9-
8+
on:
9+
push:
10+
tags:
11+
- 'v*' # only publish on version tags (e.g. v1.0.0)
12+
workflow_dispatch:
13+
inputs:
14+
pypi:
15+
description: 'Publish to PyPi'
16+
required: true
17+
default: false
18+
type: boolean
19+
github:
20+
description: 'Publish a GitHub Release'
21+
required: true
22+
default: false
23+
type: boolean
24+
testpypi:
25+
description: 'Publish to TestPyPi'
26+
required: true
27+
default: true
28+
type: boolean
29+
1030
env:
1131
PYPI_URL: https://pypi.org/p/django-typer
1232
PYPI_TEST_URL: https://test.pypi.org/project/django-typer
@@ -38,6 +58,8 @@ jobs:
3858
publish-to-pypi:
3959
name: >-
4060
Publish Python 🐍 distribution 📦 to PyPI
61+
if: startsWith(github.ref, 'refs/tags/') # only publish on tag pushes
62+
#if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pypi == 'true') || github.event_name != 'workflow_dispatch' }}
4163
needs:
4264
- build
4365
runs-on: ubuntu-latest
@@ -59,6 +81,7 @@ jobs:
5981
name: >-
6082
Sign the Python 🐍 distribution 📦 with Sigstore
6183
and upload them to GitHub Release
84+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.github == 'true') || github.event_name != 'workflow_dispatch' }}
6285
needs:
6386
- publish-to-pypi
6487
runs-on: ubuntu-latest
@@ -100,6 +123,7 @@ jobs:
100123
101124
publish-to-testpypi:
102125
name: Publish Python 🐍 distribution 📦 to TestPyPI
126+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.testpypi == 'true') || github.event_name != 'workflow_dispatch' }}
103127
needs:
104128
- build
105129
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)