Repository navigation
64 lines (49 loc) · 2.11 KB
/
Copy pathrelease.yml
File metadata and controls
64 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This workflow will upload the package to PyPi when a release is published
name: Publish Python Package (PyPi)
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing via PyPi
id-token: write
contents: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
- name: Retrieve version from tag name
id: retrieve-version
run: |
tag="${{ github.event.release.tag_name }}"
version_number="${tag#?}"
echo "version: $version_number"
echo "version=$version_number" >> "$GITHUB_OUTPUT"
- name: Bump project version in pyproject.toml and commit changes to current branch and tag
run: |
VERSION=${{ steps.retrieve-version.outputs.version }}
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION
# Keep uv.lock in sync with the bumped version of the pyoverkiz package itself
uv lock
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add pyproject.toml uv.lock
git commit -m "Bump package version to ${{ steps.retrieve-version.outputs.version }}."
git tag -f -a ${{ github.event.release.tag_name }} -m "Release ${{ steps.retrieve-version.outputs.version }}."
git push origin HEAD:main
git push origin -f ${{ github.event.release.tag_name }}
- name: Build package
run: |
uv build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
attestations: true