Skip to content

Commit a2d8908

Browse files
authored
feat: Use trusted publisher [PES-1624] (#322)
1 parent ccb2a51 commit a2d8908

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* coveooss/dev-tooling

.github/workflows/semantic-release.yaml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ on:
33
push:
44
branches: [ main ]
55

6+
# default: least privileged permissions across all jobs
67
permissions:
7-
contents: write
8+
contents: read
89

910
jobs:
1011
semantic-release:
1112
environment: production
1213
runs-on: [ ubuntu-latest ]
14+
permissions:
15+
contents: write
1316
steps:
1417
- name: Harden Runner
1518
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
@@ -31,5 +34,44 @@ jobs:
3134
shell: bash
3235
env:
3336
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
37+
id: release
3538
run: npx semantic-release
39+
40+
- name: Upload | Distribution Artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: distribution-artifacts
44+
path: dist
45+
if-no-files-found: error
46+
47+
outputs:
48+
released: ${{ steps.release.conclusion == "success" || 'false' }}
49+
50+
deploy:
51+
# 1. Separate out the deploy step from the publish step to run each step at
52+
# the least amount of token privilege
53+
# 2. Also, deployments can fail, and its better to have a separate job if you need to retry
54+
# and it won't require reversing the release.
55+
runs-on: ubuntu-latest
56+
needs: release
57+
if: ${{ needs.release.outputs.released == 'true' }}
58+
permissions:
59+
contents: read
60+
id-token: write
61+
environment:
62+
name: pypi
63+
url: https://pypi.org/project/json-schema-for-humans/
64+
65+
steps:
66+
- name: Setup | Download Build Artifacts
67+
uses: actions/download-artifact@v4
68+
id: artifact-download
69+
with:
70+
name: distribution-artifacts
71+
path: dist
72+
73+
- name: Publish to pypi
74+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
75+
76+
with:
77+
print-hash: true

.releaserc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"preset": "conventionalcommits"
1515
}
1616
],
17-
"semantic-release-pypi"
17+
[
18+
"semantic-release-pypi",
19+
{
20+
"pypiPublish": false
21+
}
22+
]
1823
]
19-
}
24+
}

0 commit comments

Comments
 (0)