Skip to content

Commit a37e110

Browse files
feat: release with trusted publisher (#514)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent a14f5fd commit a37e110

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

.github/workflows/ci_cd.yml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -431,36 +431,39 @@ jobs:
431431

432432

433433
release:
434-
name: "Release project to public PyPI and GitHub"
435-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
436-
needs: [package, update-changelog]
434+
name: "Release project"
435+
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
436+
needs: [package, update-changelog]
437437
runs-on: ubuntu-latest
438-
env:
439-
PACKAGE_NAME: 'ansys-math-core'
438+
environment: release
439+
permissions:
440+
id-token: write
441+
contents: write
440442
steps:
441-
- name: "Release to the public PyPI repository"
442-
uses: ansys/actions/release-pypi-public@v9
443-
with:
444-
library-name: ${{ env.PACKAGE_NAME }}
445-
twine-username: "__token__"
446-
twine-token: ${{ secrets.PYPI_TOKEN }}
447-
448-
- name: "Release to GitHub"
449-
uses: ansys/actions/release-github@v9
450-
with:
451-
library-name: ${{ env.PACKAGE_NAME }}
452-
453-
- name: "Add a comment on released PRs"
454-
uses: rdlf0/comment-released-prs-action@v3
455-
with:
456-
repo-token: ${{ secrets.GITHUB_TOKEN }}
457-
comment-body: |-
458-
Released in [{{name}}]({{html_url}}).
459-
460-
This comment thread has been locked. If you are still experiencing this issue after upgrading to
461-
${{ env.PACKAGE_NAME }} v[{{name}}]({{html_url}}), please open a new issue."
462-
add-label: true
463-
label-pattern: "release-{{name}}"
443+
- name: "Download the library artifacts from build-library step"
444+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
445+
with:
446+
name: ${{ env.PACKAGE_NAME }}-artifacts
447+
path: ${{ env.PACKAGE_NAME }}-artifacts
448+
449+
- name: "Display structure of downloaded files"
450+
run: ls -Rla
451+
452+
- name: "Release to PyPI using trusted publisher"
453+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
454+
with:
455+
repository-url: "https://upload.pypi.org/legacy/"
456+
print-hash: true
457+
packages-dir: ${{ env.PACKAGE_NAME }}-artifacts
458+
skip-existing: false
459+
460+
- name: "Release to GitHub"
461+
uses: ansys/actions/release-github@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.9
462+
with:
463+
library-name: ${{ env.PACKAGE_NAME }}
464+
token: ${{ secrets.GITHUB_TOKEN }}
465+
add-artifact-attestation-notes: true
466+
changelog-release-notes: true
464467

465468

466469
doc-deploy-stable:

doc/changelog.d/514.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: release with trusted publisher

0 commit comments

Comments
 (0)