1- {% raw %} name: Publish to Production Package Registry
1+ {% raw %} name: Publish to Package Registry
22
33on:
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
611env:
712 PYTHONUNBUFFERED: True
813 PRE_COMMIT_HOME: ${{ github.workspace }}/.precommit_cache
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 %}
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