Skip to content

Commit 7dcb2db

Browse files
committed
get values
1 parent dd36c64 commit 7dcb2db

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

template/.github/workflows/publish.yaml.jinja

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
{% raw %}name: Publish to Production Package Registry
1+
{% raw %}name: Publish to Package Registry
22

33
on:
44
workflow_dispatch:
5-
5+
inputs:
6+
publish_to_primary:
7+
description: 'Publish to Primary Registry'
8+
type: boolean
9+
required: false
10+
default: false
611
env:
712
PYTHONUNBUFFERED: True
813
PRE_COMMIT_HOME: ${{ github.workspace }}/.precommit_cache
@@ -15,6 +20,8 @@ jobs:
1520
get-values:
1621
name: Get Values
1722
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
23+
outputs:
24+
package-version: ${{ steps.extract-package-version.outputs.package_version }}
1825
steps:
1926
- name: Checkout code
2027
uses: actions/checkout@{% endraw %}{{ gha_checkout }}{% raw %}
@@ -23,6 +30,7 @@ jobs:
2330
with:
2431
python-version: {% endraw %}{{ python_version }}{% raw %}
2532
- name: Extract package version
33+
id: extract-package-version
2634
run: |
2735
VERSION=$(python3 ./.github/workflows/git_tag.py)
2836
echo "Extracted version: $VERSION"
@@ -186,12 +194,13 @@ jobs:
186194
with:
187195
time: 60s{% endraw %}{% endif %}{% raw %}
188196
- name: Install from staging registry
189-
run: pip install -i https://test.pypi.org/simple/ {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package_version }}
197+
run: pip install -i https://test.pypi.org/simple/ {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package-version }}
190198
- name: Confirm library can be imported successfully
191199
run: python -c "import {% endraw %}{{ package_name }}{% raw %}"
192200

193201
create-tag:
194202
name: Create the git tag
203+
if: ${{ github.event.inputs.publish_to_primary }}
195204
needs: [ install-from-staging ]
196205
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
197206
steps:
@@ -208,6 +217,7 @@ jobs:
208217

209218
publish-to-primary:
210219
name: Publish Python distribution to Primary Package Registry
220+
if: ${{ github.event.inputs.publish_to_primary }}
211221
needs: [ create-tag ]
212222
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
213223
environment:
@@ -242,6 +252,7 @@ jobs:
242252

243253
install-from-primary:
244254
name: Install package from primary registry
255+
if: ${{ github.event.inputs.publish_to_primary }}
245256
needs: [ publish-to-primary, get-values ]
246257
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
247258
steps:
@@ -255,6 +266,6 @@ jobs:
255266
with:
256267
time: 60s{% endraw %}{% endif %}{% raw %}
257268
- name: Install from primary registry
258-
run: pip install {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package_version }}
269+
run: pip install {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package-version }}
259270
- name: Confirm library can be imported successfully
260271
run: python -c "import {% endraw %}{{ package_name }}{% raw %}"{% endraw %}

0 commit comments

Comments
 (0)