Skip to content

Commit f626140

Browse files
authored
Use trusted publisher and environment (#278)
* Use trusted publisher and environment Setup PyPi for datatrails-python to use a trusted publisher. Delete any API tokens in PyPi for datatrails-python. In github repo delete PYPI secrets and create an environmant called release that is restricted to the main branch.
1 parent 290578c commit f626140

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/package.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
1+
# This workflow will upload a Python Package using a release environment and a trusted publisher.
2+
# See PyPi management in the datatrails confluence service for an explanation.
3+
#
4+
# Create a trusted publisher for datatrails-python in pypi.org and delete any API tokens.
5+
# In github add an environment called release that is restricted to the main branch and
6+
# delete any PYPI secrets.
37

48
name: Package and Publish
59

@@ -9,15 +13,19 @@ on:
913

1014
jobs:
1115
deploy:
16+
environment: release
17+
permissions:
18+
id-token: write # This is required for requesting the JWT
19+
contents: read # This is required for actions/checkout
1220

1321
runs-on: ubuntu-latest
14-
1522
steps:
1623
- uses: actions/checkout@v4
1724
- name: Set up Python
1825
uses: actions/setup-python@v4
1926
with:
2027
python-version: '3.x'
28+
2129
- name: Install dependencies
2230
run: |
2331
export DEBIAN_FRONTEND=noninteractive
@@ -37,21 +45,28 @@ jobs:
3745
python3 -m pip install --upgrade pip
3846
python3 -m pip install -r requirements-dev.txt
3947
python3 -m pip install setuptools wheel
40-
- name: Build and publish
41-
env:
42-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
43-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
48+
shell: bash
49+
50+
- name: Create wheel
4451
run: |
4552
rm -f archivist/about.py
4653
./scripts/version.sh
4754
python3 -m build --sdist
4855
python3 -m build --wheel
49-
twine check dist/*
50-
twine upload dist/*
56+
shell: bash
57+
58+
- name: Publish to PyPi
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
verbose: true
62+
attestations: true
63+
5164
- name: Build docs
5265
run: |
5366
./scripts/zipnotebooks.sh
5467
(cd docs && make clean && make html)
68+
shell: bash
69+
5570
- name: Publish docs
5671
uses: peaceiris/actions-gh-pages@v3
5772
with:

0 commit comments

Comments
 (0)