-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·86 lines (80 loc) · 2.45 KB
/
Copy pathrelease.yml
File metadata and controls
executable file
·86 lines (80 loc) · 2.45 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Release to PyPI
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install build tools
run: python -m pip install --upgrade pip build twine
- name: Build sdist and wheel
run: python -m build
- name: Check distribution metadata
run: python -m twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
- name: Run tests
run: pytest -v
publish:
name: Publish to PyPI
needs: [build, test]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sit-toolkit
permissions:
id-token: write
steps:
- name: Check whether version already exists on PyPI
id: pypi-version
run: |
version="${GITHUB_REF_NAME#v}"
status="$(curl -sS -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/sit-toolkit/${version}/json")"
if [ "$status" = "200" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "sit-toolkit ${version} already exists on PyPI; skipping publish." >> "$GITHUB_STEP_SUMMARY"
elif [ "$status" = "404" ]; then
echo "exists=false" >> "$GITHUB_OUTPUT"
else
echo "Unexpected PyPI status ${status} while checking sit-toolkit ${version}" >&2
exit 1
fi
- name: Download artifacts
if: steps.pypi-version.outputs.exists != 'true'
uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Publish to PyPI
if: steps.pypi-version.outputs.exists != 'true'
uses: pypa/gh-action-pypi-publish@release/v1