-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (58 loc) · 2.05 KB
/
publish.yml
File metadata and controls
69 lines (58 loc) · 2.05 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
on:
push:
branches:
- main
paths:
- pyproject.toml
jobs:
publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/tinybird-sdk
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect version change
id: version_check
run: |
BEFORE_SHA="${{ github.event.before }}"
AFTER_SHA="${{ github.sha }}"
BEFORE_VERSION="$(git show "${BEFORE_SHA}:pyproject.toml" 2>/dev/null | sed -nE 's/^version = "([^"]+)"/\1/p' | head -n1)"
AFTER_VERSION="$(sed -nE 's/^version = "([^"]+)"/\1/p' pyproject.toml | head -n1)"
echo "before_version=${BEFORE_VERSION}" >> "$GITHUB_OUTPUT"
echo "after_version=${AFTER_VERSION}" >> "$GITHUB_OUTPUT"
if [ -z "$AFTER_VERSION" ]; then
echo "Could not read current version from pyproject.toml"
exit 1
fi
if [ "$BEFORE_VERSION" = "$AFTER_VERSION" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No version bump detected (${AFTER_VERSION}); skipping publish."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Version changed: ${BEFORE_VERSION} -> ${AFTER_VERSION}"
fi
- name: Set up Python
if: steps.version_check.outputs.changed == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
if: steps.version_check.outputs.changed == 'true'
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build distributions
if: steps.version_check.outputs.changed == 'true'
run: python -m build
- name: Publish package to PyPI
if: steps.version_check.outputs.changed == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}