Skip to content

Commit afc6c47

Browse files
Fix release workflow to use trusted publishing (#949)
* Fix release workflow to use trusted publishing * chore: apply automated version bump --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent dd131b6 commit afc6c47

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

.github/bump.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
echo "Bumping version to ${VERSION}"
2-
echo "v${VERSION}" > VERSION
2+
echo "${VERSION}" > VERSION

.github/workflows/release.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,47 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
release-pypi:
9+
build-pypi:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
1113
steps:
1214
- uses: actions/checkout@v6
1315
- name: Set up Python
1416
uses: actions/setup-python@v6
1517
with:
1618
python-version: "3.x"
1719
cache: 'pip'
18-
- name: Build and Publish
19-
env:
20-
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
21-
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
20+
- name: Build distributions
2221
run: |
2322
python -m pip install --upgrade pip
24-
pip install -U hatch
25-
hatch build
26-
hatch publish
23+
python -m pip install build hatchling
24+
python -m build
25+
- name: Store the distribution packages
26+
uses: actions/upload-artifact@v5
27+
with:
28+
name: python-package-distributions
29+
path: dist/
30+
31+
release-pypi:
32+
name: Upload release to PyPI
33+
needs:
34+
- build-pypi
35+
runs-on: ubuntu-latest
36+
environment:
37+
name: pypi
38+
url: https://pypi.org/p/mkdocs-simple-plugin
39+
permissions:
40+
id-token: write # IMPORTANT: mandatory for trusted publishing
41+
steps:
42+
- name: Download all the dists
43+
uses: actions/download-artifact@v6
44+
with:
45+
name: python-package-distributions
46+
path: dist/
47+
- name: Publish distribution to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
2750
release-docker:
2851
runs-on: ubuntu-latest
2952
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dist/
99
venv/
1010
docs/
1111
artifact.tar
12+
.env

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v4.0.1
1+
4.0.1

0 commit comments

Comments
 (0)