Skip to content

Commit 4f7a6b3

Browse files
committed
echo
1 parent 3b6b7f1 commit 4f7a6b3

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

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

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ jobs:
160160
. .devcontainer/code-artifact-auth.sh
161161
uv publish --verbose --index code-artifact-primary --username aws --password "$TWINE_PASSWORD"
162162

163-
{% endraw %}{% endif %}{% raw %}
164-
- name: Publish distribution to PyPI
163+
{% endraw %}{% else %}{% raw %}
164+
- name: Publish distribution to Test PyPI
165165
uses: pypa/gh-action-pypi-publish@v1.12.4
166166
with:
167167
attestations: false
168168
repository-url: https://test.pypi.org/legacy/
169+
{% endraw %}{% endif %}{% raw %}
170+
169171

170172
install-from-staging:
171173
name: Install package from staging registry
@@ -178,7 +180,7 @@ jobs:
178180
python-version: {% endraw %}{{ python_version }}{% raw %}
179181
- name: Install from staging registry
180182
run: pip install -i https://test.pypi.org/simple/ {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package_version }}
181-
- name: Confirm library can be importde successfully
183+
- name: Confirm library can be imported successfully
182184
run: python -c "import {% endraw %}{{ package_name }}{% raw %}"
183185

184186
create-tag:
@@ -195,4 +197,52 @@ jobs:
195197
- name: Confirm tag not already present
196198
run: python3 ./.github/workflows/git_tag.py --confirm-tag-not-present
197199
- name: Create tag
198-
run: python3 ./.github/workflows/git_tag.py --push-tag-to-remote{% endraw %}
200+
run: python3 ./.github/workflows/git_tag.py --push-tag-to-remote
201+
202+
publish-to-primary:
203+
name: Publish Python distribution to Primary Package Registry
204+
needs: [ build ]
205+
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
206+
environment:
207+
name: pypi
208+
url: https://pypi.org/p/{% endraw %}{{ package_name | replace('_', '-') }}{% raw %}
209+
permissions:
210+
attestations: write
211+
id-token: write
212+
steps:
213+
- name: Download all the dists
214+
uses: actions/download-artifact@{% endraw %}{{ gha_download_artifact }}{% raw %}
215+
with:
216+
name: python-package-distributions
217+
path: dist/
218+
{% endraw %}{% if python_package_registry == "AWS CodeArtifact" %}{% raw %}
219+
- name: OIDC Auth for Publishing to CodeArtifact
220+
uses: aws-actions/configure-aws-credentials@{% endraw %}{{ gha_configure_aws_credentials }}{% raw %}
221+
with:
222+
role-to-assume: arn:aws:iam::{% endraw %}{{ aws_central_infrastructure_account_id }}{% raw %}:role/GHA-CA-Primary-{% endraw %}{{ repo_name }}{% raw %}
223+
aws-region: {% endraw %}{{ aws_org_home_region }}{% raw %}
224+
225+
- name: Publish distribution to Code Artifact
226+
run: |
227+
. .devcontainer/code-artifact-auth.sh
228+
uv publish --verbose --index code-artifact-primary --username aws --password "$TWINE_PASSWORD"
229+
230+
{% endraw %}{% else %}{% raw %}
231+
- name: Publish distribution to PyPI
232+
uses: pypa/gh-action-pypi-publish@v1.12.4
233+
with:
234+
attestations: false{% endraw %}{% endif %}{% raw %}
235+
236+
install-from-primary:
237+
name: Install package from primary registry
238+
needs: [ publish-to-primary, get-values ]
239+
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
240+
steps:
241+
- name: Setup python
242+
uses: actions/setup-python@{% endraw %}{{ gha_setup_python }}{% raw %}
243+
with:
244+
python-version: {% endraw %}{{ python_version }}{% raw %}
245+
- name: Install from primary registry
246+
run: pip install {% endraw %}{{ package_name | replace('_', '-') }}{% raw %}==${{ needs.get-values.outputs.package_version }}
247+
- name: Confirm library can be imported successfully
248+
run: python -c "import {% endraw %}{{ package_name }}{% raw %}"{% endraw %}

0 commit comments

Comments
 (0)