Skip to content

Commit f23697b

Browse files
authored
Update release.yml (#4)
1 parent 318c4f9 commit f23697b

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
tags: [ 'v*.*.*' ]
66
workflow_dispatch: {}
77

8-
# Read-only by default
8+
# Least-privilege by default
99
permissions:
1010
contents: read
1111

@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
permissions:
1616
contents: read
17+
1718
steps:
1819
- name: Harden runner
1920
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -24,29 +25,46 @@ jobs:
2425
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2526

2627
- name: Set up Python
27-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6
28+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7 # v6
2829
with:
2930
python-version: "3.12"
3031

31-
- name: Build dists
32+
# No pip install here: use pipx with a pinned version of 'build'
33+
- name: Install pipx + build (pinned)
34+
run: |
35+
set -euxo pipefail
36+
sudo apt-get update
37+
sudo apt-get install -y pipx
38+
pipx ensurepath
39+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
40+
pipx install build==1.2.2
41+
42+
- name: Build distributions
3243
run: |
33-
pip install -U build
34-
python -m build
44+
pyproject-build -o dist
3545
3646
- name: Upload build artifact
3747
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3848
with:
3949
name: dist
4050
path: dist/*
4151

52+
# Enable when ready to publish to PyPI with OIDC (no API token needed).
4253
publish-pypi:
43-
if: ${{ false }} # set to true when ready
54+
# Run only on tag pushes that built artifacts
55+
if: startsWith(github.ref, 'refs/tags/')
4456
needs: build
4557
runs-on: ubuntu-latest
4658
permissions:
4759
contents: read
48-
id-token: write # required only for OIDC-based PyPI publish
60+
id-token: write # required for OIDC to PyPI
61+
4962
steps:
63+
- name: Harden runner
64+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
65+
with:
66+
egress-policy: audit
67+
5068
- name: Download build artifact
5169
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
5270
with:

0 commit comments

Comments
 (0)