Skip to content

Commit

Permalink
Merge pull request #15 from dnv-opensource/14-change-the-publishing-w…
Browse files Browse the repository at this point in the history
…orkflow-to-use-openid-connect-trusted-publisher-management-when-publishing-to-pypi

Changed publishing workflow to use OpenID Connect
  • Loading branch information
ClaasRostock authored Feb 27, 2024
2 parents 4ca3462 + 5f34aa0 commit 949ab1a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 72 deletions.
39 changes: 17 additions & 22 deletions .github/workflows/_publish_package.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Publish Package to pypi

on:
workflow_call:
secrets:
PYPI_API_TOKEN:
required: true

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
environment: pypi
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: ./dist/
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
name: Publish Package to pypi

on: workflow_call

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: ./dist/
- uses: pypa/gh-action-pypi-publish@release/v1
42 changes: 19 additions & 23 deletions .github/workflows/_publish_package_test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
name: Publish Package to testpypi

on:
workflow_call:
secrets:
TEST_PYPI_API_TOKEN:
required: true

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
environment: test_pypi
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: ./dist/
- uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
name: Publish Package to testpypi

on: workflow_call

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: ./dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
50 changes: 23 additions & 27 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: Publish Release
run-name: Publish Release ${{ github.event.ref }} created by @${{ github.actor }}

on:
push:
tags:
- v*

jobs:
build_package:
uses: ./.github/workflows/_build_package.yml
publish_package:
needs:
- build_package
uses: ./.github/workflows/_publish_package.yml
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# publish_package_test:
# needs:
# - build_package
# uses: ./.github/workflows/_publish_package_test.yml
# secrets:
# TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
merge_into_release:
uses: ./.github/workflows/_merge_into_release.yml
secrets:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
name: Publish Release
run-name: Publish Release ${{ github.event.ref }} created by @${{ github.actor }}

on:
push:
tags:
- v*

jobs:
build_package:
uses: ./.github/workflows/_build_package.yml
publish_package:
needs:
- build_package
uses: ./.github/workflows/_publish_package.yml
# publish_package_test:
# needs:
# - build_package
# uses: ./.github/workflows/_publish_package_test.yml
merge_into_release:
uses: ./.github/workflows/_merge_into_release.yml
secrets:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}

0 comments on commit 949ab1a

Please sign in to comment.