Skip to content

Commit ddb98aa

Browse files
committed
Set up trusted publishing pipeline
1 parent 9b3bdc4 commit ddb98aa

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

.github/workflows/publish.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,66 @@ on:
55
types: [created]
66

77
jobs:
8-
build:
8+
fix_release_deps:
9+
permissions: write-all
910
runs-on: ubuntu-latest
10-
1111
steps:
1212
- uses: actions/checkout@v3
1313
- uses: actions/setup-python@v4
1414
with:
1515
python-version: '3.11'
1616

17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip pip-tools setuptools
20+
21+
- name: Set configuration
22+
run: |
23+
git config --global user.name "${GITHUB_ACTOR}"
24+
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
25+
26+
- name: Create requirements files
27+
run: |
28+
python tools/generate_requirements_txt.py
29+
pip-compile -o requirements_full.txt pyproject.toml
30+
git add requirements_full.txt requirements.txt
31+
git commit -m "Updated requirements.txt files" || true
32+
33+
- name: Bump version to new tag
34+
run: |
35+
python -m pip install bump-my-version
36+
bump-my-version bump --new-version $GITHUB_REF_NAME patch
37+
git commit -am "Bump version to: $GITHUB_REF_NAME"
38+
39+
- name: Push back changes to main and tag
40+
run: |
41+
git tag --force $GITHUB_REF_NAME HEAD
42+
git push --force --tags
43+
git switch -C main
44+
git push --set-upstream -f origin main
45+
46+
deploy:
47+
needs: fix_release_deps
48+
runs-on: ubuntu-latest
49+
environment: release
50+
permissions:
51+
# IMPORTANT: this permission is mandatory for trusted publishing
52+
id-token: write
53+
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
ref: ${{ github.ref_name }}
58+
59+
- uses: actions/setup-python@v4
60+
with:
61+
python-version: '3.12'
62+
1763
- name: Install dependencies
1864
run: |
1965
python -m pip install --upgrade pip
20-
pip install -U build setuptools wheel
66+
python -m pip install build setuptools>=61.2 wheel
2167
python -m build --no-isolation
2268
2369
- name: Publish package
2470
uses: pypa/gh-action-pypi-publish@release/v1
25-
with:
26-
user: __token__
27-
password: ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)