-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (61 loc) · 2.07 KB
/
Copy pathpublish-to-pypi.yml
File metadata and controls
69 lines (61 loc) · 2.07 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
65
66
67
68
69
name: Publish to PyPI
on:
workflow_run:
workflows: ["Release"]
types: [completed]
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Get latest tag
id: tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using tag: $TAG"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: pip install build tomli tomli_w
- name: Inject version from tag
run: |
python3 - <<'EOF'
import tomli, tomli_w, os
version = os.environ["VERSION"].lstrip("v")
with open("pyproject.toml", "rb") as f:
data = tomli.load(f)
data["project"]["version"] = version
with open("pyproject.toml", "wb") as f:
tomli_w.dump(data, f)
print(f"Set version to {version}")
EOF
env:
VERSION: ${{ steps.tag.outputs.tag }}
- name: Build package
run: python3 -m build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/deezer-python-gql
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1