Repository navigation
58 lines (49 loc) · 1.8 KB
/
Copy pathrelease.yml
File metadata and controls
58 lines (49 loc) · 1.8 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
# Publish the `replyz` package to PyPI when a GitHub release is published.
# Uses PyPI Trusted Publishing (OIDC): no API tokens are stored in GitHub.
# PyPI pending publisher: owner=replyz, repo=sdk-python, workflow=release.yml, environment=pypi
name: release
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.x"
# The release tag (e.g. v0.0.1) must match the version in pyproject.toml.
- name: Check tag matches version
env:
TAG: ${{ github.event.release.tag_name }}
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
test "${TAG#v}" = "$VERSION" || { echo "Tag $TAG does not match version $VERSION"; exit 1; }
- name: Build sdist and wheel
run: |
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/replyz
permissions:
id-token: write # required for Trusted Publishing (OIDC)
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3